Improve Symbol information in Block IR#412
Open
ChingLongTin wants to merge 311 commits intohkust-taco:hkmc2from
Open
Improve Symbol information in Block IR#412ChingLongTin wants to merge 311 commits intohkust-taco:hkmc2from
ChingLongTin wants to merge 311 commits intohkust-taco:hkmc2from
Conversation
Contributor
|
Thanks. Please mark the PR as ready when it's ready for a review. |
There was a problem hiding this comment.
Pull request overview
This PR enhances Block IR symbol fidelity (introducing distinct symbol variants like VirtualClassSymbol, ClassSymbol with richer metadata, and ModuleSymbol) and updates the staging/instrumentation pipeline to support these richer symbols, including stricter handling of multi-parameter-list functions via :ftc.
Changes:
- Extend Block IR symbol model and adjust pretty-printing to rely on symbol
toString(). - Update Scala instrumentation to emit richer symbol objects and to pre-collect class definitions (
defnMap) for later lookup. - Refresh/add staging golden tests and extend Shape primitive-type handling (adds
TypedArray).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| hkmc2/shared/src/test/mlscript/block-staging/StageSymbols.mls | Adds coverage for richer symbols and :ftc error behavior in staged output. |
| hkmc2/shared/src/test/mlscript/block-staging/Functions.mls | Updates golden outputs for new symbol formatting and :ftc behavior. |
| hkmc2/shared/src/test/mlscript-compile/Shape.mls | Extends primitive-type checks to include TypedArray. |
| hkmc2/shared/src/test/mlscript-compile/Block.mls | Updates Block IR model for richer symbol types and simplifies symbol printing. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala | Switches instrumentation entrypoint to applyBlockFinal to build defnMap before staging. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala | Implements richer symbol emission, defnMap collection, and :ftc enforcement for multi-parameter lists. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala
Outdated
Show resolved
Hide resolved
classes staged into VirtualSymbol and literals in Block IR are independent, and Literals do not have TypedArray
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds more types of Symbols to Block IR, and addresses both comments in #355.
#355 (comment): we now require
:ftcto be enabled for functions with multiple parameter lists#355 (comment): we collect all class definitions during compilation into
defnMapso that we can retrieve the definition for desugared classes generated from:ftcIn the future, we will need change
StagedSymbols.mlsto show that we have staged the Symbols correctly.Instead of relying on the printout from
showBlock, we probably will need to print the global map of created symbols, sinceshowBlockwill be used for pretty-printing code for the next stage and will not show a difference between the different types of symbols.