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.TIntHashSet;
14 public class ListGuard extends ListQualifier {
15 public Expression condition;
17 public ListGuard(Expression condition) {
18 this.condition = condition;
22 public void checkType(TypingContext context) {
23 condition.checkType(context, Types.BOOLEAN);
27 public void collectVars(TObjectIntHashMap<Variable> allVars,
29 condition.collectVars(allVars, vars);
33 public CompiledQualifier compile(SimplificationContext context) {
34 return new CompiledQualifier(
35 context.guardList(condition.copy()),
40 public void resolve(TranslationContext context) {
41 condition = condition.resolve(context);
45 public void setLocationDeep(long loc) {
46 if(location == Locations.NO_LOCATION) {
48 condition.setLocationDeep(loc);
53 public void accept(ListQualifierVisitor visitor) {
58 public ListQualifier accept(ListQualifierTransformer transformer) {
59 return transformer.transform(this);