Skip to content

Commit

Permalink
Do not cache the targetConfig.
Browse files Browse the repository at this point in the history
This matters in case of AST transformations. The test framework uses an
AST transformation to set tests as CCpp, and it needs the context set in
order to do the AST transformation. But the context would need to be
computed after the AST transformation in order for it to get the right
target. This is the least invasive way to sidestep this dependency
cycle. I acknowledge that there may be performance consequences, but I'm
not concerned about performance consequences until they are shown to be
of practical significance. The fact is that if we do not cache, we do
not have two inconsistent views of the targetConfig in the presence of
AST transformations that touch the targetConfig.
  • Loading branch information
petervdonovan committed Jan 15, 2023
1 parent 9418c60 commit e5d8558
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions org.lflang.tests/src/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ private void validateAndRun(Set<LFTest> tests, Configurator configurator, TestLe
} catch (TestError e) {
test.handleTestError(e);
} catch (Throwable e) {
e.printStackTrace();
test.handleTestError(new TestError(
"Unknown exception during test execution", Result.TEST_EXCEPTION, e));
} finally {
Expand Down
12 changes: 3 additions & 9 deletions org.lflang/src/org/lflang/generator/MainContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class MainContext implements LFGeneratorContext {
/** Whether the requested build is required to be complete. */
private final Mode mode;

private final TargetConfig targetConfig;

/** The result of the code generation process. */
private GeneratorResult result = null;
private final Properties args;
Expand Down Expand Up @@ -95,12 +93,6 @@ public MainContext(
}

this.errorReporter = constructErrorReporter.apply(this.fileConfig);

this.targetConfig = GeneratorUtils.getTargetConfig(
args, GeneratorUtils.findTarget(fileConfig.resource), errorReporter
);


}

@Override
Expand Down Expand Up @@ -143,7 +135,9 @@ public FileConfig getFileConfig() {

@Override
public TargetConfig getTargetConfig() {
return this.targetConfig;
return GeneratorUtils.getTargetConfig(
args, GeneratorUtils.findTarget(fileConfig.resource), errorReporter
);
}

@Override
Expand Down

0 comments on commit e5d8558

Please sign in to comment.