]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java
(refs #7375) Replace collectRefs by CollectRefsVisitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / chr / CHRRuleset.java
index d670300cbe1a4253758ee5731a766ddc42cac0aa..805e781e74a6eff0f2876ea43df82b86443395ca 100644 (file)
@@ -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;
@@ -123,13 +122,6 @@ public class CHRRuleset extends Symbol {
         }*/
     }
 
-    public void collectRefs(TObjectIntHashMap<Object> 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,13 +136,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<Variable> vars) {
         for(IncludeStatement include : includes)
             include.value.collectFreeVariables(vars);
@@ -283,7 +268,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 +277,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 +291,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);
             }
         }