73ba8ea1a1c4e5fc21822a15ded514e380d31785
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / chr / CHRRulesetObject.java
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.CHRCodeGenerator;
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.storeType);
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.storeClassName, Types.PROC, ruleset.storeType, Types.getTypes(parameters));
25     }
26     
27     @Override
28     public void generateCode(ModuleBuilder moduleBuilder) {
29         CHRCodeGenerator.generateStore(moduleBuilder, ruleset);
30     }
31 }