1 package org.simantics.scl.compiler.elaboration.expressions.block;
3 import org.simantics.scl.compiler.elaboration.contexts.EnvironmentalContext;
4 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
5 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
6 import org.simantics.scl.compiler.elaboration.expressions.EBind;
7 import org.simantics.scl.compiler.elaboration.expressions.ESimpleLet;
8 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
9 import org.simantics.scl.compiler.elaboration.expressions.Expression;
10 import org.simantics.scl.compiler.elaboration.expressions.Variable;
11 import org.simantics.scl.compiler.errors.Locations;
13 public class GuardStatement extends Statement {
14 public Expression value;
16 public GuardStatement(Expression value) {
21 public Expression toExpression(EnvironmentalContext context, boolean monadic, Expression in) {
23 Variable var = new Variable("_");
24 return new EBind(location, new EVariable(location, var), value, in);
27 return new ESimpleLet(location, null, value, in);
31 public void setLocationDeep(long loc) {
32 if(location == Locations.NO_LOCATION) {
34 value.setLocationDeep(loc);
39 public void resolvePattern(TranslationContext context) {
43 public boolean mayBeRecursive() {
48 public Statement replace(ReplaceContext context) {
49 return new GuardStatement(value.replace(context));
53 public void accept(StatementVisitor visitor) {
58 public StatementGroup getStatementGroup() {