Skip to content

Commit

Permalink
Get all preambles in Python, add test, update C test, and align react…
Browse files Browse the repository at this point in the history
…or-c
  • Loading branch information
edwardalee authored and lhstrh committed Jul 31, 2024
1 parent a088c1a commit 55a1680
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static String generatePythonClass(
pythonClasses.pr(generatePythonClassHeader(className));
// Generate preamble code
pythonClasses.indent();
pythonClasses.pr(PythonPreambleGenerator.generatePythonPreambles(reactor.getPreambles()));
pythonClasses.pr(
PythonPreambleGenerator.generatePythonPreambles(ASTUtils.allPreambles(reactor)));
// Handle runtime initializations
pythonClasses.pr(generatePythonConstructor(decl, types));
pythonClasses.pr(PythonParameterGenerator.generatePythonGetters(decl));
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/c/reactor-c
Submodule reactor-c updated 0 files
3 changes: 3 additions & 0 deletions test/C/src/PreambleInherited.lf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ reactor A {
}

reactor B extends A {
reaction(startup) {=
printf("FOO 2: %d\n", FOO);
=}
}

main reactor {
Expand Down
18 changes: 18 additions & 0 deletions test/Python/src/PreambleInherited.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
target Python

reactor Base {
preamble {=
def initiation(self):
print("Hello World\n")
=}
}

reactor Extended extends Base {
reaction(startup) {=
self.initiation()
=}
}

main reactor {
e = new Extended()
}

0 comments on commit 55a1680

Please sign in to comment.