]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/interpreted/ILet.java
Showing compilation warnings in SCL issue view and editors
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / interpreted / ILet.java
1 package org.simantics.scl.compiler.internal.interpreted;
2
3
4 public class ILet implements IExpression {
5     private final int variableId;
6     private final IExpression value;
7     private final IExpression in;
8
9     public ILet(int variableId, IExpression value, IExpression in) {
10         this.variableId = variableId;
11         this.value = value;
12         this.in = in;
13     }
14
15     @Override
16     public Object execute(Object[] variableBindings) {
17         variableBindings[variableId] = value.execute(variableBindings);
18         try {
19             return in.execute(variableBindings);
20         } finally {
21             variableBindings[variableId] = null;
22         }
23     }
24     
25     @Override
26     public String toString() {
27         StringBuilder b = new StringBuilder();
28         b.append("(let v");
29         b.append(variableId);
30         b.append(" = ");
31         b.append(value);
32         b.append(" in ");
33         b.append(in);
34         b.append(')');
35         return b.toString();
36     }
37 }