-
Notifications
You must be signed in to change notification settings - Fork 231
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
Position/locate/pseudocode revamp (split) #3395
Conversation
mahrud
commented
Aug 9, 2024
- removed duplicated keywordTexMath
- renamed thenclause to thenClause in interpreter
- removed functionCode.arrow
- added a frame error in evalraw
- changed how position is stored in Token
- fixed lookup for symbols
- added Pseudocode and PseudocodeClosure types
- removed col+1 from changed tostring(Position)
- removed +1 from endpoint of errors
- added position to stringCode and functionCode
- updated codePosition
- updated convertr.d
- setup functions for some operators
- fixed error start point location in a test
- fixed a ComputationsBook test
- updated documentation for pseudocode
- revamped locate and moved it to debugging.dd
- updated locate and code in code.m2
- moved disassemble and pseudocode to debugging.dd
- added toList(Code) in debugging.dd
- moved tostring(Code) to debugging.dd
- added printing and introspection for Pseudocode
- added typical values for disassemble and pseudocode
- added disassemble for FunctionBody and Pseudocode
- renamed fetch to local-fetch
@pzinn have a look at this PR. I tried to stay as close to #3363 as possible, but there are several changes:
Several things that I think we should consider doing:
To do that last item, I need your help/clarification: I couldn't figure out a precise change resulted by these commits: Could you give examples of what output these change? I'm guessing two of them might correspond to test fixes in ca8cbbd and 4bb2b0c. |
745a1c2
to
2e53884
Compare
For the |
Paul mentioned one in the description of his PR, and I added it as a test. Before: i1 : () -> "blah
foo";
i2 : locate oo
o2 = stdio:1:3-1:3 Now: i1 : () -> "blah
foo";
i2 : locate oo
o2 = stdio:1:0-2:4 |
a0fc17f
to
3d9e4b2
Compare
is about fixing the location of symbols that are "exported" before being defined, as is often done (maybe shouldn't?) in packages. I think we discussed this at some point. These I think were hacks intended to compensate for the inaccuracy of the position of code. they are no longer needed. |
probably |
Can you give an example a situation where this is different now? This didn't work: i1 : needsPackage "FirstPackage"
o1 = FirstPackage
o1 : Package
i2 : locate firstFunction
i3 : |
this is about symbol location:
|
e.g. fixes "toString locate symbol firstFunction".
3d9e4b2
to
85f3094
Compare
Thanks, just added a test. |
85f3094
to
067a274
Compare
067a274
to
1ff9ef6
Compare
Getting these new tests to pass has been a pain, but hopefully it'll pay off by preventing accidental regressions. |
Does this have everyone's approval now? |
I'd still like to spend a bit more time reviewing. Classes just started, but I'll try to get to it this week. |
I'm confused -- what was the point of asking me for a review if it gets merged before I get a chance to complete it? |
Oops, my fault! Sorry about that |
I'm going to make a new issue to keep track of remaining work. You can still finish the review here too, and I'll add whatever needs to be changed there. Also, do you know how this "frame error" can occur? 608a8bd |
|
I'm confused. In your example I suppose i56 : f = x -> y -> x = x+y;
i57 : g = f(0);
i58 : g(1)
o58 = 1
i59 : g(2)
o59 = 3
i60 : g(2)
o60 = 5
i61 : g' = pseudocode g
o61 = function restargs true
numparms 1
framesize 1
frameID 15399
body local-assign 0 1 2-OP + local-fetch 0 1
local-fetch 0 0
o61 : PseudocodeClosure
i62 : g'_4_0_0
o62 = local-fetch 0 1
o62 : Pseudocode
i63 : value oo
stdio:57:18:(3): error: frame error In this case i64 : peek frame g'
o64 = MutableList{5} |
That's a complicated issue. Yes, in principle, one could try to get a closure even for sub-code of some function, and in fact in some earlier iteration of this PR I did that. But it was too hacky and I gave up on it. Right now |
Ah, I understand, |
something like that could work (I hadn't tried that), except the output of |
is i:IfThen do Code(ifCode(convert(i.predicate),unseq(c:=convert0(i.thenClause)),NullCode,combinePosition(i.ifToken.position,codePosition(c)))) | ||
is i:IfThenElse do Code(ifCode(convert(i.predicate),convert(i.thenClause),unseq(c:=convert0(i.elseClause)),combinePosition(i.ifToken.position,codePosition(c)))) |
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.
@pzinn what was the motivation behind unseq
and the choices for combinePosition
instead of treePosition
? The positions seem to be random in practice, and I'm thinking about undoing some of these.