]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java
Refactoring CHR handling code
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / ECHRRuleset.java
index e3fc0a4f2c5a56279d2580981b02a924b01ddcaf..54a3e6bba3a57a35eb73f46a885d429b295c6725 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 {
@@ -44,7 +45,7 @@ public class ECHRRuleset extends Expression {
         context.pushCHRConstraintFrame();
         ruleset.resolve(context);
         in = in.resolve(context);
-        context.popCHRConstraintFrame(ruleset.constraints);
+        context.popCHRConstraintFrame(ruleset);
         context.popFrame();
         
         context.currentRuleset = null;
@@ -72,10 +73,16 @@ 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);
-        ruleset.compile(context);
+        ruleset.simplifyAndCompileIfNeeded(context);
         in = in.simplify(context);
         return this;
     }