]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpression.java
fa67162d5620df596630bde077ae49bc031ea751
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / GuardedExpression.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.errors.Locations;
5 import org.simantics.scl.compiler.internal.parsing.Symbol;
6
7 public class GuardedExpression extends Symbol {
8     public Expression[] guards;
9     public Expression value;
10     
11     public GuardedExpression(Expression[] guards, Expression value) {
12         this.guards = guards;
13         this.value = value;
14     }
15
16     public GuardedExpression replace(ReplaceContext context) {
17         return new GuardedExpression(
18                 Expression.replace(context, guards), 
19                 value.replace(context));
20     }
21
22     public void setLocationDeep(long loc) {
23         if(location == Locations.NO_LOCATION) {
24             location = loc;
25             for(Expression guard : guards)
26                 guard.setLocationDeep(loc);
27             value.setLocationDeep(loc);
28         }
29     }
30
31     public void forVariables(VariableProcedure procedure) {
32         for(Expression guard : guards)
33             guard.forVariables(procedure);
34         value.forVariables(procedure);
35     }
36 }