source: trunk/ada-2012/src/asis/asis-extensions-static_expressions.adb@ 349

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

Rename function_call to auxiliary_apply

This node actually represents several constructs. Exact kind of
construct is known only after resolving overloading rules. So let's
rename it to artifical name.

File size: 2.4 KB
Line 
1with Gela.Compilations;
2with Gela.Element_Visiters;
3with Gela.Elements.Auxiliary_Applies;
4with Gela.Elements.String_Literals;
5with Gela.Semantic_Types;
6
7package body Asis.Extensions.Static_Expressions is
8
9 ---------------
10 -- Is_Static --
11 ---------------
12
13 function Is_Static (Self : Value) return Boolean is
14 begin
15 return Self.Is_Static;
16 end Is_Static;
17
18 ------------------
19 -- Static_Value --
20 ------------------
21
22 function Static_Value (Expression : Asis.Expression) return Value is
23 package Get is
24 type Visiter is new Gela.Element_Visiters.Visiter with record
25 Result : Gela.Semantic_Types.Value_Index := 0;
26 end record;
27
28 overriding procedure Auxiliary_Apply
29 (Self : in out Visiter;
30 Node : not null Gela.Elements.Auxiliary_Applies.
31 Auxiliary_Apply_Access);
32
33 overriding procedure String_Literal
34 (Self : in out Visiter;
35 Node : not null Gela.Elements.String_Literals.
36 String_Literal_Access);
37
38 end Get;
39
40 package body Get is
41
42 overriding procedure Auxiliary_Apply
43 (Self : in out Visiter;
44 Node : not null Gela.Elements.Auxiliary_Applies.
45 Auxiliary_Apply_Access)
46 is
47 begin
48 Self.Result := Node.Static_Value;
49 end Auxiliary_Apply;
50
51 overriding procedure String_Literal
52 (Self : in out Visiter;
53 Node : not null Gela.Elements.String_Literals.
54 String_Literal_Access) is
55 begin
56 Self.Result := Node.Static_Value;
57 end String_Literal;
58
59 end Get;
60
61 use type Gela.Semantic_Types.Value_Index;
62 V : Get.Visiter;
63 begin
64 Check_Nil_Element (Expression, "Static_Value");
65 Expression.Data.Visit (V);
66
67 if V.Result = 0 then
68 return (others => <>);
69 else
70 declare
71 Comp : constant Gela.Compilations.Compilation_Access :=
72 Expression.Data.Enclosing_Compilation;
73 begin
74 return (True, Comp.Context.Values.Image (V.Result));
75 end;
76 end if;
77 end Static_Value;
78
79 -----------------
80 -- Value_Image --
81 -----------------
82
83 function Value_Image (Self : Value) return Asis.Program_Text is
84 begin
85 return Self.Image.To_UTF_16_Wide_String;
86 end Value_Image;
87
88end Asis.Extensions.Static_Expressions;
Note: See TracBrowser for help on using the repository browser.