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

Generated structs exposed in header files, reactions linkable from separate source files, and updated C target preamble visibility #1599

Merged
merged 98 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
26df586
Add a minimal test case.
petervdonovan Feb 14, 2023
3834317
Add header file.
petervdonovan Feb 15, 2023
2d3d9e0
Start working on code generator (WIP).
petervdonovan Feb 15, 2023
74ce30e
Get a basic smoke test to work.
petervdonovan Feb 15, 2023
f037bcc
Get a test involving inputs/outputs to work.
petervdonovan Feb 15, 2023
308db3b
Adjust self struct names.
petervdonovan Feb 15, 2023
6d2a177
Draft proposal for making the grammar unambiguous
lhstrh Feb 16, 2023
72ffe96
Alternative proposal without semicolons and optional naming
lhstrh Feb 17, 2023
7214350
Swap name and body following suggestion by @cmnrd.
lhstrh Feb 17, 2023
e8faf9d
Update LinguaFranca.xtext
lhstrh Feb 17, 2023
ff2240a
Minor grammar repair.
petervdonovan Feb 22, 2023
ec935f2
Minor bugfixes.
petervdonovan Feb 23, 2023
8e29e39
Do not generate prototypes for inlined reactions.
petervdonovan Feb 23, 2023
538da7c
Addressing NPE in C++ tests.
petervdonovan Feb 23, 2023
f037ab4
Hack around the Arduino #includes.
petervdonovan Feb 23, 2023
ede2f9f
Address another name conflict in C++ generator.
petervdonovan Feb 23, 2023
29ad276
Address Python test failure.
petervdonovan Feb 23, 2023
31fef2e
Try again to address C++ name conflict.
petervdonovan Feb 23, 2023
6a8430c
Address failing CCpp tests.
petervdonovan Feb 23, 2023
6e5b7a1
Fix type inference issue.
petervdonovan Feb 23, 2023
7fa42ba
Replace ReactorDecl.getName() -> Reactor.getName()
petervdonovan Feb 24, 2023
84a9114
Use hashes to prevent name conflicts.
petervdonovan Feb 24, 2023
faa9408
Factor reactor code out into separate files.
petervdonovan Feb 24, 2023
0a6b5b3
Fix includes.
petervdonovan Feb 24, 2023
1d561e8
[C] Try again to fix namespacing issues.
petervdonovan Feb 25, 2023
8fd1955
[C] Get a CCpp smoke test to pass.
petervdonovan Feb 25, 2023
aacfbd7
[C] Get some Python tests to pass.
petervdonovan Feb 25, 2023
9277c96
Minor bugfixes for CCpp, Arduino.
petervdonovan Feb 25, 2023
bd3a820
Resolve conflict in CPreambleGenerator.
petervdonovan Feb 25, 2023
ea979ee
Do not delete include directory.
petervdonovan Mar 3, 2023
dd24c55
Copy file-level preamble to reactor-specific files
petervdonovan Mar 3, 2023
9b28591
Make ScheduleAt compile.
petervdonovan Mar 3, 2023
848e8bf
Fixes for CCpp.
petervdonovan Mar 3, 2023
b145e51
Update tests according to preamble changes.
petervdonovan Mar 3, 2023
0d92151
Do not include user-facing headers in main .c file
petervdonovan Mar 3, 2023
a45fb13
Get a federated smoke test to pass.
petervdonovan Mar 3, 2023
880ae35
Fix issue with modal models.
petervdonovan Mar 4, 2023
59b686c
Do not generate code for uninstantiated reactors.
petervdonovan Mar 4, 2023
e538915
Repair user-facing generated header files.
petervdonovan Mar 4, 2023
78a4571
Attempt to pass test with imported preamble.
petervdonovan Mar 4, 2023
6eb0f04
Get federated smoke test to pass again.
petervdonovan Mar 8, 2023
a857373
Get CCPP smoke test to pass again.
petervdonovan Mar 8, 2023
1657031
Address failing serialization test.
petervdonovan Mar 8, 2023
ee90c33
Address failing benchmark test.
petervdonovan Mar 8, 2023
398ff83
Address failing Python federated test.
petervdonovan Mar 8, 2023
abd1ffe
Address misc failing C tests.
petervdonovan Mar 8, 2023
d3cfb00
Format C tests.
petervdonovan Mar 8, 2023
2f02042
Do not run no_inlining tests as CCpp.
petervdonovan Mar 9, 2023
4349db5
Update ci.yml.
petervdonovan Mar 12, 2023
a7e4e42
Update ci.yml.
petervdonovan Mar 21, 2023
0ab0b3d
Merge branch 'master' into bodyless-reactions
petervdonovan Mar 21, 2023
3cf6b8f
Attempt to fix failing C++ federated tests.
petervdonovan Mar 21, 2023
a2ba495
Merge branch 'master' into bodyless-reactions
petervdonovan Mar 23, 2023
36c8088
Address failing Python tests.
petervdonovan Mar 23, 2023
04da8d2
Attempt to fix the file system races in fed-gen.
petervdonovan Mar 23, 2023
f67cc8f
Hacky (?) fix for Python compilation issues.
petervdonovan Mar 24, 2023
ca3f167
Address failing TS federated tests.
petervdonovan Mar 24, 2023
a23fd47
Delete some #includes from reactor.h.
petervdonovan Mar 24, 2023
9ba7d56
Merge branch 'master' into bodyless-reactions
petervdonovan Mar 24, 2023
1fa316c
Prune user-visible namespace.
petervdonovan Mar 24, 2023
a8c9693
Update tracing utilities.
petervdonovan Mar 24, 2023
9729f27
Update submodule.
petervdonovan Mar 24, 2023
84cae07
Another fix in tracing utilities.
petervdonovan Mar 24, 2023
c130d60
Repair runtime copying.
petervdonovan Mar 24, 2023
8009d8b
More missing #includes in tests.
petervdonovan Mar 24, 2023
368f01a
Address another round of test failures.
petervdonovan Mar 25, 2023
26e0637
Address another round of test failures.
petervdonovan Mar 25, 2023
bfb69ec
Address another round of test failures.
petervdonovan Mar 25, 2023
d491f5e
Address another round of test failures.
petervdonovan Mar 25, 2023
2dc2fd0
Address another round of test failures.
petervdonovan Mar 25, 2023
02a56b4
Try again to pass on Windows.
petervdonovan Mar 25, 2023
f25358d
Fix mistakes in previous commits.
petervdonovan Mar 26, 2023
e6ced4e
Try again to pass on Windows.
petervdonovan Mar 26, 2023
3ea3952
Revert more accidental C -> CCpp changes.
petervdonovan Mar 26, 2023
d82edb3
Handle a hierarchical reference.
petervdonovan Mar 27, 2023
48540b3
Minor bugfixes in previous commit.
petervdonovan Mar 27, 2023
f168342
Pass smoke test for reacting to contained bank.
petervdonovan Mar 27, 2023
1647e59
Address failing modal models test.
petervdonovan Mar 27, 2023
99ff22d
Merge branch 'master' into bodyless-reactions
petervdonovan Mar 27, 2023
389392c
Fix duplicate typedefs.
petervdonovan Mar 27, 2023
c5f6190
Address failing TokenContainedPrint.
petervdonovan Mar 27, 2023
1ebb38f
Pass MultiportToReactionNoInlining test.
petervdonovan Mar 27, 2023
c33786c
Address failing benchmark tests.
petervdonovan Mar 27, 2023
c8e4c2f
Update modal models tests.
petervdonovan Mar 27, 2023
7627c4e
Pass BankMultiportToReactionNoInlining.lf.
petervdonovan Mar 27, 2023
2728529
Merge branch 'master' into bodyless-reactions
petervdonovan Mar 30, 2023
83f09b7
Add Javadoc; trivially refactor.
petervdonovan Mar 31, 2023
3e5e959
Update unit-tests.yml and submodule.
petervdonovan Mar 31, 2023
da9c9ea
Update ci.yml.
petervdonovan Mar 31, 2023
a4dd88c
Add stdio.h back into the user-visible namespace.
petervdonovan Mar 31, 2023
8a71df5
Update submodule.
petervdonovan Mar 31, 2023
0bcbf62
Revert moving instant_t typedef
petervdonovan Mar 31, 2023
a30e655
Try to pass unit tests.
petervdonovan Apr 1, 2023
cc423c4
Revert changes in unit tests.
petervdonovan Apr 5, 2023
c1d75e8
Pass unit tests.
petervdonovan Apr 6, 2023
d452c97
Address comments from code review.
petervdonovan Apr 8, 2023
5ce6138
Merge branch 'master' into bodyless-reactions
lhstrh Apr 12, 2023
ec02433
Address CLI test failure.
petervdonovan Apr 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

