Proof of Concept for exception flow with finally's #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was hoping you could take a look at this, it's not meant to be merged in its current form. If we can come to some concencus about how this should work then I will add a lot of tests for weird edge cases before merging.
This change implements control flow for try-catch-finally constructs. It only takes explicitly thrown exceptions into account, and does not (yet?) support exceptions thrown in method/function calls. I also implemented the finally's for goto & return.
The finally's were actually a big pain to get working, but I think I got there now. The idea is that we inline finally code in every possible path that can go through it. This is apparently how the JVM does it since 1.6. I guess it could be possible to do it without inlining, but that would require some kind of subroutine or weird jumping logic at the end of a finally block.
I added some Ops for dealing specifically with the current exception. They assume the exception gets stored in some globally available location, and does not use a variable. But maybe some other types of Ops could be more suited?
Any feedback/comments would be much appreciated.