-
Notifications
You must be signed in to change notification settings - Fork 139
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
[Compiler+VM POC] Add compilation for default functions #3727
base: feature/compiler
Are you sure you want to change the base?
Conversation
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:feature/compiler commit a24debb Collapsed results for better readability
|
// Inherited functions are always from interfaces | ||
interfaceType := member.ContainerType.(*sema.InterfaceType) | ||
|
||
elaboration, err := d.config.ElaborationResolver(interfaceType.Location) |
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.
There is a caveat here: In order to make this work for all/complex cases, this "imported"/"brought-over" elaboration also needs to be stored (or may be merged with the current program's elaborations). Because the compiler need type-info to compile certain things, and for these copied-over functions, type information is only available in their original elaboration (not in current program's elaboration).
This needs to be handled properly (this PR does not handles this).
// desugarTransaction Convert a transaction into a composite type declaration, | ||
// so the code-gen would seamlessly work without having special-case anything in compiler/vm. | ||
// Transaction parameters are converted into global variables. | ||
// An initializer is generated to set parameters to above generated global variables. | ||
func (c *Compiler[_]) desugarTransaction(transaction *ast.TransactionDeclaration) ( |
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.
Moved to the new desugar phase
Description
The default functions are brought/copied over at AST level, so that compiler can treat them similar to any other function that is defined within a composite type.
This PR introduces a separate desugar phase for such AST modifications, to decouple the tree re-writing logic from the compiler phase.
master
branchFiles changed
in the Github PR explorer