1 package org.simantics.scl.compiler.elaboration.expressions.visitors;
3 import org.simantics.scl.compiler.elaboration.expressions.EConstant;
4 import org.simantics.scl.compiler.elaboration.expressions.ETransformation;
5 import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisitor;
6 import org.simantics.scl.compiler.elaboration.query.QAtom;
7 import org.simantics.scl.compiler.elaboration.relations.CompositeRelation;
8 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
10 import gnu.trove.map.hash.TObjectIntHashMap;
11 import gnu.trove.set.hash.TIntHashSet;
13 public class CollectRefsVisitor extends StandardExpressionVisitor {
14 private final TObjectIntHashMap<Object> allRefs;
15 private final TIntHashSet refs;
17 public CollectRefsVisitor(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
18 this.allRefs = allRefs;
23 public void visit(ETransformation expression) {
25 int ref = allRefs.get(ETransformation.TRANSFORMATION_RULES_TYPECHECKED);
29 super.visit(expression);
33 public void visit(EConstant expression) {
34 int id = allRefs.get(expression.value);
40 public void visit(QAtom query) {
41 collectRelationRefs(query.relation);
45 private void collectRelationRefs(SCLRelation relation) {
46 if(relation instanceof CompositeRelation) {
47 for(SCLRelation subrelation : ((CompositeRelation) relation).getSubrelations())
48 collectRelationRefs(subrelation);
51 int id = allRefs.get(relation);