-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
[WIP] Added Try/Catch parsing #263
Conversation
boa/src/exec.rs
Outdated
self.realm.environment.initialize_binding(catch_bind, val); | ||
} | ||
|
||
todo!("run the catch block"); |
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.
Not sure if I'm doing this right, @jasonwilliams. The catch_expr
here is a (String, ExprDef::Block)
tuple, and I'm not sure how can I pass the binding value to the catch block. Am I doing this right? Should the type of expression be different?
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.
Seems like you've done it right to me, the catch_bind is the parameter name right?
That should be initiated on the new block.
You'll also need to pop that environment when you've finished with it but there's a lot of refactoring needed in that anyway
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 this, the catch block is a Block
type expression (as it has been implemented right now) but I need to pass a variable to it. Is this the correct way to do it?
Will have another look through his when I catch some time |
Leaving the catch block parsing/execution, this PR is ready for review. I want to note that I did pretty big changes in expression printing. I needed this to properly debug everything, and it seems it's working nicely. It adds proper indenting and pretty formatting. You can try it out by executing the |
Doing a parser rewrite at the moment, so this will most likely need to change. Hopefully the new parser is more easier to reason with and add features to |
Let's close this PR and try it differently with the new parser :) I think maybe we can take some ideas for the execution. |
I added parsing functionality for
try
/catch
/finally
blocks. Code is still WIP, and it should go to another function at least. Also, currently, if an execution finds a try/catch block, it will just panic, which is not nice. But at least, we are now able to parse theassert.js
file of the test262 ECMAScript suite.The
sta.js
file is still not parsed due to:I opened #264 for that.
I did a small idiomatization in the
get_token()
function, so that it uses idiomatic Rust functions instead of an if block. Functionality should remain the same.When adding the
Display
implementation of thetry
/catch
/finally
blocks, I also improved the display of other blocks, to give a nicer view. Still, it's not indenting expressions, so there is some work to do there.Finally, I made some modifications to the CLI so that it will only print the result of the last file. Before, it would print intermediate artifacts such as previously defined functions and more. Still not sure how will multiple file execution actually work.