]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/TranslationContext.java
New type class MonadE and corresponding monad syntax with edo keyword
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / contexts / TranslationContext.java
index 0331f9a50b86a7715405afc9bb37da2441d8b5b2..aeeb4cb5525b3be9f02bfb5cfee4e92fc857b8cb 100644 (file)
@@ -75,6 +75,8 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
     TIntArrayList chrConstraintFrames = new TIntArrayList();
     ArrayList<CHRConstraintEntry> chrConstraintEntries = new ArrayList<CHRConstraintEntry>();
     
+    public CHRRuleset currentRuleset;
+    
     static class Entry {
         String name;
         Variable variable;
@@ -157,13 +159,16 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
             return existentialFrames.get(size-1);
     }
     
-    private Expression resolveFieldAccess(Expression base, int pos, String name) {
+    private Expression resolveFieldAccess(long location, Expression base, int pos, String name) {
         while(pos != -1) {
             int p = findSeparator(name, pos+1);
+            int endPos = p==-1 ? name.length() : p;
             FieldAccessor accessor = new IdAccessor(
                     name.charAt(pos),
-                    name.substring(pos+1, p==-1 ? name.length() : p-1));
+                    name.substring(pos+1, endPos));
+            accessor.location = Locations.sublocation(location, pos+1, endPos);
             base = new EFieldAccess(base, accessor);
+            base.location = Locations.sublocation(location, 0, endPos);
             pos = p;
         }
         return base;
@@ -235,7 +240,7 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
         if(begin == 0) {
             Expression result = resolveLocalVariable(location, part);
             if(result != null)
-                return end == -1 ? result : resolveFieldAccess(result, end, name);
+                return end == -1 ? result : resolveFieldAccess(location, result, end, name);
             
             // FIXME.. support for records
             if(localEnvironment != null) {
@@ -266,7 +271,7 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
             if(result == null)
                 result = resolveValue(location, namespace, part);
             if(result != null)
-                return end == -1 ? result : resolveFieldAccess(result, end, name);
+                return end == -1 ? result : resolveFieldAccess(location, result, end, name);
         }
         reportResolveFailure(location, namespace, part);
         return new EError(location);
@@ -509,13 +514,6 @@ public class TranslationContext extends TypeTranslationContext implements Enviro
                 Locations.combine(definitions.get(0).location, definitions.get(definitions.size()-1).location),
                 cases);
     }
-    
-    public SCLValue getBindFunction() {
-        if(bindFunction == null) {
-            bindFunction = getEnvironment().getValue(Names.Prelude_bind);
-        }
-        return bindFunction;
-    }
 
     public SCLRelation resolveRelation(long location, String name) {
         SCLRelation relation = relations.get(name);