@@ -2,6 +2,8 @@ with Namet; use Namet;
2
2
with Nlists ; use Nlists;
3
3
with Aspects ; use Aspects;
4
4
5
+ with Ada.Text_IO ; use Ada.Text_IO;
6
+
5
7
package body GOTO_Utils is
6
8
7
9
-- -------------------
@@ -92,6 +94,100 @@ package body GOTO_Utils is
92
94
return Ret;
93
95
end Symbol_Expr ;
94
96
97
+ -- ------------------------------
98
+ -- New_Parameter_Symbol_Entry --
99
+ -- ------------------------------
100
+
101
+ procedure New_Parameter_Symbol_Entry (Name_Id : Symbol_Id;
102
+ BaseName : String;
103
+ Symbol_Type : Irep;
104
+ A_Symbol_Table : in out Symbol_Table)
105
+ is
106
+ New_Symbol : Symbol;
107
+ begin
108
+ New_Symbol.SymType := Symbol_Type;
109
+ New_Symbol.Name := Name_Id;
110
+ New_Symbol.PrettyName := Intern (BaseName);
111
+ New_Symbol.BaseName := Intern (BaseName);
112
+ New_Symbol.Mode := Intern (" C" );
113
+
114
+ -- Setting it as a parameter
115
+ New_Symbol.IsParameter := True;
116
+ New_Symbol.IsLValue := True;
117
+ New_Symbol.IsFileLocal := True;
118
+ New_Symbol.IsThreadLocal := True;
119
+
120
+ if A_Symbol_Table.Contains (Key => Name_Id) then
121
+ Put_Line (Standard_Error,
122
+ " ----------At: New_Parameter_Symbol_Entry----------" );
123
+ Put_Line (Standard_Error,
124
+ " ----------Trying to create known symbol.----------" );
125
+ Put_Line (Standard_Error, " ----------" & BaseName & " ----------" );
126
+ else
127
+ A_Symbol_Table.Insert (Name_Id, New_Symbol);
128
+ end if ;
129
+ end New_Parameter_Symbol_Entry ;
130
+
131
+ -- -----------------------------
132
+ -- New_Function_Symbol_Entry --
133
+ -- -----------------------------
134
+
135
+ function New_Function_Symbol_Entry (Name : String; Symbol_Type : Irep;
136
+ Value : Irep;
137
+ A_Symbol_Table : in out Symbol_Table)
138
+ return Symbol is
139
+ New_Symbol : Symbol;
140
+ begin
141
+ New_Symbol.SymType := Symbol_Type;
142
+ New_Symbol.Name := Intern (Name);
143
+ New_Symbol.PrettyName := New_Symbol.Name;
144
+ New_Symbol.BaseName := New_Symbol.Name;
145
+ New_Symbol.Mode := Intern (" C" );
146
+ New_Symbol.Value := Value;
147
+
148
+ if A_Symbol_Table.Contains (Key => Intern (Name)) then
149
+ Put_Line (Standard_Error,
150
+ " ----------At: New_Function_Symbol_Entry----------" );
151
+ Put_Line (Standard_Error,
152
+ " ----------Trying to create known symbol.----------" );
153
+ Put_Line (Standard_Error, " ----------" & Name & " ----------" );
154
+ else
155
+ A_Symbol_Table.Insert (Intern (Name), New_Symbol);
156
+ end if ;
157
+ return New_Symbol;
158
+ end New_Function_Symbol_Entry ;
159
+
160
+ -- ------------------------
161
+ -- Create_Fun_Parameter --
162
+ -- ------------------------
163
+
164
+ -- To be called when one needs to build a function inside gnat2goto
165
+ -- Modifies symbol table and Param_List as a side effect
166
+ -- Returns irep of type I_Code_Parameter
167
+ function Create_Fun_Parameter (Fun_Name : String; Param_Name : String;
168
+ Param_Type : Irep; Param_List : Irep;
169
+ A_Symbol_Table : in out Symbol_Table;
170
+ Source_Location : Source_Ptr := No_Location)
171
+ return Irep is
172
+ Func_Param_Id : constant Symbol_Id := Intern (Fun_Name & Param_Name);
173
+ -- Create an irep for the parameter
174
+ Value_Arg : constant Irep :=
175
+ Make_Code_Parameter (Source_Location => Source_Location,
176
+ Default_Value => Ireps.Empty,
177
+ I_Type => Param_Type,
178
+ Base_Name => Param_Name,
179
+ This => False,
180
+ Identifier => Unintern (Func_Param_Id));
181
+ begin
182
+ -- Creates a symbol for the parameter
183
+ New_Parameter_Symbol_Entry (Name_Id => Func_Param_Id,
184
+ BaseName => Param_Name,
185
+ Symbol_Type => Param_Type,
186
+ A_Symbol_Table => A_Symbol_Table);
187
+ Append_Parameter (Param_List, Value_Arg);
188
+ return Value_Arg;
189
+ end Create_Fun_Parameter ;
190
+
95
191
-- -------------------
96
192
-- Name_Has_Prefix --
97
193
-- -------------------
0 commit comments