-
Notifications
You must be signed in to change notification settings - Fork 12
Implement namespace.follow for symbol types #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
276b48f
to
80cd0e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to take a closer look tomorrow, but I feel like the additions to the python code need some cleanup and some explanation for what is happening in there.
@@ -51,6 +52,8 @@ package body Driver is | |||
procedure Translate_Standard_Types; | |||
procedure Initialize_CProver_Internal_Variables (Start_Body : Irep); | |||
procedure Add_CProver_Internal_Symbols; | |||
procedure Follow_Type_Declarations (Old_Table : Symbol_Table; | |||
New_Table : in out Symbol_Table); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we create a new symbol table rather than following symbols in the old one?
Also, if you're not reading fron New_Table
it should just be out
rather than in out
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I'm rewriting the symbols and I don't think I can modify a hash map while iterating over it. The second part: yes, will rewrite to just out
.
gnat2goto/driver/driver.adb
Outdated
for Sym_Iter in Old_Table.Iterate loop | ||
declare | ||
Ignored : Boolean; | ||
Unused : Symbol_Maps.Cursor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused_Inserted
and Unused_Position
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied it from a function above this one, but ok, this sounds more descriptive.
@@ -1835,6 +1835,8 @@ package body Tree_Walk is | |||
when E_Record_Subtype => Do_Itype_Record_Subtype (N), | |||
when E_Signed_Integer_Type => Do_Itype_Integer_Type (N), | |||
when E_Floating_Point_Type => Create_Dummy_Irep, | |||
when E_Anonymous_Access_Type => Make_Pointer_Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be unrelated to the follow functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although it is required to make the primitive_pointer
test work. So, separate commit or separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preference for me would be separate PR but separate commit at the least
gnat2goto/ireps/ireps_generator.py
Outdated
write(s, "") | ||
write(s, "with GNATCOLL.JSON; use GNATCOLL.JSON;") # JSON | ||
write(s, "with GNATCOLL.JSON; use GNATCOLL.JSON;") # JSON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated formatting change? I don't really mind this being part of this PR but could you do it in a separate commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be here, will remove.
Value : constant Irep := Current_Symbol.Value; | ||
begin | ||
Modified_Symbol.SymType := | ||
Follow_Irep (SymType, Follow_Symbol'Access); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be easier to follow if we just passed the Old_Table
as a parameter to Follow_Irep
and did the Follow_Symbol
logic over there? Or is there some other reason why we have to use the function pointer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the original plan but I couldn't figure out how to declare Symbol_Table
in Ireps.adb
. I always ended up with circular dependencies.
gnat2goto/ireps/ireps_generator.py
Outdated
@@ -1596,6 +1612,15 @@ def generate_code(self, optimize, schema_file_names): | |||
continuation(b) | |||
write(b, "") | |||
|
|||
write(b, "function Follow_Irep (L : Irep_List;") | |||
# with indent(b): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, will be removed.
@@ -1816,6 +1841,98 @@ def generate_code(self, optimize, schema_file_names): | |||
write(b, "end To_JSON;") | |||
write(b, "") | |||
|
|||
write_comment_block(b, "Follow_Irep") | |||
write(b, "function Follow_Irep (I : Irep;") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this bit is complicated enough to warrant being factored out into its own function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean another python script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also uncomfortable with how big this new code inserted is. I understand it's codegen stuff, which normally is long, but I'm also under the impression that it has to be factored out into a function, and then called here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just an organisational comment. I'm not too fussed about it. Good job.
@@ -1816,6 +1841,98 @@ def generate_code(self, optimize, schema_file_names): | |||
write(b, "end To_JSON;") | |||
write(b, "") | |||
|
|||
write_comment_block(b, "Follow_Irep") | |||
write(b, "function Follow_Irep (I : Irep;") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also uncomfortable with how big this new code inserted is. I understand it's codegen stuff, which normally is long, but I'm also under the impression that it has to be factored out into a function, and then called here.
80cd0e2
to
d5f6f99
Compare
2b87045
to
79445d0
Compare
@xbauch The tests show that gnat2goto now crashes on (almost?) all tests? Was it like this before, and/or is it depending on another PR going in? |
@NlightNFotis better? |
Some of the CI failures may be fixed by a rebase (which you'll need anyway) |
92cec80
to
724d839
Compare
Context: array copies are called via a wrapper function - this took the array length as a parameter. Now this is set directly (the parameter is kept and assigned to a dummy var to minimise code change as we might want to revert this in future. The dummy var is to prevent gnat error over unused var.
The TO_JSON part at least.
In driver.adb call Follow_Irep on every symbol in symbol table. In ireps_generator.py reuse to_json to implement follow_irep: traverse the irep tree to follow I_Symbol_Type ireps.
54cc8c5
to
72a22cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be in a good shape now.
d2dae7e
to
39df83c
Compare
In
driver.adb
callFollow_Irep
on every symbol in symbol table.In
ireps_generator.py
reuseTo_JSON
to implementFollow_Irep
: traverse the irep tree to followI_Symbol_Type
nodes. The irep table is not modified: we only change what ireps are referred to in some node (of the irep tree).