]> gerrit.simantics Code Review - simantics/platform.git/blob
a15e30e42638d6674a542478de4e3e8cd9aeaebb
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.chr;
2
3 import org.simantics.scl.compiler.constants.Constant;
4 import org.simantics.scl.compiler.constants.JavaConstructor;
5 import org.simantics.scl.compiler.internal.codegen.chr.CHRRuntimeRulesetCodeGenerator;
6 import org.simantics.scl.compiler.internal.codegen.references.BoundVar;
7 import org.simantics.scl.compiler.internal.codegen.ssa.SSAObject;
8 import org.simantics.scl.compiler.internal.codegen.utils.ModuleBuilder;
9 import org.simantics.scl.compiler.types.Types;
10
11 public class CHRRulesetObject extends SSAObject {
12     CHRRuleset ruleset;
13
14     public CHRRulesetObject(BoundVar target, CHRRuleset ruleset) {
15         super(ruleset.runtimeRulesetType);
16         this.setTarget(target);
17         this.ruleset = ruleset;
18     }
19     
20     @Override
21     public Constant liftClosure(BoundVar newTarget, BoundVar[] parameters) {
22         ruleset.this_ = newTarget;
23         ruleset.parameters = parameters;
24         return new JavaConstructor(ruleset.runtimeRulesetName, Types.PROC, ruleset.runtimeRulesetType, Types.getTypes(parameters));
25     }
26     
27     @Override
28     public void generateCode(ModuleBuilder moduleBuilder) {
29         CHRRuntimeRulesetCodeGenerator.generateRuntimeRuleset(moduleBuilder, ruleset);
30     }
31 }