1 package org.simantics.scl.compiler.internal.codegen.chr;
3 import org.simantics.scl.runtime.chr.CHRHashIndex;
4 import org.simantics.scl.runtime.chr.Fact;
5 import org.simantics.scl.runtime.chr.FactActivationQueue;
7 public class ExampleStore {
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 public FactActivationQueue queue = new FactActivationQueue(2);
38 private ExampleFact ExampleFact_temp = new ExampleFact();
40 public ExampleFact getExampleFact_bf(int c0) {
41 ExampleFact_temp.c0 = c0;
42 return (ExampleFact)ExampleFact_bfIndex.getEqual(ExampleFact_temp);
45 public static class ExampleFact implements Fact {
49 public ExampleFact bfPrev;
50 public ExampleFact bfNext;
52 public ExampleFact() {
55 public ExampleFact(int c0, int c1) {
60 public void add(ExampleStore store) {
61 bfNext = (ExampleFact)store.ExampleFact_bfIndex.addFreshAndReturnOld(this);
66 public void remove(ExampleStore store) {
69 store.ExampleFact_bfIndex.removeKnownToExistKey(this);
72 store.ExampleFact_bfIndex.replaceKnownToExistKey(this, bfNext);
76 bfPrev.bfNext = bfNext;
78 bfNext.bfPrev = bfPrev;
83 public int activate(Object context, int priority) {
88 public boolean isAlive() {