1 package org.simantics.scl.compiler.elaboration.expressions.list;
3 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
4 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
5 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
6 import org.simantics.scl.compiler.elaboration.expressions.Expression;
7 import org.simantics.scl.compiler.elaboration.expressions.Variable;
8 import org.simantics.scl.compiler.errors.Locations;
9 import org.simantics.scl.compiler.types.Types;
11 import gnu.trove.map.hash.TObjectIntHashMap;
12 import gnu.trove.set.hash.THashSet;
13 import gnu.trove.set.hash.TIntHashSet;
15 public class ListGuard extends ListQualifier {
16 public Expression condition;
18 public ListGuard(Expression condition) {
19 this.condition = condition;
23 public void checkType(TypingContext context) {
24 condition.checkType(context, Types.BOOLEAN);
28 public void collectVars(TObjectIntHashMap<Variable> allVars,
30 condition.collectVars(allVars, vars);
34 public void collectFreeVariables(THashSet<Variable> vars) {
35 condition.collectFreeVariables(vars);
39 public CompiledQualifier compile(SimplificationContext context) {
40 return new CompiledQualifier(
41 context.guardList(condition.copy()),
46 public void resolve(TranslationContext context) {
47 condition = condition.resolve(context);
51 public void setLocationDeep(long loc) {
52 if(location == Locations.NO_LOCATION) {
54 condition.setLocationDeep(loc);
59 public void accept(ListQualifierVisitor visitor) {
64 public ListQualifier accept(ListQualifierTransformer transformer) {
65 return transformer.transform(this);