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