]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/translation/ChildGraphTranslator.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / translation / ChildGraphTranslator.java
1 package org.simantics.graph.compiler.internal.translation;
2
3 import gnu.trove.list.array.TIntArrayList;
4
5 import org.antlr.runtime.tree.Tree;
6 import org.simantics.graph.store.GraphStore;
7
8 public class ChildGraphTranslator extends GraphTranslator {
9
10         TIntArrayList correspondences = new TIntArrayList();    
11         GraphTranslator parent;
12                 
13         public ChildGraphTranslator(GraphTranslator parent, GraphStore store) {
14                 super(parent.paths, parent.problems, store);
15                 this.parent = parent;
16         }
17
18         @Override
19         public int getVariable(Tree place, String text) {
20                 if(variables.containsKey(text))
21                         return variables.get(text);
22                 else {
23                         correspondences.add(parent.getVariable(place, text));                   
24                         int id = identities.newResource();
25                         correspondences.add(id);
26                         variables.put(text, id);                
27                         locate(id, place);
28                         return id;
29                 }
30         }       
31         
32         public int[] getCorrespondences() {
33                 return correspondences.toArray();
34         }
35 }