1 package org.simantics.scl.compiler.internal.codegen.chr;
3 import org.simantics.scl.runtime.chr.CHRFact;
4 import org.simantics.scl.runtime.chr.CHRHashIndex;
5 import org.simantics.scl.runtime.chr.CHRRuntimeRuleset;
7 public class ExampleStore extends CHRRuntimeRuleset {
9 * constraint ExampleFact Integer Integer where
14 * data Store // class Module$123
15 * data ExampleFact // class Module$123/ExampleFact
17 * add :: Store -> ExampleFact -> <Proc> ()
18 * remove :: Store -> ExampleFact -> <Proc> ()
19 * get_bf :: Store -> Integer -> <Proc> ExampleFact
20 * next_bf :: ExampleFact -> <Proc> Maybe ExampleFact
21 * idOf :: ExampleFact -> <Proc> Integer
22 * isAlive :: ExampleFact -> <Proc> Boolean
25 CHRHashIndex ExampleFact_bfIndex = new CHRHashIndex() {
27 protected boolean keyEquals(Object a, Object b) {
28 return ((ExampleFact)a).c0 == ((ExampleFact)b).c0;
31 protected int keyHashCode(Object key) {
32 return ((ExampleFact)key).c0;
36 private ExampleFact ExampleFact_temp = new ExampleFact();
38 public ExampleFact getExampleFact_bf(int c0) {
39 ExampleFact_temp.c0 = c0;
40 return (ExampleFact)ExampleFact_bfIndex.getEqual(ExampleFact_temp);
43 public static class ExampleFact extends CHRFact {
46 public ExampleFact bfPrev;
47 public ExampleFact bfNext;
49 public ExampleFact() {
52 public ExampleFact(int c0, int c1) {
57 public void add(ExampleStore store) {
58 bfNext = (ExampleFact)store.ExampleFact_bfIndex.addFreshAndReturnOld(this);
63 public void remove(ExampleStore store) {
66 store.ExampleFact_bfIndex.removeKnownToExistKey(this);
69 store.ExampleFact_bfIndex.replaceKnownToExistKey(this, bfNext);
73 bfPrev.bfNext = bfNext;
75 bfNext.bfPrev = bfPrev;