]> gerrit.simantics Code Review - simantics/platform.git/blob
aec3d84dc99e0ab6cd593d6556b1f3ffc81a4e81
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions.visitors;
2
3 import org.simantics.scl.compiler.elaboration.expressions.EApply;
4 import org.simantics.scl.compiler.elaboration.expressions.ECHRRuleset;
5 import org.simantics.scl.compiler.elaboration.expressions.ECHRSelect;
6 import org.simantics.scl.compiler.elaboration.expressions.EFieldAccess;
7 import org.simantics.scl.compiler.elaboration.expressions.ELambda;
8 import org.simantics.scl.compiler.elaboration.expressions.ESimpleLambda;
9 import org.simantics.scl.compiler.elaboration.expressions.ETransformation;
10 import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisitor;
11 import org.simantics.scl.compiler.types.Type;
12 import org.simantics.scl.compiler.types.Types;
13
14 import gnu.trove.set.hash.THashSet;
15
16 public class CollectEffectsVisitor extends StandardExpressionVisitor {
17     public final THashSet<Type> effects = new THashSet<Type>();
18     
19     @Override
20     public void visit(EApply expression) {
21         effects.add(expression.effect);
22         super.visit(expression);
23     }
24     
25     @Override
26     public void visit(ECHRRuleset expression) {
27         effects.add(Types.PROC);
28         super.visit(expression);
29     }
30     
31     @Override
32     public void visit(ECHRSelect expression) {
33         effects.add(Types.PROC);
34         super.visit(expression);
35     }
36     
37     @Override
38     public void visit(EFieldAccess expression) {
39         // FIXME
40         effects.add(Types.READ_GRAPH);
41         super.visit(expression);
42     }
43     
44     @Override
45     public void visit(ETransformation expression) {
46         // FIXME
47         effects.add(Types.PROC);
48         super.visit(expression);
49     }
50     
51     @Override
52     public void visit(ELambda expression) {
53     }
54     
55     @Override
56     public void visit(ESimpleLambda expression) {
57     }
58     
59     public Type getCombinedEffect() {
60         return Types.union(effects.toArray(new Type[effects.size()]));
61     }
62 }