From: Hannu Niemistö Date: Fri, 22 Sep 2017 08:04:48 +0000 (+0300) Subject: Dirty hack to get CHR ruleset resolved before functions using them X-Git-Tag: v1.31.0~173^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=5317f37d8c47c3b2b206856a239a829e069bd750 Dirty hack to get CHR ruleset resolved before functions using them refs #7500 Change-Id: I2a0c64c2ee8bb6698d36ee3682f29e42201c96a5 --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java index ec32ea298..50296a3a1 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java @@ -1215,6 +1215,25 @@ public class Elaboration { for(String name : valueDefinitionsAst.getValueNames()) { ArrayList 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 defs = valueDefinitionsAst.getDefinition(name); + if(defs.size() == 1 && defs.get(0).value instanceof EPreCHRRulesetConstructor) + continue; try { SCLValue value = module.getValue(name); TranslationContext context = createTranslationContext();