X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fchr%2FCHRRuleset.java;h=55bbcfe34f9c245968083ab39e374b9814fc8908;hp=13eb8491b529bdeb2943d6b15eb996195d4014ff;hb=3e457239db8dd214a3a10c74c2ecefa0f0f8dd1a;hpb=1ec0193a5a5b8f368b03adb24acd762838ddf8ea diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java index 13eb8491b..55bbcfe34 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java @@ -23,7 +23,6 @@ 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.elaboration.expressions.Variable; -import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure; import org.simantics.scl.compiler.elaboration.expressions.block.IncludeStatement; import org.simantics.scl.compiler.environment.AmbiguousNameException; import org.simantics.scl.compiler.errors.Locations; @@ -43,7 +42,6 @@ import org.simantics.scl.compiler.types.Types; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.TIntHashSet; public class CHRRuleset extends Symbol { @@ -123,13 +121,6 @@ public class CHRRuleset extends Symbol { }*/ } - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - for(IncludeStatement include : includes) - include.value.collectRefs(allRefs, refs); - for(CHRRule rule : rules) - rule.collectRefs(allRefs, refs); - } - public void checkType(TypingContext context) { for(IncludeStatement include : includes) include.value = include.value.checkType(context, include.ruleset.runtimeRulesetType); @@ -144,20 +135,6 @@ public class CHRRuleset extends Symbol { rule.collectVars(allVars, vars); } - public void forVariables(VariableProcedure procedure) { - for(IncludeStatement include : includes) - include.value.forVariables(procedure); - for(CHRRule rule : rules) - rule.forVariables(procedure); - } - - public void collectFreeVariables(THashSet vars) { - for(IncludeStatement include : includes) - include.value.collectFreeVariables(vars); - for(CHRRule rule : rules) - rule.collectFreeVariables(vars); - } - public void setLocationDeep(long loc) { if(location == Locations.NO_LOCATION) { this.location = loc; @@ -263,7 +240,7 @@ public class CHRRuleset extends Symbol { public IVal generateCode(CodeWriter w) { for(IncludeStatement include : includes) { - include.storeVar = include.value.toVal(cachedContext.environment, w); + include.storeVar = include.value.toVal(cachedContext, w); initialPriorityNumber = Math.max(initialPriorityNumber, include.ruleset.initialPriorityNumber + include.ruleset.priorityCount); } CHRRulesetObject object = new CHRRulesetObject(runtimeRulesetVariable, this); @@ -283,7 +260,7 @@ public class CHRRuleset extends Symbol { methodWriter.return_(BooleanConstant.TRUE); } } - if(!includes.isEmpty()) { + if(!includes.isEmpty() || extensible) { { CodeWriter methodWriter = object.createMethod(w.getModuleWriter(), TVar.EMPTY_ARRAY, Types.PROC, Types.UNIT, new Type[] {Types.CHRContext}); initializer = methodWriter.getFunction(); @@ -292,6 +269,10 @@ public class CHRRuleset extends Symbol { new JavaMethod(true, runtimeRulesetClassName, "register", Types.PROC, Types.UNIT, new Type[] {runtimeRulesetType, Types.CHRContext, include.ruleset.runtimeRulesetType}), object.getTarget(), methodWriter.getParameters()[0], include.storeVar); } + if(extensible) + methodWriter.apply(Locations.NO_LOCATION, + new JavaMethod(true, runtimeRulesetClassName, "register", Types.PROC, Types.UNIT, new Type[] {runtimeRulesetType, Types.CHRContext}), + object.getTarget(), methodWriter.getParameters()[0]); methodWriter.return_(NoRepConstant.UNIT); } { @@ -302,6 +283,10 @@ public class CHRRuleset extends Symbol { new JavaMethod(true, runtimeRulesetClassName, "unregister", Types.PROC, Types.UNIT, new Type[] {runtimeRulesetType, Types.CHRContext, include.ruleset.runtimeRulesetType}), object.getTarget(), methodWriter.getParameters()[0], include.storeVar); } + if(extensible) + methodWriter.apply(Locations.NO_LOCATION, + new JavaMethod(true, runtimeRulesetClassName, "unregister", Types.PROC, Types.UNIT, new Type[] {runtimeRulesetType, Types.CHRContext}), + object.getTarget(), methodWriter.getParameters()[0]); methodWriter.return_(NoRepConstant.UNIT); } } @@ -324,15 +309,6 @@ public class CHRRuleset extends Symbol { return runtimeRulesetVariable; } - public void collectEffects(THashSet effects) { - for(CHRRule rule : rules) { - for(CHRLiteral literal : rule.head.literals) - literal.collectQueryEffects(effects); - for(CHRLiteral literal : rule.head.literals) - literal.collectEnforceEffects(effects); - } - } - public void addRule(CHRRule rule) { rules.add(rule); rule.parentRuleset = this;