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