From: Hannu Niemistö Date: Thu, 17 Aug 2017 13:37:00 +0000 (+0300) Subject: (refs #7436) Added location information to ECHRRuleset X-Git-Tag: v1.31.0~234 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F867%2F1;p=simantics%2Fplatform.git (refs #7436) Added location information to ECHRRuleset Also small modification to typechecking of ECHRRuleset to get smaller scope for a potential type error. Change-Id: I9edaaa26c5a18c988de3fa89f39290030394972c --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java index ea47c57b2..50f299651 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBlock.java @@ -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); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java index e3fc0a4f2..da37a4a58 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java @@ -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);