]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7436) Added location information to ECHRRuleset 67/867/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 17 Aug 2017 13:37:00 +0000 (16:37 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Thu, 17 Aug 2017 13:37:00 +0000 (16:37 +0300)
Also small modification to typechecking of ECHRRuleset to get smaller
scope for a potential type error.

Change-Id: I9edaaa26c5a18c988de3fa89f39290030394972c

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java

index ea47c57b23a5cb90fe33be40fd626590ee910261..50f29965130ddf38abfc888ef8cd3099cde29421 100644 (file)
@@ -76,10 +76,14 @@ public class EBlock extends ASTExpression {
                 case Rule:
                     in = extractRules(i, endId, in);
                     break;
-                case CHR:
-                    in = new ECHRRuleset(extractCHRRules(context, i, endId), in);
+                case CHR: {
+                    CHRRuleset ruleset = extractCHRRules(context, i, endId);
+                    long location = Locations.combine(ruleset.location, in.location);
+                    in = new ECHRRuleset(ruleset, in);
+                    in.location = location;
                     break;
                 }
+                }
             }
         }
         return in.resolve(context);
index e3fc0a4f2c5a56279d2580981b02a924b01ddcaf..da37a4a58f228b5cd8c15af94c2fa80b709eb2bb 100644 (file)
@@ -10,6 +10,7 @@ import org.simantics.scl.compiler.internal.codegen.references.IVal;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.internal.interpreted.IExpression;
 import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
+import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.exceptions.MatchException;
 
 public class ECHRRuleset extends Expression {
@@ -72,6 +73,13 @@ public class ECHRRuleset extends Expression {
         return this;
     }
     
+    @Override
+    public Expression checkBasicType(TypingContext context, Type requiredType) {
+        ruleset.checkType(context);
+        in = in.checkType(context, requiredType);
+        return this;
+    }
+    
     @Override
     public Expression simplify(SimplificationContext context) {
         ruleset.simplify(context);