]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Dirty hack to get CHR ruleset resolved before functions using them"
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 22 Sep 2017 09:46:10 +0000 (12:46 +0300)
committerGerrit Code Review <gerrit2@www.simantics.org>
Fri, 22 Sep 2017 09:46:10 +0000 (12:46 +0300)
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();