Skip to content
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 support for scanning exception regions #17

Closed
vitek-karas opened this issue Oct 11, 2021 · 0 comments · Fixed by #62
Closed

Add support for scanning exception regions #17

vitek-karas opened this issue Oct 11, 2021 · 0 comments · Fixed by #62
Assignees

Comments

@vitek-karas
Copy link
Collaborator

Valid once #16 is merged.

Repro:
Update the repro program by changing Main to contain try/catch/finally and calling some new methods from the catch and finally regions.

Fix:

  • Work is done in MethodBodyNode.cs
  • Use bodyBlock.ExceptionRegions to get to the exception regions in the original method
  • Update GetStaticDependencies to report the catch clause type token dependency
  • Include exception regions when rewriting the method body in Write.
    • The code already uses InstructionEncoder so just add a ControlFlowBuilder to it
    • Use the ControlFlowBuilder to add labels for the try/catch/finally blocks
    • Add exception regions
    • Remap the catch clause type tokens

Don't forget (or add an issue for) about filter blocks.

vitek-karas added a commit that referenced this issue Oct 12, 2021
Scan method body instructions for all opcodes which take a token operand.
Create static dependency nodes for all tokens found.
Rewrite the method body when writing output to update all tokens in it.

I improved the tests to validate member removal as well.

Implementation notes:
- Brings in ILReader and ILOpcode form the type system
- For now implemented ThrowHelper stub since the type system code uses this.

What's missing:
Scanning exception regions and reporting dependencies for tokens in them
Rewriting exception regions and updating tokens in them
I added #17 to track that work.
@mateoatr mateoatr self-assigned this Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants