1 package org.simantics.scl.compiler.elaboration.expressions;
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;
8 public class GuardedExpression extends Symbol {
9 public Expression[] guards;
10 public Expression value;
12 public GuardedExpression(Expression[] guards, Expression value) {
17 public GuardedExpression replace(ReplaceContext context) {
18 return new GuardedExpression(
19 Expression.replace(context, guards),
20 value.replace(context));
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);
29 public void setLocationDeep(long loc) {
30 if(location == Locations.NO_LOCATION) {
32 for(Expression guard : guards)
33 guard.setLocationDeep(loc);
34 value.setLocationDeep(loc);
38 public void forVariables(VariableProcedure procedure) {
39 for(Expression guard : guards)
40 guard.forVariables(procedure);
41 value.forVariables(procedure);