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.Expression;
\r
8 import org.simantics.scl.compiler.errors.Locations;
\r
10 public class BindStatement extends Statement {
\r
11 public Expression pattern;
\r
12 public Expression value;
\r
14 public BindStatement(Expression pattern, Expression value) {
\r
15 this.pattern = pattern;
\r
20 public Expression toExpression(EnvironmentalContext context, boolean monadic, Expression in) {
\r
22 // context.getErrorLog().log(location, "Bind statements are allowed only in mdo-blocks.");
\r
23 return new EBind(location, pattern, value, in);
\r
27 public void setLocationDeep(long loc) {
\r
28 if(location == Locations.NO_LOCATION) {
\r
30 pattern.setLocationDeep(loc);
\r
31 value.setLocationDeep(loc);
\r
36 public void resolvePattern(TranslationContext context) {
\r
37 pattern = pattern.resolveAsPattern(context);
\r
41 public boolean mayBeRecursive() {
\r
46 public Statement replace(ReplaceContext context) {
\r
47 return new BindStatement(pattern.replaceInPattern(context), value.replace(context));
\r
51 public void accept(StatementVisitor visitor) {
\r
52 visitor.visit(this);
\r