Skip to content

Commit 732eec8

Browse files
committed
Extract constant entry from do_object_declaration
and introduce a new wrapper in goto_utils.
1 parent 9b802b3 commit 732eec8

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

gnat2goto/driver/goto_utils.adb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ package body GOTO_Utils is
121121
return Ret;
122122
end Symbol_Expr;
123123

124+
procedure New_Valueless_Object_Symbol_Entry (Constant_Name : Symbol_Id;
125+
A_Symbol_Table : in out Symbol_Table)
126+
is
127+
Object_Symbol : Symbol;
128+
begin
129+
Object_Symbol.Name := Constant_Name;
130+
Object_Symbol.BaseName := Constant_Name;
131+
Object_Symbol.PrettyName := Constant_Name;
132+
Object_Symbol.SymType := Make_Nil (No_Location);
133+
Object_Symbol.Mode := Intern ("C");
134+
Object_Symbol.Value := Make_Nil (No_Location);
135+
136+
A_Symbol_Table.Insert (Constant_Name, Object_Symbol);
137+
end New_Valueless_Object_Symbol_Entry;
138+
124139
procedure New_Enum_Member_Symbol_Entry (
125140
Member_Name : Symbol_Id; Base_Name : Symbol_Id; Enum_Type : Irep;
126141
Value_Expr : Irep; A_Symbol_Table : in out Symbol_Table) is

gnat2goto/driver/goto_utils.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ package GOTO_Utils is
4141
function Symbol_Expr (Sym : Symbol) return Irep
4242
with Post => Kind (Symbol_Expr'Result) = I_Symbol_Expr;
4343

44+
procedure New_Valueless_Object_Symbol_Entry (Constant_Name : Symbol_Id;
45+
A_Symbol_Table : in out Symbol_Table);
46+
4447
procedure New_Enum_Member_Symbol_Entry (
4548
Member_Name : Symbol_Id; Base_Name : Symbol_Id; Enum_Type : Irep;
4649
Value_Expr : Irep; A_Symbol_Table : in out Symbol_Table);

gnat2goto/driver/tree_walk.adb

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,25 +2628,6 @@ package body Tree_Walk is
26282628
-- declaration has the pragma Import applied.
26292629
Full_View_Entity : constant Entity_Id := Full_View (Entity);
26302630

2631-
procedure Register_Constant_In_Symbol_Table (N : Node_Id);
2632-
-- Adds a dummy entry to the symbol table to register that a
2633-
-- constant has already been processed.
2634-
2635-
procedure Register_Constant_In_Symbol_Table (N : Node_Id) is
2636-
Constant_Name : constant Symbol_Id :=
2637-
Intern (Unique_Name (Defining_Identifier (N)));
2638-
Constant_Symbol : Symbol;
2639-
begin
2640-
Constant_Symbol.Name := Constant_Name;
2641-
Constant_Symbol.BaseName := Constant_Name;
2642-
Constant_Symbol.PrettyName := Constant_Name;
2643-
Constant_Symbol.SymType := Make_Nil (Sloc (N));
2644-
Constant_Symbol.Mode := Intern ("C");
2645-
Constant_Symbol.Value := Make_Nil (Sloc (N));
2646-
Global_Symbol_Table.Insert (Constant_Name, Constant_Symbol);
2647-
2648-
end Register_Constant_In_Symbol_Table;
2649-
26502631
begin
26512632
if not Has_Init_Expression (N) and then
26522633
Present (Full_View_Entity)
@@ -2659,7 +2640,12 @@ package body Tree_Walk is
26592640
-- register it in the symbol table so that it is not
26602641
-- processed again when the completion is encountered in
26612642
-- the tree.
2662-
Register_Constant_In_Symbol_Table (N);
2643+
New_Valueless_Object_Symbol_Entry (Intern (Unique_Name
2644+
(Defining_Identifier (N))),
2645+
Global_Symbol_Table);
2646+
-- Adds a dummy entry to the symbol table to register that a
2647+
-- constant has already been processed.
2648+
26632649
Do_Object_Declaration_Full
26642650
(Declaration_Node (Full_View_Entity), Block);
26652651
else
@@ -2670,6 +2656,7 @@ package body Tree_Walk is
26702656
end;
26712657
end if;
26722658

2659+
pragma Assert (Global_Symbol_Table.Contains (Obj_Id));
26732660
end Do_Object_Declaration;
26742661

26752662
--------------------------------------------

0 commit comments

Comments
 (0)