]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/types/effects/EffectIdMap.java
New SCL syntax <<effects>>
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / types / effects / EffectIdMap.java
index 4168fff931241574484b794ce94e40fe4de043b0..8ba0e6783a149aecd08fe9281063bf6d7b9b9cc3 100644 (file)
@@ -17,19 +17,17 @@ public class EffectIdMap {
     public static final int MAX = 0xffffffff;
     private static final int FIRST_FREE_EFFECT_ID = 16;
     
-    private static ArrayList<TCon> effectCons = new ArrayList<TCon>(); 
-    private static TObjectIntHashMap<TCon> effectCodes = new TObjectIntHashMap<TCon>();
+    private static ArrayList<TCon> EFFECT_CONS = new ArrayList<TCon>(); 
+    private static TObjectIntHashMap<TCon> EFFECT_CODES = new TObjectIntHashMap<TCon>();
     
-    private static void add(String module, String name, int code) {
-        TCon con = Types.con(module, name);
-        effectCodes.put(con, code);
-        effectCons.add(con);
+    private static void add(TCon con, int code) {
+        EFFECT_CODES.put(con, code);
+        EFFECT_CONS.add(con);
     }
     
     static {
-        add("Simantics/DB", "WriteGraph", 12);
-        add("Simantics/DB", "ReadGraph",  4);
-        add(Types.BUILTIN, "Proc",       1);
+        add(Types.WRITE_GRAPH, 0b11);
+        add(Types.READ_GRAPH,  0b01);
     }
     
     private ArrayList<Type> localCons = new ArrayList<Type>(); 
@@ -44,8 +42,8 @@ public class EffectIdMap {
                 id |= toId(e, metaVars);
             return id;
         }
-        else if(effectCodes.contains(type)) {
-            return effectCodes.get(type);
+        else if(EFFECT_CODES.contains(type)) {
+            return EFFECT_CODES.get(type);
         }
         else if(type instanceof TMetaVar) {
             metaVars.add((TMetaVar)type);
@@ -67,8 +65,8 @@ public class EffectIdMap {
         if(id == 0)
             return Types.NO_EFFECTS;
         ArrayList<Type> components = new ArrayList<Type>();
-        for(TCon con : effectCons) {
-            int conId = effectCodes.get(con);
+        for(TCon con : EFFECT_CONS) {
+            int conId = EFFECT_CODES.get(con);
             if((id&conId) == conId) {
                 components.add(con);
                 id ^= conId;