1 package org.simantics.scl.compiler.elaboration.expressions.list;
\r
3 import gnu.trove.map.hash.TObjectIntHashMap;
\r
4 import gnu.trove.set.hash.THashSet;
\r
5 import gnu.trove.set.hash.TIntHashSet;
\r
7 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
\r
8 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
\r
9 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
\r
10 import org.simantics.scl.compiler.elaboration.expressions.Expression;
\r
11 import org.simantics.scl.compiler.elaboration.expressions.Variable;
\r
12 import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
\r
13 import org.simantics.scl.compiler.errors.Locations;
\r
14 import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
\r
15 import org.simantics.scl.compiler.types.Type;
\r
16 import org.simantics.scl.compiler.types.Types;
\r
18 public class ListGuard extends ListQualifier {
\r
19 public Expression condition;
\r
21 public ListGuard(Expression condition) {
\r
22 this.condition = condition;
\r
26 public void checkType(TypingContext context) {
\r
27 condition.checkType(context, Types.BOOLEAN);
\r
31 public void collectRefs(TObjectIntHashMap<Object> allRefs,
\r
33 condition.collectRefs(allRefs, refs);
\r
37 public void collectVars(TObjectIntHashMap<Variable> allVars,
\r
39 condition.collectVars(allVars, vars);
\r
43 public void collectFreeVariables(THashSet<Variable> vars) {
\r
44 condition.collectFreeVariables(vars);
\r
48 public CompiledQualifier compile(SimplificationContext context) {
\r
49 return new CompiledQualifier(
\r
50 context.guardList(condition.copy()),
\r
55 public void resolve(TranslationContext context) {
\r
56 condition = condition.resolve(context);
\r
60 public void decorate(ExpressionDecorator decorator) {
\r
61 condition = condition.decorate(decorator);
\r
65 public void collectEffects(THashSet<Type> effects) {
\r
66 condition.collectEffects(effects);
\r
70 public void setLocationDeep(long loc) {
\r
71 if(location == Locations.NO_LOCATION) {
\r
73 condition.setLocationDeep(loc);
\r
78 public void accept(ListQualifierVisitor visitor) {
\r
79 visitor.visit(this);
\r
83 public void forVariables(VariableProcedure procedure) {
\r
84 condition.forVariables(procedure);
\r
88 public ListQualifier accept(ListQualifierTransformer transformer) {
\r
89 return transformer.transform(this);
\r