]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Dirty hack to get CHR ruleset resolved before functions using them 15/1015/2
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 22 Sep 2017 08:04:48 +0000 (11:04 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 22 Sep 2017 09:15:40 +0000 (12:15 +0300)
refs #7500

Change-Id: I2a0c64c2ee8bb6698d36ee3682f29e42201c96a5

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java

index ec32ea2981ec9cb68692a7126c4398049e986968..50296a3a1c6c287fb12b7a3564bf26af44f7a568 100644 (file)
@@ -1215,6 +1215,25 @@ public class Elaboration {
         
         for(String name : valueDefinitionsAst.getValueNames()) {
             ArrayList<DValueAst> defs = valueDefinitionsAst.getDefinition(name);
+            if(defs.size() != 1 || !(defs.get(0).value instanceof EPreCHRRulesetConstructor))
+                continue;
+            try {
+                SCLValue value = module.getValue(name);
+                TranslationContext context = createTranslationContext();
+                Expression expression = context.translateCases2(defs);
+                value.setExpression(expression);
+                
+                if(exportMap != null && exportMap.remove(name) == null)
+                    value.addProperty(PrivateProperty.INSTANCE);
+            } catch(RuntimeException e) {
+                errorLog.setExceptionPosition(defs.get(0).location);
+                throw e;
+            }
+        }
+        for(String name : valueDefinitionsAst.getValueNames()) {
+            ArrayList<DValueAst> defs = valueDefinitionsAst.getDefinition(name);
+            if(defs.size() == 1 && defs.get(0).value instanceof EPreCHRRulesetConstructor)
+                continue;
             try {
                 SCLValue value = module.getValue(name);
                 TranslationContext context = createTranslationContext();