-
Notifications
You must be signed in to change notification settings - Fork 161
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
Add a coder to reread syntaxtrees #3371
Conversation
The first commit "WIP: add SyntaxTreeDefaultCoder" should be removed. |
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.
Overall this is looking close to be ready for merging, but I still left some comments.
8e327f0
to
bd5364f
Compare
Codecov Report
@@ Coverage Diff @@
## master #3371 +/- ##
==========================================
+ Coverage 85.33% 85.34% +<.01%
==========================================
Files 699 699
Lines 345897 346082 +185
==========================================
+ Hits 295181 295365 +184
- Misses 50716 50717 +1
|
@fingolfin I think I adressed all your comments. I also added sensible error messages for checking if a needed entry in a syntax tree node record is bound. |
5438351
to
581bb00
Compare
581bb00
to
4a17596
Compare
This PR is now based on #3370 |
e0351b8
to
76c7e11
Compare
I think I addressed all your comments, and also added the checks we discussed today. Should we try to add the context object, too, or would be a different PR a better place. |
76c7e11
to
ce6af4f
Compare
@fingolfin I think I adressed all of your comments |
ce6af4f
to
c050276
Compare
@ChrisJefferson @fingolfin ping? |
So, possibly stupid question, is this supposed to be complete, or progress towards a rereader? I tried extending the test which tests SYNTAX_TREE on every function, by the following horrible patch:
And GAP segfaults. |
@ChrisJefferson It does not work on operations, no. But I should really check that when calling |
Wait, this is a different issue. Sorry. |
This is enough to upset it:
|
I will fix that. I am not sure how that slipped. Thank you. Anyway, there is a thing that I am aware of that does not work yet, namely I plan to overcome this by adding a |
(I don't know if this is reasonable), if in cases where SYNTAX_TREE_CODE failed it just returned 'fail', then we could obviously test for when it works, or returns fail, and then still loop over all the functions? (I don't know if that's reasonable given the way it works internally) |
@ChrisJefferson Currently, they throw an error, which I would guess is more reasonable. But I could do a The problem rereading those
|
I was just thinking about if it would be reasonable to merge something like the diff I made, to test a large set of functions. If we are still too far away from that, we can also merge the current partial code, and work on improving it later. |
No, absolutely reasonable. I will include it. |
@ChrisJefferson I added the full cycle test, and they pass |
tst/testinstall/syntaxtree.tst
Outdated
> elif IsOperation(v) then | ||
> for i in [1..6] do | ||
> for x in METHODS_OPERATION(v, i) do | ||
> if IsFunction(x) and not IsKernelFunction(v) then | ||
> SYNTAX_TREE(x); | ||
> if not test_tree(v) then | ||
> Print("failed round trip: ",n,"\n"); |
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.
Would be more useful like this:
> Print("failed round trip: ",n,"\n"); | |
> Print("METHODS_OPERATION(", n, ",", i, ") failed round trip\n"); |
src/code.c
Outdated
{ | ||
CodeReturnVoidWhichIsNotProfiled(); | ||
nr++; | ||
while( 1 ){ |
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.
Code formatting!
while( 1 ){ | |
while (1) { |
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.
Also, this code really needs to be commented. Both what it is doing (see my suggestion below), but also more importantly, why it is doing it. Which I don't know right now...
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 doesn't it suffice to insert the following into the existing code, to achieve the same effect?
// find the last statement
while (T_SEQ_STAT <= TNUM_STAT(stat1) && TNUM_STAT(stat1) <= T_SEQ_STAT7) {
TNUM_STAT(stat1) <= T_SEQ_STAT7) {
UInt size = SIZE_STAT(stat1) / sizeof(Stat);
stat1 = READ_STAT(stat1, size - 1);
}
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, logically, this does exactly the same, except it is not intertwined with the addition of the return void
to the statement.
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.
About the why: The thing is that if we reread a syntax tree, the statements are already nested, i.e., if there are more than 7 statements in the body, the last one is already a new SEQ_STAT*
. This ensures that the return;
is only added if there is really no return
in the last statement.
When a function is coded, the statements are packed into nested statements later.
I discovered this problem when I realized that "long" functions get an additional return;
to indicate that the statement stack is complete and does not need any more additions.
See here for the initial discussion and history