-
Notifications
You must be signed in to change notification settings - Fork 63
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
Infrastructure for AST transformations and factored out delay transformation #1508
Conversation
org.lflang/src/org/lflang/generator/cpp/CppDelayBodyGenerator.kt
Outdated
Show resolved
Hide resolved
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.
I think this looks great! Thanks for doing this! Aside from making the transformation optional, this code cleanup was much overdue. I've left some minor comments.
/** | ||
* Apply the AST transformation to all given reactors. | ||
*/ | ||
void applyTransformation(List<Reactor> reactors); |
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.
I would change this to take in the entire resource so that the interface is more general.
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.
Yes, my first intuition was also to pass the model and/or the resource. However, it appears that there is some intelligence built into generating this list of reactors (this is handled by the instance graph). We would need to duplicate that code or refactor it to make it reusable, but I wanted to avoid spending too much time on this. Also I am not sure which information other than transformations we would need. I suggest to revisit this as part of fixing #1510
org.lflang/src/org/lflang/generator/cpp/CppDelayBodyGenerator.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Marten Lohstroh <[email protected]>
The main motivation of this PR is to apply the after delay transformation only optionally when needed by the target.
Currently, the after delay transformation is handled in between some other important passes in
GeneratorBase
and cannot easily be moved such that it can be called directly by our code generators before or after invokingGeneratorBase
. Therefore, this PR introduces aTransformation
interface which allows the target generators to register transformations which are then automatically applied.This PR implements the
AfterDelayTransformation
and factors out the target specific code into a new interfaceDelayBodyGenerator
which the targets need to provide.