source: trunk/ada-2012/src/semantic/gela-plain_value_sets.ads@ 374

Last change on this file since 374 was 374, checked in by Maxim Reznik, 6 years ago

Add Is_String function for check static values

File size: 3.1 KB
Line 
1-- This package provides Value_Set implementation.
2with Ada.Containers.Hashed_Maps;
3with Ada.Containers.Vectors;
4
5with League.Strings;
6
7with Gela.Arithmetic.Integers;
8with Gela.Elements.Defining_Names;
9with Gela.Semantic_Types;
10with Gela.Value_Sets;
11
12package Gela.Plain_Value_Sets is
13 pragma Preelaborate;
14
15 type Value_Set is limited new Gela.Value_Sets.Value_Set with private;
16 type Value_Set_Access is access all Value_Set'Class;
17
18private
19 subtype Positive_Value_Index is Gela.Semantic_Types.Value_Index
20 range 1 .. Gela.Semantic_Types.Value_Index'Last;
21
22 type Value_Kinds is
23 (Integer_Value, String_Value, List_Value, Denote_Function);
24
25 type Value (Kind : Value_Kinds := String_Value) is record
26 case Kind is
27 when Denote_Function =>
28 Op : Gela.Semantic_Types.Static_Operator;
29 when Integer_Value =>
30 Integer : Gela.Arithmetic.Integers.Value;
31 when String_Value =>
32 String : League.Strings.Universal_String;
33 when List_Value =>
34 Head : Positive_Value_Index;
35 Tail : Positive_Value_Index;
36 end case;
37 end record;
38
39 function Hash (X : Value) return Ada.Containers.Hash_Type;
40
41 package Hash_Maps is new Ada.Containers.Hashed_Maps
42 (Key_Type => Value,
43 Element_Type => Positive_Value_Index,
44 Hash => Hash,
45 Equivalent_Keys => "=",
46 "=" => Gela.Semantic_Types."=");
47
48 package Vectors is new Ada.Containers.Vectors
49 (Index_Type => Positive_Value_Index,
50 Element_Type => Value,
51 "=" => "=");
52
53 type Value_Set is limited new Gela.Value_Sets.Value_Set with record
54 Map : Hash_Maps.Map;
55 Vector : Vectors.Vector;
56 end record;
57
58 not overriding procedure Put_Value
59 (Self : in out Value_Set;
60 Item : Value;
61 Value : out Gela.Semantic_Types.Value_Index);
62
63 overriding procedure String_Literal
64 (Self : in out Value_Set;
65 Image : League.Strings.Universal_String;
66 Value : out Gela.Semantic_Types.Value_Index);
67
68 overriding procedure Numeric_Literal
69 (Self : in out Value_Set;
70 Image : League.Strings.Universal_String;
71 Value : out Gela.Semantic_Types.Value_Index);
72
73 overriding procedure Name
74 (Self : in out Value_Set;
75 Name : Gela.Elements.Defining_Names.Defining_Name_Access;
76 Value : out Gela.Semantic_Types.Value_Index);
77
78 overriding procedure List
79 (Self : in out Value_Set;
80 Head : Gela.Semantic_Types.Value_Index;
81 Tail : Gela.Semantic_Types.Value_Index;
82 Value : out Gela.Semantic_Types.Value_Index);
83
84 overriding procedure Apply
85 (Self : in out Value_Set;
86 Name : Gela.Semantic_Types.Value_Index;
87 Args : Gela.Semantic_Types.Value_Index;
88 Value : out Gela.Semantic_Types.Value_Index);
89
90 overriding function Is_String
91 (Self : Value_Set;
92 Value : Gela.Semantic_Types.Value_Index) return Boolean;
93
94 overriding function Image
95 (Self : Value_Set;
96 Value : Gela.Semantic_Types.Value_Index)
97 return League.Strings.Universal_String;
98
99end Gela.Plain_Value_Sets;
Note: See TracBrowser for help on using the repository browser.