X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FECHRRuleset.java;h=da37a4a58f228b5cd8c15af94c2fa80b709eb2bb;hb=4bb82aede02d798846196cc4f51e09d9f9161fef;hp=d23b2e4cee3b19710a8bf1d855c3144c153fa295;hpb=2f63e7a58e49a233b28c6968b848281060117c43;p=simantics%2Fplatform.git 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 d23b2e4ce..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 @@ -13,43 +13,26 @@ import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - public class ECHRRuleset extends Expression { - CHRRuleset ruleset; - Expression in; + public CHRRuleset ruleset; + public Expression in; public ECHRRuleset(CHRRuleset ruleset, Expression in) { this.ruleset = ruleset; this.in = in; } - - @Override - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - ruleset.collectRefs(allRefs, refs); - in.collectRefs(allRefs, refs); - } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - ruleset.collectVars(allVars, vars); - in.collectVars(allVars, vars); - } + @Override protected void updateType() throws MatchException { setType(in.getType()); } + @Override public IVal toVal(CompilationContext context, CodeWriter w) { ruleset.generateCode(w); return in.toVal(context, w); } - @Override - public void collectFreeVariables(THashSet vars) { - ruleset.collectFreeVariables(vars); - in.collectFreeVariables(vars); - } + @Override public Expression resolve(TranslationContext context) { if(context.currentRuleset != null) { @@ -77,11 +60,7 @@ public class ECHRRuleset extends Expression { in.setLocationDeep(loc); } } - @Override - public void collectEffects(THashSet effects) { - ruleset.collectEffects(effects); - in.collectEffects(effects); - } + @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); @@ -94,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);