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