]> gerrit.simantics Code Review - simantics/platform.git/blob
e5e8ee9d47cdca494a9224a088519426fe684f81
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions.list;
2
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.errors.Locations;
8 import org.simantics.scl.compiler.types.Types;
9
10 public class ListGuard extends ListQualifier {
11     public Expression condition;
12
13     public ListGuard(Expression condition) {
14         this.condition = condition;
15     }
16
17     @Override
18     public void checkType(TypingContext context) {
19         condition.checkType(context, Types.BOOLEAN);
20     }
21
22     @Override
23     public CompiledQualifier compile(SimplificationContext context) {
24         return new CompiledQualifier(
25                 context.guardList(condition.copy()), 
26                 context.tuple());
27     }
28
29     @Override
30     public void resolve(TranslationContext context) {
31         condition = condition.resolve(context);
32     }
33
34     @Override
35     public void setLocationDeep(long loc) {
36         if(location == Locations.NO_LOCATION) {
37             location = loc;
38             condition.setLocationDeep(loc);
39         }
40     }
41     
42     @Override
43     public void accept(ListQualifierVisitor visitor) {
44         visitor.visit(this);
45     }
46     
47     @Override
48     public ListQualifier accept(ListQualifierTransformer transformer) {
49         return transformer.transform(this);
50     }
51 }