Skip to content

Commit 43c5e3f

Browse files
committed
Decorate addressed variables
with dollar sign and via a helper function.
1 parent b5f4014 commit 43c5e3f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,20 +4713,20 @@ package body Tree_Walk is
47134713
Address_Expr : constant Irep := Get_Address_Expr;
47144714
Address_Type : constant Irep :=
47154715
Make_Pointer_Type (Target_Type_Irep);
4716+
Decorated_Name : constant String :=
4717+
Decorate_Addressed_Variables (Get_Identifier (Target_Name));
47164718
Lhs_Expr : constant Irep :=
47174719
Make_Symbol_Expr (Source_Location => Source_Loc,
47184720
I_Type => Address_Type,
47194721
Range_Check => False,
4720-
Identifier =>
4721-
"Ptr_" & Get_Identifier (Target_Name));
4722+
Identifier => Decorated_Name);
47224723
Rhs_Expr : constant Irep :=
47234724
Typecast_If_Necessary (Expr => Address_Expr,
47244725
New_Type => Address_Type,
47254726
A_Symbol_Table => Global_Symbol_Table);
47264727
begin
47274728
New_Object_Symbol_Entry
4728-
(Object_Name =>
4729-
Intern ("Ptr_" & Get_Identifier (Target_Name)),
4729+
(Object_Name => Intern (Decorated_Name),
47304730
Object_Type => Address_Type,
47314731
Object_Init_Value => Rhs_Expr,
47324732
A_Symbol_Table => Global_Symbol_Table);

gnat2goto/ireps/ireps_generator.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,10 @@ def generate_code(self, optimize, schema_file_names):
18781878
write(s, "-- Increase Pointer Depth")
18791879
write(s, "")
18801880

1881+
write(s, "function Decorate_Addressed_Variables (Name : String) return String;")
1882+
write(s, "-- Create Decorated Name")
1883+
write(s, "")
1884+
18811885
write(s, "function Remove_Extra_Type_Information (I : Irep) return Irep;")
18821886
write(s, "-- Remove Type Bounds")
18831887
write(s, "")
@@ -2130,7 +2134,8 @@ def generate_code(self, optimize, schema_file_names):
21302134
with indent(b):
21312135
write(b, "return Make_Dereference_Expr (Make_Symbol_Expr (Get_Source_Location (I),")
21322136
with indent(b):
2133-
write(b, "Make_Pointer_Type (Get_Type (I), 64), False, \"Ptr_\" & Name),")
2137+
write(b, "Make_Pointer_Type (Get_Type (I), 64), False,")
2138+
write(b, "Decorate_Addressed_Variables (Name)),")
21342139
write(b, "Get_Source_Location (I), Get_Type (I));")
21352140
write(b, "end if;")
21362141
write(b, "")
@@ -2151,6 +2156,15 @@ def generate_code(self, optimize, schema_file_names):
21512156
write(b, "end Wrap_Pointer;")
21522157
write(b, "")
21532158

2159+
write_comment_block(b, "Decorate_Addressed_Variables")
2160+
write(b, "function Decorate_Addressed_Variables (Name : String) return String")
2161+
write(b, "is")
2162+
write(b, "begin")
2163+
with indent(b):
2164+
write(b, "return Name & \"$Ptr\";")
2165+
write(b, "end Decorate_Addressed_Variables;")
2166+
write(b, "")
2167+
21542168
write_comment_block(b, "Remove_Extra_Type_Information")
21552169
write(b, "function Remove_Extra_Type_Information (I : Irep) return Irep")
21562170
write(b, "is")

0 commit comments

Comments
 (0)