Skip to content

Commit

Permalink
Address immutability exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lhstrh committed Oct 15, 2023
1 parent f1f1735 commit f02ff3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 53 deletions.
17 changes: 1 addition & 16 deletions cli/lfc/src/test/kotlin/org/lflang/cli/LfcIssueReportingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,7 @@ class SpyPrintStream {


class LfcIssueReportingTest {
/*
Note: when executing these tests in Intellij, I get the following error:
java.lang.SecurityException: class "org.eclipse.core.runtime.IPath"'s
signer information does not match signer information of other classes
in the same package
To fix this:
- Go into File > Project Structure (CTRL+MAJ+S)
- Open the "Modules" tab
- Select the module org.lflang/lfc/test in the tree view
- Open the "Dependencies" tab
- Remove the dependency org.eclipse.platform:org.eclipse.equinox.common (it will have Provided scope)
*/



@Test
fun testSimpleWarning() {
doTest(fileBaseName = "simpleWarning")
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/java/org/lflang/ast/ASTUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,12 @@ public static ReactorInstance createMainReactorInstance(
if (breadth == 0) {
messageReporter.nowhere().warning("The program has no reactions");
} else {
// FIXME: not marking the property as set!
targetConfig
.get(new CompileDefinitionsProperty())
.put("LF_REACTION_GRAPH_BREADTH", String.valueOf(reactionInstanceGraph.getBreadth()));
new CompileDefinitionsProperty()
.update(
targetConfig,
Map.of(
"LF_REACTION_GRAPH_BREADTH",
String.valueOf(reactionInstanceGraph.getBreadth())));
}
return main;
}
Expand Down
36 changes: 12 additions & 24 deletions core/src/main/java/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -1976,23 +1978,18 @@ protected DockerGenerator getDockerGenerator(LFGeneratorContext context) {
// Perform set up that does not generate code
protected void setUpGeneralParameters() {
accommodatePhysicalActionsIfPresent();
targetConfig
.get(new CompileDefinitionsProperty())
.put(
"LOG_LEVEL",
String.valueOf(
targetConfig
.get(new LoggingProperty())
.ordinal())); // FIXME: put without marking as set
new CompileDefinitionsProperty()
.update(
targetConfig,
Map.of("LOG_LEVEL", String.valueOf(targetConfig.get(new LoggingProperty()).ordinal())));

targetConfig.compileAdditionalSources.addAll(CCoreFilesUtils.getCTargetSrc());
// Create the main reactor instance if there is a main reactor.
this.main =
ASTUtils.createMainReactorInstance(mainDef, reactors, messageReporter, targetConfig);
if (hasModalReactors) {
// So that each separate compile knows about modal reactors, do this:
targetConfig
.get(new CompileDefinitionsProperty())
.put("MODAL_REACTORS", "TRUE"); // FIXME: put without marking as set
new CompileDefinitionsProperty().update(targetConfig, Map.of("MODAL_REACTORS", "TRUE"));
}
final var platformOptions = targetConfig.get(new PlatformProperty());
if (targetConfig.get(new ThreadingProperty())
Expand Down Expand Up @@ -2037,19 +2034,10 @@ protected void setUpGeneralParameters() {
if (targetConfig.get(new ThreadingProperty())) { // FIXME: This logic is duplicated in CMake
pickScheduler();
// FIXME: this and pickScheduler should be combined.
targetConfig
.get(new CompileDefinitionsProperty())
.put(
"SCHEDULER",
targetConfig
.get(new SchedulerProperty())
.name()); // FIXME: put without marking as set
targetConfig
.get(new CompileDefinitionsProperty())
.put(
"NUMBER_OF_WORKERS",
String.valueOf(
targetConfig.get(new WorkersProperty()))); // FIXME: put without marking as set
var map = new HashMap<String, String>();
map.put("SCHEDULER", targetConfig.get(new SchedulerProperty()).name());
map.put("NUMBER_OF_WORKERS", String.valueOf(targetConfig.get(new WorkersProperty())));
new CompileDefinitionsProperty().update(targetConfig, map);
}
pickCompilePlatform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.lflang.util.StringUtil.addDoubleQuotes;

import java.nio.file.Path;
import java.util.HashMap;
import org.lflang.generator.CodeBuilder;
import org.lflang.target.TargetConfig;
import org.lflang.target.property.CompileDefinitionsProperty;
Expand Down Expand Up @@ -72,29 +73,28 @@ public static String generateDefineDirectives(TargetConfig targetConfig, Path sr
// TODO: Get rid of all of these
code.pr("#define LOG_LEVEL " + logLevel);
code.pr("#define TARGET_FILES_DIRECTORY " + addDoubleQuotes(srcGenPath.toString()));

final var definitions = new HashMap<String, String>();
if (tracing.isEnabled()) {
targetConfig
.get(new CompileDefinitionsProperty())
.put("LF_TRACE", tracing.traceFileName); // FIXME: put without marking as set
definitions.put("LF_TRACE", tracing.traceFileName);
}
// if (clockSyncIsOn) {
// code.pr(generateClockSyncDefineDirective(
// targetConfig.clockSync,
// targetConfig.clockSyncOptions
// ));
// }
final var defs = targetConfig.get(new CompileDefinitionsProperty());

if (targetConfig.get(new ThreadingProperty())) {
defs.put("LF_THREADED", "1");
definitions.put("LF_THREADED", "1");
} else {
defs.put("LF_UNTHREADED", "1");
definitions.put("LF_UNTHREADED", "1");
}
if (targetConfig.get(new ThreadingProperty())) {
defs.put("LF_THREADED", "1");
definitions.put("LF_THREADED", "1");
} else {
defs.put("LF_UNTHREADED", "1");
definitions.put("LF_UNTHREADED", "1");
}
new CompileDefinitionsProperty().update(targetConfig, definitions);
code.newLine();
return code.toString();
}
Expand Down

0 comments on commit f02ff3f

Please sign in to comment.