]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/TranslationContext.java
(refs #7250) Support for record syntax for CHR relations
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / contexts / TranslationContext.java
index 75090ae3833f9f07c2643874bf95fdc9c6bd41c2..0331f9a50b86a7715405afc9bb37da2441d8b5b2 100644 (file)
@@ -46,7 +46,15 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
     public static class ExistentialFrame {
         THashSet<String> variables = new THashSet<String>(4);
         ArrayList<Variable> blanks = new ArrayList<Variable>(2); 
-        boolean disallowNewExistentials;
+        public boolean disallowNewExistentials;
+        
+        public EVariable createBlank(long location) {
+            Variable variable = new Variable("_");
+            blanks.add(variable);
+            EVariable result = new EVariable(variable);
+            result.location = location;
+            return result;
+        }
     }
     
     THashMap<String, Variable> variables = new THashMap<String, Variable>();
@@ -128,14 +136,12 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
         }
         case '_': {
             if(name.length()==1) {
-                variable = new Variable("_");
                 ExistentialFrame existentialFrame = getCurrentExistentialFrame();
                 if(existentialFrame == null || existentialFrame.disallowNewExistentials) {
                     errorLog.log(location, "Blank variables can be used only in queries.");
                     return new EError(location);
                 }
-                existentialFrame.blanks.add(variable);
-                return new EVariable(variable);
+                return existentialFrame.createBlank(location);
             }
             break;
         }
@@ -143,7 +149,7 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
         return null;
     }
     
-    private ExistentialFrame getCurrentExistentialFrame() {
+    public ExistentialFrame getCurrentExistentialFrame() {
         int size = existentialFrames.size(); 
         if(size == 0)
             return null;