1 package org.simantics.scl.compiler.elaboration.expressions.visitors;
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.types.Type;
11 import org.simantics.scl.compiler.types.Types;
13 import gnu.trove.set.hash.THashSet;
15 public class CollectEffectsVisitor extends StandardExpressionVisitor {
16 public final THashSet<Type> effects = new THashSet<Type>();
19 public void visit(EApply expression) {
20 effects.add(expression.effect);
21 super.visit(expression);
25 public void visit(ECHRRuleset expression) {
26 effects.add(Types.PROC);
27 super.visit(expression);
31 public void visit(ECHRSelect expression) {
32 effects.add(Types.PROC);
33 super.visit(expression);
37 public void visit(EFieldAccess expression) {
39 effects.add(Types.READ_GRAPH);
40 super.visit(expression);
44 public void visit(ETransformation expression) {
46 effects.add(Types.PROC);
47 super.visit(expression);
51 public void visit(ELambda expression) {
55 public void visit(ESimpleLambda expression) {
58 public Type getCombinedEffect() {
59 return Types.union(effects.toArray(new Type[effects.size()]));