1 package org.simantics.scl.compiler.elaboration.expressions;
3 import org.simantics.scl.compiler.elaboration.chr.CHRRuleset;
4 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
5 import org.simantics.scl.compiler.errors.Locations;
6 import org.simantics.scl.compiler.internal.parsing.declarations.DRulesetAst;
8 public class EPreCHRRulesetConstructor extends ASTExpression {
9 DRulesetAst rulesetAst;
11 public EPreCHRRulesetConstructor(DRulesetAst rulesetAst) {
12 this.rulesetAst = rulesetAst;
13 this.location = rulesetAst.location;
17 public Expression resolve(TranslationContext context) {
18 CHRRuleset ruleset = rulesetAst.block.extractCHRRules(context);
19 ruleset.setLocationDeep(rulesetAst.location);
20 ruleset.setRulesetType(rulesetAst.type, rulesetAst.className);
21 ruleset.extensible = true;
22 context.getCompilationContext().module.addRuleset(rulesetAst.name, ruleset);
23 ECHRRulesetConstructor result = new ECHRRulesetConstructor(ruleset);
24 result.resolve(context);
25 result.setType(rulesetAst.type);
30 public void setLocationDeep(long loc) {
31 if(location == Locations.NO_LOCATION) {
32 rulesetAst.block.setLocationDeep(loc);
38 public Expression accept(ExpressionTransformer transformer) {