]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Assignment.java
04b70deb0ac47042e38732a7e831afd16a418555
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / Assignment.java
1 package org.simantics.scl.compiler.elaboration.expressions;
2
3 import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext;
4 import org.simantics.scl.compiler.types.Type;
5
6 public class Assignment {
7     public Expression pattern;
8     public Expression value;
9     
10     public Assignment(Expression pattern, Expression value) {
11         if(Type.NULL_CHECKS) {
12             if(pattern == null)
13                 throw new NullPointerException();
14             if(value == null)
15                 throw new NullPointerException();
16         }
17         this.pattern = pattern;
18         this.value = value;
19     }
20
21     public Assignment replace(ReplaceContext context) {
22         Expression newPattern = pattern.replaceInPattern(context);
23         Expression newValue = value.replace(context);
24         return new Assignment(newPattern, newValue);
25     }
26
27     public void setLocationDeep(long loc) {
28         pattern.setLocationDeep(loc);
29         value.setLocationDeep(loc);
30     }
31
32     public void forVariables(VariableProcedure procedure) {
33         value.forVariables(procedure);
34     }
35 }