# Run the unit tests.
unit-tests:
uses: lf-lang/lingua-franca/.github/workflows/unit-tests.yml@master
uses: lf-lang/lingua-franca/.github/workflows/unit-tests.yml@bodyless-reactions
needs: cancel

# Run tests for the standalone compiler.
Expand All @@ -51,6 +51,8 @@ jobs:
uses: lf-lang/benchmarks-lingua-franca/.github/workflows/benchmark-tests.yml@main
with:
target: 'C'
benchmarks-ref: 'c-separate-gen-files'
compiler-ref: bodyless-reactions
needs: cancel

# Run language server tests.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Prepare build environment
uses: ./.github/actions/prepare-build-env
Expand Down
24 changes: 10 additions & 14 deletions org.lflang.tests/resources/org/lflang/tests/cli/issue490.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ lfc: error: Name of main reactor must match the file name (or be omitted).
| ^ Name of main reactor must match the file name (or be omitted).
|
5 | state liss(2, 3);

lfc: error: missing '{=' at '{'
lfc: error: no viable alternative at input '{'
--> %%%PATH.lf%%%:6:22
|
5 | state liss(2, 3);
6 | reaction (startup) {
| ^ missing '{=' at '{'
| ^ no viable alternative at input '{'
|
7 | print(self.liss)

lfc: error: mismatched input '<EOF>' expecting '=}'
--> %%%PATH.lf%%%:9:2
|
8 | }
| >>>>>>>>>>>>>>
9 | }
10 |
| < mismatched input '<EOF>' expecting '=}'
11 |

