]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Assignment.java
7cc70aaa77bed69f6328ce0a5055f884301f201b
[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.internal.elaboration.utils.ExpressionDecorator;
5 import org.simantics.scl.compiler.types.Type;
6
7 public class Assignment {
8     public Expression pattern;
9     public Expression value;
10     
11     public Assignment(Expression pattern, Expression value) {
12         if(Type.NULL_CHECKS) {
13             if(pattern == null)
14                 throw new NullPointerException();
15             if(value == null)
16                 throw new NullPointerException();
17         }
18         this.pattern = pattern;
19         this.value = value;
20     }
21
22     public Assignment replace(ReplaceContext context) {
23         Expression newPattern = pattern.replaceInPattern(context);
24         Expression newValue = value.replace(context);
25         return new Assignment(newPattern, newValue);
26     }
27
28     public void decorate(ExpressionDecorator decorator) {
29         pattern = pattern.decorate(decorator);
30         value = value.decorate(decorator);
31     }
32
33     public void setLocationDeep(long loc) {
34         pattern.setLocationDeep(loc);
35         value.setLocationDeep(loc);
36     }
37
38     public void forVariables(VariableProcedure procedure) {
39         value.forVariables(procedure);
40     }
41 }