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
22 Variable var = new Variable("_");
\r
24 return new EBind(location, new EVariable(location, var), value, in);
\r
26 return new ESimpleLet(location, var, value, in);
\r
30 public void setLocationDeep(long loc) {
\r
31 if(location == Locations.NO_LOCATION) {
\r
33 value.setLocationDeep(loc);
\r
38 public void resolvePattern(TranslationContext context) {
\r
42 public boolean mayBeRecursive() {
\r
47 public Statement replace(ReplaceContext context) {
\r
48 return new GuardStatement(value.replace(context));
\r
52 public void accept(StatementVisitor visitor) {
\r
53 visitor.visit(this);
\r