]> gerrit.simantics Code Review - simantics/platform.git/blob
9791b068a5cc4791154da76a6c726f574e2627d1
[simantics/platform.git] /
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.elaboration.utils.ExpressionDecorator;
6 import org.simantics.scl.compiler.internal.parsing.Symbol;
7
8 public class GuardedExpression extends Symbol {
9     public Expression[] guards;
10     public Expression value;
11     
12     public GuardedExpression(Expression[] guards, Expression value) {
13         this.guards = guards;
14         this.value = value;
15     }
16
17     public GuardedExpression replace(ReplaceContext context) {
18         return new GuardedExpression(
19                 Expression.replace(context, guards), 
20                 value.replace(context));
21     }
22
23     public void decorate(ExpressionDecorator decorator) {
24         for(int i=0;i<guards.length;++i)
25             guards[i] = guards[i].decorate(decorator);
26         value = value.decorate(decorator);
27     }
28
29     public void setLocationDeep(long loc) {
30         if(location == Locations.NO_LOCATION) {
31             location = loc;
32             for(Expression guard : guards)
33                 guard.setLocationDeep(loc);
34             value.setLocationDeep(loc);
35         }
36     }
37
38     public void forVariables(VariableProcedure procedure) {
39         for(Expression guard : guards)
40             guard.forVariables(procedure);
41         value.forVariables(procedure);
42     }
43 }