lfc: error: no viable alternative at input '('
--> %%%PATH.lf%%%:7:5
|
6 | reaction (startup) {
7 | print(self.liss)
| ^^^^^ no viable alternative at input '('
|
8 | }
70 changes: 35 additions & 35 deletions org.lflang.tests/src/org/lflang/tests/TestRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

/**
* A registry to retrieve tests from, organized by target and category.
*
*
* @author Marten Lohstroh
*/
public class TestRegistry {

static class TestMap {
/**
* Registry that maps targets to maps from categories to sets of tests.
* Registry that maps targets to maps from categories to sets of tests.
*/
protected final Map<Target,
Map<TestCategory, Set<LFTest>>> map = new HashMap<>();
Expand All @@ -57,7 +57,7 @@ public TestMap() {
map.put(target, categories);
}
}

/**
* Return a set of tests given a target and test category.
* @param t The target.
Expand All @@ -68,26 +68,26 @@ public Set<LFTest> getTests(Target t, TestCategory c) {
return this.map.get(t).get(c);
}
}

/**
* List of directories that should be skipped when indexing test files. Any
* test file that has a directory in its path that matches an entry in this
* array will not be discovered.
*/
public static final String[] IGNORED_DIRECTORIES = {"failing", "knownfailed", "failed", "fed-gen"};

/**
* Path to the root of the repository.
*/
public static final Path LF_REPO_PATH = Paths.get("").toAbsolutePath();

/**
* Path to the test directory in the repository.
*/
public static final Path LF_TEST_PATH = LF_REPO_PATH.resolve("test");

/**
* Internal data structure that stores registered tests.
* Internal data structure that stores registered tests.
*/
protected static final TestMap registered = new TestMap();

Expand All @@ -96,31 +96,31 @@ public Set<LFTest> getTests(Target t, TestCategory c) {
* source files with no main reactor are indexed here.
*/
protected static final TestMap ignored = new TestMap();

/**
* A map from each test category to a set of tests that is the union of
* all registered tests in that category across all targets.
*/
protected static final Map<TestCategory, Set<LFTest>> allTargets = new HashMap<>();

/**
* Enumeration of test categories, used to map tests to categories. The
* nearest containing directory that matches any of the categories will
* determine the category that the test is mapped to. Matching is case
* insensitive.
*
*
* For example, the following files will all map to THREADED:
* - C/threaded/Foo.lf
* - C/THREADED/Foo.lf
* - C/THREADED/Foo.lf
* - C/Threaded/Foo.lf
* - C/foo/threaded/Bar.lf
* - C/foo/bar/threaded/Threaded.lf
* - C/foo/threaded/Bar.lf
* - C/foo/bar/threaded/Threaded.lf
* - C/federated/threaded/bar.lf
* but the following will not:
* but the following will not:
* - C/Foo.lf (maps to COMMON)
* - C/Threaded.lf (maps to COMMON)
* - C/threaded/federated/foo.lf (maps to FEDERATED)
*
*
* @author Marten Lohstroh
*/
public enum TestCategory {
Expand All @@ -140,7 +140,7 @@ public enum TestCategory {
PROPERTIES(true),
/** Tests concerning modal reactors */
MODAL_MODELS(true),

NO_INLINING(false),
// non-shared tests
DOCKER(true),
DOCKER_FEDERATED(true, "docker" + File.separator + "federated"),
Expand All @@ -155,7 +155,7 @@ public enum TestCategory {
public final boolean isCommon;
public final String path;
public final TestLevel level ;

/**
* Create a new test category.
*/
Expand Down Expand Up @@ -189,14 +189,14 @@ public String getPath() {

/**
* Return a header associated with the category.
*
*
* @return A header to print in the test report.
*/
public String getHeader() {
return TestBase.THICK_LINE + "Category: " + this.name();
}
}

// Static code that performs the file system traversal and discovers
// all .lf files to be included in the registry.
static {
Expand All @@ -220,7 +220,7 @@ public String getHeader() {
} else {
System.out.println("WARNING: No test directory for target " + target + "\n");
}

} catch (IOException e) {
System.err.println(
"ERROR: Caught exception while indexing tests for target " + target);
Expand All @@ -231,18 +231,18 @@ public String getHeader() {
c -> allTargets.get(c).addAll(getRegisteredTests(target, c, false)));
}
}

/**
* Calling this function forces the lazy initialization of the static code
* that indexes all files. It is advisable to do this prior to executing
* other code that prints to standard out so that any error messages
* printed while indexing are printed first.
*/
public static void initialize() {}

/**
* Return the tests that were indexed for a given target and category.
*
*
* @param target The target to get indexed tests for.
* @param category The category of tests to include in the returned tests.
* @param copy Whether to return copies of the indexed tests instead of the indexed tests themselves.
Expand All @@ -260,7 +260,7 @@ public static Set<LFTest> getRegisteredTests(Target target,
return registered.getTests(target, category);
}
}

/**
* Return the test that were found but not indexed because they did not
* have a main reactor.
Expand All @@ -275,11 +275,11 @@ public static String getCoverageReport(Target target, TestCategory category) {
s.append(TestBase.THIN_LINE);
s.append("Ignored: ").append(ignored.size()).append("\n");
s.append(TestBase.THIN_LINE);

for (LFTest test : ignored) {
s.append("No main reactor in: ").append(test).append("\n");
}

Set<LFTest> own = getRegisteredTests(target, category, false);
if (category.isCommon) {
Set<LFTest> all = allTargets.get(category);
Expand All @@ -301,17 +301,17 @@ public static String getCoverageReport(Target target, TestCategory category) {

/**
* FileVisitor implementation that maintains a stack to map found tests to
* the appropriate category and excludes directories that are listed as
* the appropriate category and excludes directories that are listed as
* "ignored" from walks.
*
*
* Specifically, when a directory is encountered that matches a category,
* this category is pushed onto the stack. Similarly, when the DFS leaves
* such a directory, its corresponding category is popped from the stack.
* Any test (*.lf) file that is encountered will be mapped to the category
* that is on top of the stack. Initially, the stack has one element that
* that is on top of the stack. Initially, the stack has one element that
* is TestCategory.COMMON, meaning that test files in the top-level test
* directory for a given target will be mapped to that category.
*
*
* @author Marten Lohstroh
*/
public static class TestDirVisitor extends SimpleFileVisitor<Path> {
Expand All @@ -325,7 +325,7 @@ public static class TestDirVisitor extends SimpleFileVisitor<Path> {
* The target that all encountered tests belong to.
*/
protected Target target;

protected ResourceSet rs;

protected Path srcBasePath;
Expand All @@ -342,7 +342,7 @@ public TestDirVisitor(ResourceSet rs, Target target, Path srcBasePath) {
this.target = target;
this.srcBasePath = srcBasePath;
}

/**
* Push categories onto the stack as appropriate and skip directories
* that should be ignored.
Expand All @@ -363,7 +363,7 @@ public FileVisitResult preVisitDirectory(Path dir,
}
return CONTINUE;
}

/**
* Pop categories from the stack as appropriate.
*/
Expand All @@ -377,7 +377,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
}
return CONTINUE;
}

/**
* Add test files to the registry if they end with ".lf", but only if they have a main reactor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ private List<String> synthesizeExamples(UnionType type, boolean correct) {
*/
private List<String> synthesizeExamples(DictionaryType type, boolean correct) {
List<String> examples = new LinkedList<>();
// Produce a set of singleton dictionaries.
// Produce a set of singleton dictionaries.
// If incorrect examples are wanted, garble the key.
for (DictionaryElement option : type.options) {
synthesizeExamples(option.getType(), correct).forEach(it -> examples.add(
Expand Down Expand Up @@ -1629,7 +1629,7 @@ public void testMainReactorHasHost() throws Exception {
""";
// TODO: Uncomment and fix test
// List<Issue> issues = validator.validate(parseWithoutError(testCase));
// Assertions.assertTrue(issues.size() == 1 &&
// Assertions.assertTrue(issues.size() == 1 &&
// issues.get(0).getMessage().contains("Cannot assign a host to reactor '") &&
// issues.get(0).getMessage().contains("' because it is not federated."));
}
Expand Down Expand Up @@ -1810,7 +1810,7 @@ public void testMissingModeStateResetInstance() throws Exception {
"This reactor contains state variables that are not reset upon mode entry: "
+ "s in R"
+ ".\nThe state variables are neither marked for automatic reset nor have a dedicated reset reaction. "
+ "It is usafe to instatiate this reactor inside a mode entered with reset.");
+ "It is unsafe to instantiate this reactor inside a mode entered with reset.");
}

@Test
Expand Down Expand Up @@ -1841,11 +1841,9 @@ public void testUnspecifiedTransitionType() throws Exception {
}
""";
validator.assertWarning(parseWithoutError(testCase), LfPackage.eINSTANCE.getReaction(), null,
"You should specifiy a transition type! "
"You should specify a transition type! "
+ "Reset and history transitions have different effects on this target mode. "
+ "Currently, a reset type is implicitly assumed.");
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void roundTripTest() {

private void run(Path file) throws Exception {
Model originalModel = LfParsingUtil.parse(file);
System.out.println(file);
assertThat(originalModel.eResource().getErrors(), equalTo(emptyList()));
// TODO: Check that the output is a fixed point
final int smallLineLength = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public MockReportProgress() {

@Override
public void apply(String message, Integer percentage) {
System.out.printf("%s [%d -> %d]%n", message, previousPercentProgress, percentage);
System.out.printf("MockReportProgress: %s [%d -> %d]%n", message, previousPercentProgress, percentage);
if (percentage == null) return;
if (percentage < previousPercentProgress || percentage < 0 || percentage > 100) failed = true;
previousPercentProgress = percentage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private static boolean isExcludedFromCCpp(TestCategory category) {
excluded |= isMac() && (category == TestCategory.DOCKER_FEDERATED || category == TestCategory.DOCKER);
excluded |= category == TestCategory.ZEPHYR;
excluded |= category == TestCategory.ARDUINO;
excluded |= category == TestCategory.NO_INLINING;
return !excluded;
}
}
2 changes: 1 addition & 1 deletion org.lflang/src/lib/py/reactor-c-py
Loading