Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions core/src/main/java/org/lflang/target/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ public boolean supportsFederated() {
};
}

/** Return true if the target supports decentralized coordination. */
public boolean supportsDecentralizedCoordination() {
return switch (this) {
case C, CCPP, Python, Polyglot -> true;
default -> false;
};
}

/** Return true if the target supports reactor inheritance (extends keyword). */
public boolean supportsInheritance() {
return switch (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.lflang.MessageReporter;
import org.lflang.ast.ASTUtils;
import org.lflang.lf.Element;
import org.lflang.lf.LfPackage.Literals;
import org.lflang.target.TargetConfig;
import org.lflang.target.property.type.CoordinationModeType;
import org.lflang.target.property.type.CoordinationModeType.CoordinationMode;

Expand Down Expand Up @@ -35,6 +37,19 @@ protected CoordinationMode fromString(String string, MessageReporter reporter) {
return ((CoordinationModeType) this.type).forName(string);
}

@Override
public void validate(TargetConfig config, MessageReporter reporter) {
if (config.get(this) == CoordinationMode.DECENTRALIZED
&& !config.target.supportsDecentralizedCoordination()) {
reporter
.at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE)
.error(
"The "
+ config.target.getDisplayName()
+ " target does not support decentralized coordination.");
}
}

@Override
public Element toAstElement(CoordinationMode value) {
return ASTUtils.toElement(value.toString());
Expand Down
4 changes: 1 addition & 3 deletions core/src/main/resources/lib/ts/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
allowBuilds:
'@lf-lang/reactor-ts': true
'microtime': true
dangerouslyAllowAllBuilds: true
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.lflang.target.property.type.TargetPropertyType;
import org.lflang.target.property.type.UnionType;
import org.lflang.tests.LFInjectorProvider;
import org.lflang.tests.TestBase;
import org.lflang.util.StringUtil;

/**
Expand Down Expand Up @@ -1091,6 +1092,21 @@ public void testFederationSupport() throws Exception {
}
}

@Test
public void testDecentralizedCoordinationNotSupportedForTypeScript() throws Exception {
validator.assertError(
parseWithoutError(
"""
target TypeScript {
coordination: decentralized
}
main reactor {}
"""),
LfPackage.eINSTANCE.getKeyValuePair(),
null,
TestBase.Message.NO_DECENTRALIZED_COORDINATION_SUPPORT);
}

/** Tests for state and parameter declarations, including native lists. */
@Test
public void stateAndParameterDeclarationsInC() throws Exception {
Expand Down
2 changes: 2 additions & 0 deletions core/src/testFixtures/java/org/lflang/tests/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public static class Message {
"Target does not support single-threaded execution.";
public static final String NO_FEDERATION_SUPPORT =
"Target does not support federated execution.";
public static final String NO_DECENTRALIZED_COORDINATION_SUPPORT =
"The TypeScript target does not support decentralized coordination.";
public static final String NO_ENCLAVE_SUPPORT = "Targeet does not support the enclave feature.";
public static final String NO_DOCKER_SUPPORT = "Target does not support the 'docker' property.";
public static final String NO_DOCKER_TEST_SUPPORT = "Docker tests are only supported on Linux.";
Expand Down
Loading