|
| 1 | +package org.lflang.target.property; |
| 2 | + |
| 3 | +import org.lflang.MessageReporter; |
| 4 | +import org.lflang.ast.ASTUtils; |
| 5 | +import org.lflang.lf.Action; |
| 6 | +import org.lflang.lf.ActionOrigin; |
| 7 | +import org.lflang.lf.LfPackage.Literals; |
| 8 | +import org.lflang.lf.Reactor; |
| 9 | +import org.lflang.target.Target; |
| 10 | +import org.lflang.target.TargetConfig; |
| 11 | + |
| 12 | +/** |
| 13 | + * If true, configure the execution environment such that it does not wait for physical time to |
| 14 | + * match logical time. The default is false. |
| 15 | + */ |
| 16 | +public final class FastProperty extends BooleanProperty { |
| 17 | + |
| 18 | + /** Singleton target property instance. */ |
| 19 | + public static final FastProperty INSTANCE = new FastProperty(); |
| 20 | + |
| 21 | + private FastProperty() { |
| 22 | + super(); |
| 23 | + } |
| 24 | + |
| 25 | + @Override |
| 26 | + public String name() { |
| 27 | + return "fast"; |
| 28 | + } |
| 29 | + |
| 30 | + @Override |
| 31 | + public void validate(TargetConfig config, MessageReporter reporter) { |
| 32 | + var pair = config.lookup(this); |
| 33 | + if (config.isSet(this) && config.isFederated()) { |
| 34 | + reporter |
| 35 | + .at(pair, Literals.KEY_VALUE_PAIR__NAME) |
| 36 | + .error("The fast target property is incompatible with federated programs."); |
| 37 | + } |
| 38 | + |
| 39 | +// if (config.target != Target.CPP) { |
| 40 | + // Check for physical actions |
| 41 | + for (Reactor reactor : ASTUtils.getAllReactors(config.getMainResource())) { |
| 42 | + // Check to see if the program has a physical action in a reactor |
| 43 | + for (Action action : reactor.getActions()) { |
| 44 | + if (action.getOrigin().equals(ActionOrigin.PHYSICAL)) { |
| 45 | + reporter |
| 46 | + .at(pair, Literals.KEY_VALUE_PAIR__NAME) |
| 47 | + .error( |
| 48 | + String.format( |
| 49 | + "In the %s target, the fast target property is incompatible with physical" |
| 50 | + + " actions.", |
| 51 | + config.target.toString())); |
| 52 | + break; |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | +// } |
| 57 | + } |
| 58 | +} |
0 commit comments