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.elaboration.expressions.StandardExpressionVisitor;
11 import org.simantics.scl.compiler.types.Type;
12 import org.simantics.scl.compiler.types.Types;
14 import gnu.trove.set.hash.THashSet;
16 public class CollectEffectsVisitor extends StandardExpressionVisitor {
17 public final THashSet<Type> effects = new THashSet<Type>();
20 public void visit(EApply expression) {
21 effects.add(expression.effect);
22 super.visit(expression);
26 public void visit(ECHRRuleset expression) {
27 effects.add(Types.PROC);
28 super.visit(expression);
32 public void visit(ECHRSelect expression) {
33 effects.add(Types.PROC);
34 super.visit(expression);
38 public void visit(EFieldAccess expression) {
40 effects.add(Types.READ_GRAPH);
41 super.visit(expression);
45 public void visit(ETransformation expression) {
47 effects.add(Types.PROC);
48 super.visit(expression);
52 public void visit(ELambda expression) {
56 public void visit(ESimpleLambda expression) {
59 public Type getCombinedEffect() {
60 return Types.union(effects.toArray(new Type[effects.size()]));