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%2FECHRRulesetConstructor.java;h=dbba5a5390d93a99a5a010ea5baad5bc23bcb627;hb=refs%2Fchanges%2F12%2F1712%2F1;hp=e8a5cb81beb4300b29f69a35af5bfc31af83bd90;hpb=bf5f7cda1b9b64484cc6e53499e38d6785744aec;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java index e8a5cb81b..dbba5a539 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java @@ -1,61 +1,41 @@ package org.simantics.scl.compiler.elaboration.expressions; import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; +import org.simantics.scl.compiler.compilation.CompilationContext; import org.simantics.scl.compiler.elaboration.chr.CHRRuleset; import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; import org.simantics.scl.compiler.elaboration.contexts.TypingContext; -import org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; -import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; 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; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - public class ECHRRulesetConstructor extends Expression { - CHRRuleset ruleset; + public CHRRuleset ruleset; public ECHRRulesetConstructor(CHRRuleset ruleset) { this.ruleset = ruleset; } - - @Override - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - ruleset.collectRefs(allRefs, refs); - } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - ruleset.collectVars(allVars, vars); - } - @Override - public void forVariables(VariableProcedure procedure) { - ruleset.forVariables(procedure); - } + @Override protected void updateType() throws MatchException { throw new InternalCompilerError("Type of ECHRRulesetConstructor should be already given."); } + @Override - public IVal toVal(Environment env, CodeWriter w) { + public IVal toVal(CompilationContext context, CodeWriter w) { return ruleset.generateCode(w); } - @Override - public void collectFreeVariables(THashSet vars) { - ruleset.collectFreeVariables(vars); - } + @Override public Expression resolve(TranslationContext context) { context.pushFrame(); context.pushCHRConstraintFrame(); ruleset.resolve(context); - context.popCHRConstraintFrame(ruleset.constraints); + context.popCHRConstraintFrame(ruleset); context.popFrame(); return this; } @@ -67,14 +47,6 @@ public class ECHRRulesetConstructor extends Expression { } } @Override - public Expression decorate(ExpressionDecorator decorator) { - return this; - } - @Override - public void collectEffects(THashSet effects) { - ruleset.collectEffects(effects); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); } @@ -87,8 +59,7 @@ public class ECHRRulesetConstructor extends Expression { @Override public Expression simplify(SimplificationContext context) { - ruleset.simplify(context); - ruleset.compile(context); + ruleset.simplifyAndCompileIfNeeded(context); return this; }