callatz.chr
· 230 B · Text
Исходник
Playground
move, y <=> x, move
move, x, x <=> x, x, eval
move, x <=> x
odd, y <=> x, x, x, x, x, x, odd
odd <=> x, eval
eval, x, x <=> y, eval
eval, x <=> x, x, x, odd
eval <=> move
start <=>
x, x, x, x, x,
x, x, x, x, x,
x, x, eval
| 1 | move, y <=> x, move |
| 2 | move, x, x <=> x, x, eval |
| 3 | move, x <=> x |
| 4 | |
| 5 | odd, y <=> x, x, x, x, x, x, odd |
| 6 | odd <=> x, eval |
| 7 | |
| 8 | eval, x, x <=> y, eval |
| 9 | eval, x <=> x, x, x, odd |
| 10 | eval <=> move |
| 11 | |
| 12 | start <=> |
| 13 | x, x, x, x, x, |
| 14 | x, x, x, x, x, |
| 15 | x, x, eval |
callatz.js
· 21 KiB · JavaScript
Исходник
Playground
/**
*
* Automatically generated
* Do not edit
*
* Created using CHR.js AOT compiler
* (CHR.js version v3.3.21)
* http://github.com/fnogatz/CHR.js
*
*/
module.exports = (function () {
/* eslint no-labels: ["error", { "allowLoop": true }] */
// Constraint
function Constraint (name, arity, args) {
this.name = name
this.arity = arity
this.functor = name + '/' + arity
this.args = args
this.id = null
this.alive = true
this.activated = false
this.stored = false
this.hist = null
this.cont = null
}
Constraint.prototype.continue = function () {
this.cont[0].call(this, this, this.cont[1])
}
Constraint.prototype.toString = function () {
let s = this.name
if (this.arity >= 1) {
s += '(' + this.args.join(',') + ')'
}
return s
}
// Store
function Store () {
this._index = {}
this._size = 0
this._nextId = 0
}
Store.prototype.add = function (constraint) {
if (typeof this._index[constraint.functor] === 'undefined') {
this._index[constraint.functor] = []
}
constraint.id = this._nextId
this._index[constraint.functor].push(constraint)
this._size += 1
this._nextId += 1
}
Store.prototype.remove = function (constraint) {
constraint.alive = false
const ix = this._index[constraint.functor].indexOf(constraint)
this._index[constraint.functor].splice(ix, 1)
this._size -= 1
}
Store.prototype.lookup = function (rule, patterns, constraint) {
const ret = this.lookupResume(rule, patterns, constraint, 0)
if (!ret || !ret.res) {
return false
}
return ret.res
}
Store.prototype.lookupResume = function (rule, patterns, constraint, startFrom) {
startFrom = startFrom || 0
const lastPattern = patterns.length - 1
const lengths = []
const divs = []
let div = 1
let i
// build array of arrays
const arr = []
for (i = 0; i <= lastPattern; i++) {
if (patterns[i] === '_') {
// "_" is a placeholder for the given `constraint`
arr[i] = [constraint]
} else if (typeof this._index[patterns[i]] !== 'undefined') {
arr[i] = this._index[patterns[i]]
} else {
// not a single element for this functor
return false
}
}
for (i = lastPattern; i >= 0; i--) {
lengths[i] = arr[i].length
divs[i] = div
div *= arr[i].length
}
const max = divs[0] * arr[0].length
let res
let resIds
let curr
loopng: for (let n = startFrom; n < max; n++) {
res = []
resIds = []
curr = n
for (i = 0; i <= lastPattern; i++) {
res[i] = arr[i][curr / divs[i] >> 0]
resIds[i] = res[i].id
// avoid multiple occurences of the same constraint
if (res.slice(0, i).indexOf(res[i]) !== -1) {
continue loopng
}
curr = curr % divs[i]
}
// check if already in history
/*
if (history.lookup(rule, resIds)) {
continue loopng
}
*/
return {
n: n,
res: res
}
}
return false
}
Store.prototype.size = function () {
return this._size
}
Store.prototype.valueOf = function () {
return this.size()
}
Store.prototype.toString = function () {
if (this.size() === 0) {
return '(empty)'
}
let maxLengthC = 'constraint'.length
let maxLengthI = 'id'.length
const rows = []
let functor
for (functor in this._index) {
this._index[functor].forEach(function (c) {
const s = c.toString()
maxLengthC = Math.max(s.length, maxLengthC)
maxLengthI = Math.max(c.id.toString().length + 1, maxLengthI)
})
}
for (functor in this._index) {
this._index[functor].forEach(function (c) {
rows.push(c.id.toString().padStart(maxLengthI) + ' | ' + c.toString().padEnd(maxLengthC))
})
}
return [
'id'.padStart(maxLengthI) + ' | ' + 'constraint'.padEnd(maxLengthC),
''.padStart(maxLengthI, '-') + '-+-' + ''.padEnd(maxLengthC, '-')
].concat(rows).join('\n')
}
// trampoline
function trampoline () { // eslint-disable-line
let constraint
while (constraint = stack.pop()) { // eslint-disable-line
constraint.continue()
}
}
var chr = { // eslint-disable-line
Store: new Store()
}
var stack = [] // eslint-disable-line
// var history = new History()
function __y_0_0 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "move/0", "_" ]
var lookupResult = chr.Store.lookupResume(0, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__y_0_1, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("move", 0, [ ])
_c.cont = [__move_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __move_0_0 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "y/0" ]
var lookupResult = chr.Store.lookupResume(0, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__move_0_1, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("move", 0, [ ])
_c.cont = [__move_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_0 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "move/0", "x/0", "_" ]
var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_1, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_1 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "move/0", "_", "x/0" ]
var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_2, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
chr.Store.remove(constraints[2])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __move_0_1 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "x/0", "x/0" ]
var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__move_0_2, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
chr.Store.remove(constraints[2])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_2 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "move/0", "_" ]
var lookupResult = chr.Store.lookupResume(2, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_3, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __move_0_2 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "x/0" ]
var lookupResult = chr.Store.lookupResume(2, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__move_0_3, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __y_0_1 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "odd/0", "_" ]
var lookupResult = chr.Store.lookupResume(3, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__y_0_2, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("odd", 0, [ ])
_c.cont = [__odd_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __odd_0_0 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "y/0" ]
var lookupResult = chr.Store.lookupResume(3, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__odd_0_1, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("odd", 0, [ ])
_c.cont = [__odd_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __odd_0_1 (constraint, __n) {
__n = __n || 0
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_3 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "eval/0", "x/0", "_" ]
var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_4, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("y", 0, [ ])
_c.cont = [__y_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_4 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "eval/0", "_", "x/0" ]
var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_5, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
chr.Store.remove(constraints[2])
;(function () {
var _c = new Constraint("y", 0, [ ])
_c.cont = [__y_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __eval_0_0 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "x/0", "x/0" ]
var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__eval_0_1, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
chr.Store.remove(constraints[2])
;(function () {
var _c = new Constraint("y", 0, [ ])
_c.cont = [__y_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __x_0_5 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "eval/0", "_" ]
var lookupResult = chr.Store.lookupResume(6, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__x_0_6, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[0])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("odd", 0, [ ])
_c.cont = [__odd_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __eval_0_1 (constraint, __n) {
__n = __n || 0
var constraintPattern = [ "_", "x/0" ]
var lookupResult = chr.Store.lookupResume(6, constraintPattern, constraint, __n)
if (lookupResult === false) {
constraint.cont = [__eval_0_2, 0]
stack.push(constraint)
return
}
var constraints = lookupResult.res
chr.Store.remove(constraints[1])
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("odd", 0, [ ])
_c.cont = [__odd_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __eval_0_2 (constraint, __n) {
__n = __n || 0
;(function () {
var _c = new Constraint("move", 0, [ ])
_c.cont = [__move_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __start_0_0 (constraint, __n) {
__n = __n || 0
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("x", 0, [ ])
_c.cont = [__x_0_0, 0]
stack.push(_c)
})()
;(function () {
var _c = new Constraint("eval", 0, [ ])
_c.cont = [__eval_0_0, 0]
stack.push(_c)
})()
// active constraint gets removed
}
function __move_0_3 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function __y_0_2 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function __x_0_6 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function __eval_0_3 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function __odd_0_2 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function __start_0_1 (constraint) {
constraint.cont = null
chr.Store.add(constraint)
}
function move () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "move/" + arity
var constraint = new Constraint("move", arity, args)
if (arity === 0) {
constraint.cont = [__move_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
function y () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "y/" + arity
var constraint = new Constraint("y", arity, args)
if (arity === 0) {
constraint.cont = [__y_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
function x () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "x/" + arity
var constraint = new Constraint("x", arity, args)
if (arity === 0) {
constraint.cont = [__x_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
function eval () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "eval/" + arity
var constraint = new Constraint("eval", arity, args)
if (arity === 0) {
constraint.cont = [__eval_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
function odd () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "odd/" + arity
var constraint = new Constraint("odd", arity, args)
if (arity === 0) {
constraint.cont = [__odd_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
function start () {
var args = Array.prototype.slice.call(arguments)
var arity = arguments.length
var functor = "start/" + arity
var constraint = new Constraint("start", arity, args)
if (arity === 0) {
constraint.cont = [__start_0_0, ]
} else {
throw new Error("Undefined constraint: " + functor)
}
stack.push(constraint)
trampoline()
}
chr.move = move
chr.y = y
chr.x = x
chr.eval = eval
chr.odd = odd
chr.start = start
return chr
})()
| 1 | /** |
| 2 | * |
| 3 | * Automatically generated |
| 4 | * Do not edit |
| 5 | * |
| 6 | * Created using CHR.js AOT compiler |
| 7 | * (CHR.js version v3.3.21) |
| 8 | * http://github.com/fnogatz/CHR.js |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | module.exports = (function () { |
| 13 | |
| 14 | /* eslint no-labels: ["error", { "allowLoop": true }] */ |
| 15 | |
| 16 | // Constraint |
| 17 | function Constraint (name, arity, args) { |
| 18 | this.name = name |
| 19 | this.arity = arity |
| 20 | this.functor = name + '/' + arity |
| 21 | this.args = args |
| 22 | this.id = null |
| 23 | this.alive = true |
| 24 | this.activated = false |
| 25 | this.stored = false |
| 26 | this.hist = null |
| 27 | this.cont = null |
| 28 | } |
| 29 | |
| 30 | Constraint.prototype.continue = function () { |
| 31 | this.cont[0].call(this, this, this.cont[1]) |
| 32 | } |
| 33 | |
| 34 | Constraint.prototype.toString = function () { |
| 35 | let s = this.name |
| 36 | if (this.arity >= 1) { |
| 37 | s += '(' + this.args.join(',') + ')' |
| 38 | } |
| 39 | return s |
| 40 | } |
| 41 | |
| 42 | // Store |
| 43 | function Store () { |
| 44 | this._index = {} |
| 45 | this._size = 0 |
| 46 | this._nextId = 0 |
| 47 | } |
| 48 | |
| 49 | Store.prototype.add = function (constraint) { |
| 50 | if (typeof this._index[constraint.functor] === 'undefined') { |
| 51 | this._index[constraint.functor] = [] |
| 52 | } |
| 53 | constraint.id = this._nextId |
| 54 | this._index[constraint.functor].push(constraint) |
| 55 | this._size += 1 |
| 56 | this._nextId += 1 |
| 57 | } |
| 58 | |
| 59 | Store.prototype.remove = function (constraint) { |
| 60 | constraint.alive = false |
| 61 | const ix = this._index[constraint.functor].indexOf(constraint) |
| 62 | this._index[constraint.functor].splice(ix, 1) |
| 63 | |
| 64 | this._size -= 1 |
| 65 | } |
| 66 | |
| 67 | Store.prototype.lookup = function (rule, patterns, constraint) { |
| 68 | const ret = this.lookupResume(rule, patterns, constraint, 0) |
| 69 | if (!ret || !ret.res) { |
| 70 | return false |
| 71 | } |
| 72 | return ret.res |
| 73 | } |
| 74 | |
| 75 | Store.prototype.lookupResume = function (rule, patterns, constraint, startFrom) { |
| 76 | startFrom = startFrom || 0 |
| 77 | |
| 78 | const lastPattern = patterns.length - 1 |
| 79 | const lengths = [] |
| 80 | const divs = [] |
| 81 | let div = 1 |
| 82 | let i |
| 83 | |
| 84 | // build array of arrays |
| 85 | const arr = [] |
| 86 | for (i = 0; i <= lastPattern; i++) { |
| 87 | if (patterns[i] === '_') { |
| 88 | // "_" is a placeholder for the given `constraint` |
| 89 | arr[i] = [constraint] |
| 90 | } else if (typeof this._index[patterns[i]] !== 'undefined') { |
| 91 | arr[i] = this._index[patterns[i]] |
| 92 | } else { |
| 93 | // not a single element for this functor |
| 94 | return false |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | for (i = lastPattern; i >= 0; i--) { |
| 99 | lengths[i] = arr[i].length |
| 100 | divs[i] = div |
| 101 | div *= arr[i].length |
| 102 | } |
| 103 | const max = divs[0] * arr[0].length |
| 104 | |
| 105 | let res |
| 106 | let resIds |
| 107 | let curr |
| 108 | loopng: for (let n = startFrom; n < max; n++) { |
| 109 | res = [] |
| 110 | resIds = [] |
| 111 | curr = n |
| 112 | for (i = 0; i <= lastPattern; i++) { |
| 113 | res[i] = arr[i][curr / divs[i] >> 0] |
| 114 | resIds[i] = res[i].id |
| 115 | |
| 116 | // avoid multiple occurences of the same constraint |
| 117 | if (res.slice(0, i).indexOf(res[i]) !== -1) { |
| 118 | continue loopng |
| 119 | } |
| 120 | |
| 121 | curr = curr % divs[i] |
| 122 | } |
| 123 | |
| 124 | // check if already in history |
| 125 | /* |
| 126 | if (history.lookup(rule, resIds)) { |
| 127 | continue loopng |
| 128 | } |
| 129 | */ |
| 130 | return { |
| 131 | n: n, |
| 132 | res: res |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return false |
| 137 | } |
| 138 | |
| 139 | Store.prototype.size = function () { |
| 140 | return this._size |
| 141 | } |
| 142 | |
| 143 | Store.prototype.valueOf = function () { |
| 144 | return this.size() |
| 145 | } |
| 146 | |
| 147 | Store.prototype.toString = function () { |
| 148 | if (this.size() === 0) { |
| 149 | return '(empty)' |
| 150 | } |
| 151 | |
| 152 | let maxLengthC = 'constraint'.length |
| 153 | let maxLengthI = 'id'.length |
| 154 | const rows = [] |
| 155 | let functor |
| 156 | for (functor in this._index) { |
| 157 | this._index[functor].forEach(function (c) { |
| 158 | const s = c.toString() |
| 159 | maxLengthC = Math.max(s.length, maxLengthC) |
| 160 | maxLengthI = Math.max(c.id.toString().length + 1, maxLengthI) |
| 161 | }) |
| 162 | } |
| 163 | for (functor in this._index) { |
| 164 | this._index[functor].forEach(function (c) { |
| 165 | rows.push(c.id.toString().padStart(maxLengthI) + ' | ' + c.toString().padEnd(maxLengthC)) |
| 166 | }) |
| 167 | } |
| 168 | |
| 169 | return [ |
| 170 | 'id'.padStart(maxLengthI) + ' | ' + 'constraint'.padEnd(maxLengthC), |
| 171 | ''.padStart(maxLengthI, '-') + '-+-' + ''.padEnd(maxLengthC, '-') |
| 172 | ].concat(rows).join('\n') |
| 173 | } |
| 174 | |
| 175 | // trampoline |
| 176 | function trampoline () { // eslint-disable-line |
| 177 | let constraint |
| 178 | while (constraint = stack.pop()) { // eslint-disable-line |
| 179 | constraint.continue() |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | var chr = { // eslint-disable-line |
| 184 | Store: new Store() |
| 185 | } |
| 186 | |
| 187 | var stack = [] // eslint-disable-line |
| 188 | // var history = new History() |
| 189 | |
| 190 | function __y_0_0 (constraint, __n) { |
| 191 | __n = __n || 0 |
| 192 | |
| 193 | var constraintPattern = [ "move/0", "_" ] |
| 194 | var lookupResult = chr.Store.lookupResume(0, constraintPattern, constraint, __n) |
| 195 | if (lookupResult === false) { |
| 196 | constraint.cont = [__y_0_1, 0] |
| 197 | stack.push(constraint) |
| 198 | return |
| 199 | } |
| 200 | var constraints = lookupResult.res |
| 201 | |
| 202 | chr.Store.remove(constraints[0]) |
| 203 | |
| 204 | ;(function () { |
| 205 | var _c = new Constraint("x", 0, [ ]) |
| 206 | _c.cont = [__x_0_0, 0] |
| 207 | stack.push(_c) |
| 208 | })() |
| 209 | |
| 210 | ;(function () { |
| 211 | var _c = new Constraint("move", 0, [ ]) |
| 212 | _c.cont = [__move_0_0, 0] |
| 213 | stack.push(_c) |
| 214 | })() |
| 215 | |
| 216 | // active constraint gets removed |
| 217 | } |
| 218 | |
| 219 | function __move_0_0 (constraint, __n) { |
| 220 | __n = __n || 0 |
| 221 | |
| 222 | var constraintPattern = [ "_", "y/0" ] |
| 223 | var lookupResult = chr.Store.lookupResume(0, constraintPattern, constraint, __n) |
| 224 | if (lookupResult === false) { |
| 225 | constraint.cont = [__move_0_1, 0] |
| 226 | stack.push(constraint) |
| 227 | return |
| 228 | } |
| 229 | var constraints = lookupResult.res |
| 230 | |
| 231 | chr.Store.remove(constraints[1]) |
| 232 | |
| 233 | ;(function () { |
| 234 | var _c = new Constraint("x", 0, [ ]) |
| 235 | _c.cont = [__x_0_0, 0] |
| 236 | stack.push(_c) |
| 237 | })() |
| 238 | |
| 239 | ;(function () { |
| 240 | var _c = new Constraint("move", 0, [ ]) |
| 241 | _c.cont = [__move_0_0, 0] |
| 242 | stack.push(_c) |
| 243 | })() |
| 244 | |
| 245 | // active constraint gets removed |
| 246 | } |
| 247 | |
| 248 | function __x_0_0 (constraint, __n) { |
| 249 | __n = __n || 0 |
| 250 | |
| 251 | var constraintPattern = [ "move/0", "x/0", "_" ] |
| 252 | var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n) |
| 253 | if (lookupResult === false) { |
| 254 | constraint.cont = [__x_0_1, 0] |
| 255 | stack.push(constraint) |
| 256 | return |
| 257 | } |
| 258 | var constraints = lookupResult.res |
| 259 | |
| 260 | chr.Store.remove(constraints[0]) |
| 261 | chr.Store.remove(constraints[1]) |
| 262 | |
| 263 | ;(function () { |
| 264 | var _c = new Constraint("x", 0, [ ]) |
| 265 | _c.cont = [__x_0_0, 0] |
| 266 | stack.push(_c) |
| 267 | })() |
| 268 | |
| 269 | ;(function () { |
| 270 | var _c = new Constraint("x", 0, [ ]) |
| 271 | _c.cont = [__x_0_0, 0] |
| 272 | stack.push(_c) |
| 273 | })() |
| 274 | |
| 275 | ;(function () { |
| 276 | var _c = new Constraint("eval", 0, [ ]) |
| 277 | _c.cont = [__eval_0_0, 0] |
| 278 | stack.push(_c) |
| 279 | })() |
| 280 | |
| 281 | // active constraint gets removed |
| 282 | } |
| 283 | |
| 284 | function __x_0_1 (constraint, __n) { |
| 285 | __n = __n || 0 |
| 286 | |
| 287 | var constraintPattern = [ "move/0", "_", "x/0" ] |
| 288 | var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n) |
| 289 | if (lookupResult === false) { |
| 290 | constraint.cont = [__x_0_2, 0] |
| 291 | stack.push(constraint) |
| 292 | return |
| 293 | } |
| 294 | var constraints = lookupResult.res |
| 295 | |
| 296 | chr.Store.remove(constraints[0]) |
| 297 | chr.Store.remove(constraints[2]) |
| 298 | |
| 299 | ;(function () { |
| 300 | var _c = new Constraint("x", 0, [ ]) |
| 301 | _c.cont = [__x_0_0, 0] |
| 302 | stack.push(_c) |
| 303 | })() |
| 304 | |
| 305 | ;(function () { |
| 306 | var _c = new Constraint("x", 0, [ ]) |
| 307 | _c.cont = [__x_0_0, 0] |
| 308 | stack.push(_c) |
| 309 | })() |
| 310 | |
| 311 | ;(function () { |
| 312 | var _c = new Constraint("eval", 0, [ ]) |
| 313 | _c.cont = [__eval_0_0, 0] |
| 314 | stack.push(_c) |
| 315 | })() |
| 316 | |
| 317 | // active constraint gets removed |
| 318 | } |
| 319 | |
| 320 | function __move_0_1 (constraint, __n) { |
| 321 | __n = __n || 0 |
| 322 | |
| 323 | var constraintPattern = [ "_", "x/0", "x/0" ] |
| 324 | var lookupResult = chr.Store.lookupResume(1, constraintPattern, constraint, __n) |
| 325 | if (lookupResult === false) { |
| 326 | constraint.cont = [__move_0_2, 0] |
| 327 | stack.push(constraint) |
| 328 | return |
| 329 | } |
| 330 | var constraints = lookupResult.res |
| 331 | |
| 332 | chr.Store.remove(constraints[1]) |
| 333 | chr.Store.remove(constraints[2]) |
| 334 | |
| 335 | ;(function () { |
| 336 | var _c = new Constraint("x", 0, [ ]) |
| 337 | _c.cont = [__x_0_0, 0] |
| 338 | stack.push(_c) |
| 339 | })() |
| 340 | |
| 341 | ;(function () { |
| 342 | var _c = new Constraint("x", 0, [ ]) |
| 343 | _c.cont = [__x_0_0, 0] |
| 344 | stack.push(_c) |
| 345 | })() |
| 346 | |
| 347 | ;(function () { |
| 348 | var _c = new Constraint("eval", 0, [ ]) |
| 349 | _c.cont = [__eval_0_0, 0] |
| 350 | stack.push(_c) |
| 351 | })() |
| 352 | |
| 353 | // active constraint gets removed |
| 354 | } |
| 355 | |
| 356 | function __x_0_2 (constraint, __n) { |
| 357 | __n = __n || 0 |
| 358 | |
| 359 | var constraintPattern = [ "move/0", "_" ] |
| 360 | var lookupResult = chr.Store.lookupResume(2, constraintPattern, constraint, __n) |
| 361 | if (lookupResult === false) { |
| 362 | constraint.cont = [__x_0_3, 0] |
| 363 | stack.push(constraint) |
| 364 | return |
| 365 | } |
| 366 | var constraints = lookupResult.res |
| 367 | |
| 368 | chr.Store.remove(constraints[0]) |
| 369 | |
| 370 | ;(function () { |
| 371 | var _c = new Constraint("x", 0, [ ]) |
| 372 | _c.cont = [__x_0_0, 0] |
| 373 | stack.push(_c) |
| 374 | })() |
| 375 | |
| 376 | // active constraint gets removed |
| 377 | } |
| 378 | |
| 379 | function __move_0_2 (constraint, __n) { |
| 380 | __n = __n || 0 |
| 381 | |
| 382 | var constraintPattern = [ "_", "x/0" ] |
| 383 | var lookupResult = chr.Store.lookupResume(2, constraintPattern, constraint, __n) |
| 384 | if (lookupResult === false) { |
| 385 | constraint.cont = [__move_0_3, 0] |
| 386 | stack.push(constraint) |
| 387 | return |
| 388 | } |
| 389 | var constraints = lookupResult.res |
| 390 | |
| 391 | chr.Store.remove(constraints[1]) |
| 392 | |
| 393 | ;(function () { |
| 394 | var _c = new Constraint("x", 0, [ ]) |
| 395 | _c.cont = [__x_0_0, 0] |
| 396 | stack.push(_c) |
| 397 | })() |
| 398 | |
| 399 | // active constraint gets removed |
| 400 | } |
| 401 | |
| 402 | function __y_0_1 (constraint, __n) { |
| 403 | __n = __n || 0 |
| 404 | |
| 405 | var constraintPattern = [ "odd/0", "_" ] |
| 406 | var lookupResult = chr.Store.lookupResume(3, constraintPattern, constraint, __n) |
| 407 | if (lookupResult === false) { |
| 408 | constraint.cont = [__y_0_2, 0] |
| 409 | stack.push(constraint) |
| 410 | return |
| 411 | } |
| 412 | var constraints = lookupResult.res |
| 413 | |
| 414 | chr.Store.remove(constraints[0]) |
| 415 | |
| 416 | ;(function () { |
| 417 | var _c = new Constraint("x", 0, [ ]) |
| 418 | _c.cont = [__x_0_0, 0] |
| 419 | stack.push(_c) |
| 420 | })() |
| 421 | |
| 422 | ;(function () { |
| 423 | var _c = new Constraint("x", 0, [ ]) |
| 424 | _c.cont = [__x_0_0, 0] |
| 425 | stack.push(_c) |
| 426 | })() |
| 427 | |
| 428 | ;(function () { |
| 429 | var _c = new Constraint("x", 0, [ ]) |
| 430 | _c.cont = [__x_0_0, 0] |
| 431 | stack.push(_c) |
| 432 | })() |
| 433 | |
| 434 | ;(function () { |
| 435 | var _c = new Constraint("x", 0, [ ]) |
| 436 | _c.cont = [__x_0_0, 0] |
| 437 | stack.push(_c) |
| 438 | })() |
| 439 | |
| 440 | ;(function () { |
| 441 | var _c = new Constraint("x", 0, [ ]) |
| 442 | _c.cont = [__x_0_0, 0] |
| 443 | stack.push(_c) |
| 444 | })() |
| 445 | |
| 446 | ;(function () { |
| 447 | var _c = new Constraint("x", 0, [ ]) |
| 448 | _c.cont = [__x_0_0, 0] |
| 449 | stack.push(_c) |
| 450 | })() |
| 451 | |
| 452 | ;(function () { |
| 453 | var _c = new Constraint("odd", 0, [ ]) |
| 454 | _c.cont = [__odd_0_0, 0] |
| 455 | stack.push(_c) |
| 456 | })() |
| 457 | |
| 458 | // active constraint gets removed |
| 459 | } |
| 460 | |
| 461 | function __odd_0_0 (constraint, __n) { |
| 462 | __n = __n || 0 |
| 463 | |
| 464 | var constraintPattern = [ "_", "y/0" ] |
| 465 | var lookupResult = chr.Store.lookupResume(3, constraintPattern, constraint, __n) |
| 466 | if (lookupResult === false) { |
| 467 | constraint.cont = [__odd_0_1, 0] |
| 468 | stack.push(constraint) |
| 469 | return |
| 470 | } |
| 471 | var constraints = lookupResult.res |
| 472 | |
| 473 | chr.Store.remove(constraints[1]) |
| 474 | |
| 475 | ;(function () { |
| 476 | var _c = new Constraint("x", 0, [ ]) |
| 477 | _c.cont = [__x_0_0, 0] |
| 478 | stack.push(_c) |
| 479 | })() |
| 480 | |
| 481 | ;(function () { |
| 482 | var _c = new Constraint("x", 0, [ ]) |
| 483 | _c.cont = [__x_0_0, 0] |
| 484 | stack.push(_c) |
| 485 | })() |
| 486 | |
| 487 | ;(function () { |
| 488 | var _c = new Constraint("x", 0, [ ]) |
| 489 | _c.cont = [__x_0_0, 0] |
| 490 | stack.push(_c) |
| 491 | })() |
| 492 | |
| 493 | ;(function () { |
| 494 | var _c = new Constraint("x", 0, [ ]) |
| 495 | _c.cont = [__x_0_0, 0] |
| 496 | stack.push(_c) |
| 497 | })() |
| 498 | |
| 499 | ;(function () { |
| 500 | var _c = new Constraint("x", 0, [ ]) |
| 501 | _c.cont = [__x_0_0, 0] |
| 502 | stack.push(_c) |
| 503 | })() |
| 504 | |
| 505 | ;(function () { |
| 506 | var _c = new Constraint("x", 0, [ ]) |
| 507 | _c.cont = [__x_0_0, 0] |
| 508 | stack.push(_c) |
| 509 | })() |
| 510 | |
| 511 | ;(function () { |
| 512 | var _c = new Constraint("odd", 0, [ ]) |
| 513 | _c.cont = [__odd_0_0, 0] |
| 514 | stack.push(_c) |
| 515 | })() |
| 516 | |
| 517 | // active constraint gets removed |
| 518 | } |
| 519 | |
| 520 | function __odd_0_1 (constraint, __n) { |
| 521 | __n = __n || 0 |
| 522 | |
| 523 | ;(function () { |
| 524 | var _c = new Constraint("x", 0, [ ]) |
| 525 | _c.cont = [__x_0_0, 0] |
| 526 | stack.push(_c) |
| 527 | })() |
| 528 | |
| 529 | ;(function () { |
| 530 | var _c = new Constraint("eval", 0, [ ]) |
| 531 | _c.cont = [__eval_0_0, 0] |
| 532 | stack.push(_c) |
| 533 | })() |
| 534 | |
| 535 | // active constraint gets removed |
| 536 | } |
| 537 | |
| 538 | function __x_0_3 (constraint, __n) { |
| 539 | __n = __n || 0 |
| 540 | |
| 541 | var constraintPattern = [ "eval/0", "x/0", "_" ] |
| 542 | var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n) |
| 543 | if (lookupResult === false) { |
| 544 | constraint.cont = [__x_0_4, 0] |
| 545 | stack.push(constraint) |
| 546 | return |
| 547 | } |
| 548 | var constraints = lookupResult.res |
| 549 | |
| 550 | chr.Store.remove(constraints[0]) |
| 551 | chr.Store.remove(constraints[1]) |
| 552 | |
| 553 | ;(function () { |
| 554 | var _c = new Constraint("y", 0, [ ]) |
| 555 | _c.cont = [__y_0_0, 0] |
| 556 | stack.push(_c) |
| 557 | })() |
| 558 | |
| 559 | ;(function () { |
| 560 | var _c = new Constraint("eval", 0, [ ]) |
| 561 | _c.cont = [__eval_0_0, 0] |
| 562 | stack.push(_c) |
| 563 | })() |
| 564 | |
| 565 | // active constraint gets removed |
| 566 | } |
| 567 | |
| 568 | function __x_0_4 (constraint, __n) { |
| 569 | __n = __n || 0 |
| 570 | |
| 571 | var constraintPattern = [ "eval/0", "_", "x/0" ] |
| 572 | var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n) |
| 573 | if (lookupResult === false) { |
| 574 | constraint.cont = [__x_0_5, 0] |
| 575 | stack.push(constraint) |
| 576 | return |
| 577 | } |
| 578 | var constraints = lookupResult.res |
| 579 | |
| 580 | chr.Store.remove(constraints[0]) |
| 581 | chr.Store.remove(constraints[2]) |
| 582 | |
| 583 | ;(function () { |
| 584 | var _c = new Constraint("y", 0, [ ]) |
| 585 | _c.cont = [__y_0_0, 0] |
| 586 | stack.push(_c) |
| 587 | })() |
| 588 | |
| 589 | ;(function () { |
| 590 | var _c = new Constraint("eval", 0, [ ]) |
| 591 | _c.cont = [__eval_0_0, 0] |
| 592 | stack.push(_c) |
| 593 | })() |
| 594 | |
| 595 | // active constraint gets removed |
| 596 | } |
| 597 | |
| 598 | function __eval_0_0 (constraint, __n) { |
| 599 | __n = __n || 0 |
| 600 | |
| 601 | var constraintPattern = [ "_", "x/0", "x/0" ] |
| 602 | var lookupResult = chr.Store.lookupResume(5, constraintPattern, constraint, __n) |
| 603 | if (lookupResult === false) { |
| 604 | constraint.cont = [__eval_0_1, 0] |
| 605 | stack.push(constraint) |
| 606 | return |
| 607 | } |
| 608 | var constraints = lookupResult.res |
| 609 | |
| 610 | chr.Store.remove(constraints[1]) |
| 611 | chr.Store.remove(constraints[2]) |
| 612 | |
| 613 | ;(function () { |
| 614 | var _c = new Constraint("y", 0, [ ]) |
| 615 | _c.cont = [__y_0_0, 0] |
| 616 | stack.push(_c) |
| 617 | })() |
| 618 | |
| 619 | ;(function () { |
| 620 | var _c = new Constraint("eval", 0, [ ]) |
| 621 | _c.cont = [__eval_0_0, 0] |
| 622 | stack.push(_c) |
| 623 | })() |
| 624 | |
| 625 | // active constraint gets removed |
| 626 | } |
| 627 | |
| 628 | function __x_0_5 (constraint, __n) { |
| 629 | __n = __n || 0 |
| 630 | |
| 631 | var constraintPattern = [ "eval/0", "_" ] |
| 632 | var lookupResult = chr.Store.lookupResume(6, constraintPattern, constraint, __n) |
| 633 | if (lookupResult === false) { |
| 634 | constraint.cont = [__x_0_6, 0] |
| 635 | stack.push(constraint) |
| 636 | return |
| 637 | } |
| 638 | var constraints = lookupResult.res |
| 639 | |
| 640 | chr.Store.remove(constraints[0]) |
| 641 | |
| 642 | ;(function () { |
| 643 | var _c = new Constraint("x", 0, [ ]) |
| 644 | _c.cont = [__x_0_0, 0] |
| 645 | stack.push(_c) |
| 646 | })() |
| 647 | |
| 648 | ;(function () { |
| 649 | var _c = new Constraint("x", 0, [ ]) |
| 650 | _c.cont = [__x_0_0, 0] |
| 651 | stack.push(_c) |
| 652 | })() |
| 653 | |
| 654 | ;(function () { |
| 655 | var _c = new Constraint("x", 0, [ ]) |
| 656 | _c.cont = [__x_0_0, 0] |
| 657 | stack.push(_c) |
| 658 | })() |
| 659 | |
| 660 | ;(function () { |
| 661 | var _c = new Constraint("odd", 0, [ ]) |
| 662 | _c.cont = [__odd_0_0, 0] |
| 663 | stack.push(_c) |
| 664 | })() |
| 665 | |
| 666 | // active constraint gets removed |
| 667 | } |
| 668 | |
| 669 | function __eval_0_1 (constraint, __n) { |
| 670 | __n = __n || 0 |
| 671 | |
| 672 | var constraintPattern = [ "_", "x/0" ] |
| 673 | var lookupResult = chr.Store.lookupResume(6, constraintPattern, constraint, __n) |
| 674 | if (lookupResult === false) { |
| 675 | constraint.cont = [__eval_0_2, 0] |
| 676 | stack.push(constraint) |
| 677 | return |
| 678 | } |
| 679 | var constraints = lookupResult.res |
| 680 | |
| 681 | chr.Store.remove(constraints[1]) |
| 682 | |
| 683 | ;(function () { |
| 684 | var _c = new Constraint("x", 0, [ ]) |
| 685 | _c.cont = [__x_0_0, 0] |
| 686 | stack.push(_c) |
| 687 | })() |
| 688 | |
| 689 | ;(function () { |
| 690 | var _c = new Constraint("x", 0, [ ]) |
| 691 | _c.cont = [__x_0_0, 0] |
| 692 | stack.push(_c) |
| 693 | })() |
| 694 | |
| 695 | ;(function () { |
| 696 | var _c = new Constraint("x", 0, [ ]) |
| 697 | _c.cont = [__x_0_0, 0] |
| 698 | stack.push(_c) |
| 699 | })() |
| 700 | |
| 701 | ;(function () { |
| 702 | var _c = new Constraint("odd", 0, [ ]) |
| 703 | _c.cont = [__odd_0_0, 0] |
| 704 | stack.push(_c) |
| 705 | })() |
| 706 | |
| 707 | // active constraint gets removed |
| 708 | } |
| 709 | |
| 710 | function __eval_0_2 (constraint, __n) { |
| 711 | __n = __n || 0 |
| 712 | |
| 713 | ;(function () { |
| 714 | var _c = new Constraint("move", 0, [ ]) |
| 715 | _c.cont = [__move_0_0, 0] |
| 716 | stack.push(_c) |
| 717 | })() |
| 718 | |
| 719 | // active constraint gets removed |
| 720 | } |
| 721 | |
| 722 | function __start_0_0 (constraint, __n) { |
| 723 | __n = __n || 0 |
| 724 | |
| 725 | ;(function () { |
| 726 | var _c = new Constraint("x", 0, [ ]) |
| 727 | _c.cont = [__x_0_0, 0] |
| 728 | stack.push(_c) |
| 729 | })() |
| 730 | |
| 731 | ;(function () { |
| 732 | var _c = new Constraint("x", 0, [ ]) |
| 733 | _c.cont = [__x_0_0, 0] |
| 734 | stack.push(_c) |
| 735 | })() |
| 736 | |
| 737 | ;(function () { |
| 738 | var _c = new Constraint("x", 0, [ ]) |
| 739 | _c.cont = [__x_0_0, 0] |
| 740 | stack.push(_c) |
| 741 | })() |
| 742 | |
| 743 | ;(function () { |
| 744 | var _c = new Constraint("x", 0, [ ]) |
| 745 | _c.cont = [__x_0_0, 0] |
| 746 | stack.push(_c) |
| 747 | })() |
| 748 | |
| 749 | ;(function () { |
| 750 | var _c = new Constraint("x", 0, [ ]) |
| 751 | _c.cont = [__x_0_0, 0] |
| 752 | stack.push(_c) |
| 753 | })() |
| 754 | |
| 755 | ;(function () { |
| 756 | var _c = new Constraint("x", 0, [ ]) |
| 757 | _c.cont = [__x_0_0, 0] |
| 758 | stack.push(_c) |
| 759 | })() |
| 760 | |
| 761 | ;(function () { |
| 762 | var _c = new Constraint("x", 0, [ ]) |
| 763 | _c.cont = [__x_0_0, 0] |
| 764 | stack.push(_c) |
| 765 | })() |
| 766 | |
| 767 | ;(function () { |
| 768 | var _c = new Constraint("x", 0, [ ]) |
| 769 | _c.cont = [__x_0_0, 0] |
| 770 | stack.push(_c) |
| 771 | })() |
| 772 | |
| 773 | ;(function () { |
| 774 | var _c = new Constraint("x", 0, [ ]) |
| 775 | _c.cont = [__x_0_0, 0] |
| 776 | stack.push(_c) |
| 777 | })() |
| 778 | |
| 779 | ;(function () { |
| 780 | var _c = new Constraint("x", 0, [ ]) |
| 781 | _c.cont = [__x_0_0, 0] |
| 782 | stack.push(_c) |
| 783 | })() |
| 784 | |
| 785 | ;(function () { |
| 786 | var _c = new Constraint("x", 0, [ ]) |
| 787 | _c.cont = [__x_0_0, 0] |
| 788 | stack.push(_c) |
| 789 | })() |
| 790 | |
| 791 | ;(function () { |
| 792 | var _c = new Constraint("x", 0, [ ]) |
| 793 | _c.cont = [__x_0_0, 0] |
| 794 | stack.push(_c) |
| 795 | })() |
| 796 | |
| 797 | ;(function () { |
| 798 | var _c = new Constraint("eval", 0, [ ]) |
| 799 | _c.cont = [__eval_0_0, 0] |
| 800 | stack.push(_c) |
| 801 | })() |
| 802 | |
| 803 | // active constraint gets removed |
| 804 | } |
| 805 | |
| 806 | function __move_0_3 (constraint) { |
| 807 | constraint.cont = null |
| 808 | chr.Store.add(constraint) |
| 809 | } |
| 810 | |
| 811 | function __y_0_2 (constraint) { |
| 812 | constraint.cont = null |
| 813 | chr.Store.add(constraint) |
| 814 | } |
| 815 | |
| 816 | function __x_0_6 (constraint) { |
| 817 | constraint.cont = null |
| 818 | chr.Store.add(constraint) |
| 819 | } |
| 820 | |
| 821 | function __eval_0_3 (constraint) { |
| 822 | constraint.cont = null |
| 823 | chr.Store.add(constraint) |
| 824 | } |
| 825 | |
| 826 | function __odd_0_2 (constraint) { |
| 827 | constraint.cont = null |
| 828 | chr.Store.add(constraint) |
| 829 | } |
| 830 | |
| 831 | function __start_0_1 (constraint) { |
| 832 | constraint.cont = null |
| 833 | chr.Store.add(constraint) |
| 834 | } |
| 835 | |
| 836 | function move () { |
| 837 | var args = Array.prototype.slice.call(arguments) |
| 838 | var arity = arguments.length |
| 839 | var functor = "move/" + arity |
| 840 | var constraint = new Constraint("move", arity, args) |
| 841 | if (arity === 0) { |
| 842 | constraint.cont = [__move_0_0, ] |
| 843 | } else { |
| 844 | throw new Error("Undefined constraint: " + functor) |
| 845 | } |
| 846 | stack.push(constraint) |
| 847 | |
| 848 | trampoline() |
| 849 | } |
| 850 | |
| 851 | function y () { |
| 852 | var args = Array.prototype.slice.call(arguments) |
| 853 | var arity = arguments.length |
| 854 | var functor = "y/" + arity |
| 855 | var constraint = new Constraint("y", arity, args) |
| 856 | if (arity === 0) { |
| 857 | constraint.cont = [__y_0_0, ] |
| 858 | } else { |
| 859 | throw new Error("Undefined constraint: " + functor) |
| 860 | } |
| 861 | stack.push(constraint) |
| 862 | |
| 863 | trampoline() |
| 864 | } |
| 865 | |
| 866 | function x () { |
| 867 | var args = Array.prototype.slice.call(arguments) |
| 868 | var arity = arguments.length |
| 869 | var functor = "x/" + arity |
| 870 | var constraint = new Constraint("x", arity, args) |
| 871 | if (arity === 0) { |
| 872 | constraint.cont = [__x_0_0, ] |
| 873 | } else { |
| 874 | throw new Error("Undefined constraint: " + functor) |
| 875 | } |
| 876 | stack.push(constraint) |
| 877 | |
| 878 | trampoline() |
| 879 | } |
| 880 | |
| 881 | function eval () { |
| 882 | var args = Array.prototype.slice.call(arguments) |
| 883 | var arity = arguments.length |
| 884 | var functor = "eval/" + arity |
| 885 | var constraint = new Constraint("eval", arity, args) |
| 886 | if (arity === 0) { |
| 887 | constraint.cont = [__eval_0_0, ] |
| 888 | } else { |
| 889 | throw new Error("Undefined constraint: " + functor) |
| 890 | } |
| 891 | stack.push(constraint) |
| 892 | |
| 893 | trampoline() |
| 894 | } |
| 895 | |
| 896 | function odd () { |
| 897 | var args = Array.prototype.slice.call(arguments) |
| 898 | var arity = arguments.length |
| 899 | var functor = "odd/" + arity |
| 900 | var constraint = new Constraint("odd", arity, args) |
| 901 | if (arity === 0) { |
| 902 | constraint.cont = [__odd_0_0, ] |
| 903 | } else { |
| 904 | throw new Error("Undefined constraint: " + functor) |
| 905 | } |
| 906 | stack.push(constraint) |
| 907 | |
| 908 | trampoline() |
| 909 | } |
| 910 | |
| 911 | function start () { |
| 912 | var args = Array.prototype.slice.call(arguments) |
| 913 | var arity = arguments.length |
| 914 | var functor = "start/" + arity |
| 915 | var constraint = new Constraint("start", arity, args) |
| 916 | if (arity === 0) { |
| 917 | constraint.cont = [__start_0_0, ] |
| 918 | } else { |
| 919 | throw new Error("Undefined constraint: " + functor) |
| 920 | } |
| 921 | stack.push(constraint) |
| 922 | |
| 923 | trampoline() |
| 924 | } |
| 925 | |
| 926 | chr.move = move |
| 927 | chr.y = y |
| 928 | chr.x = x |
| 929 | chr.eval = eval |
| 930 | chr.odd = odd |
| 931 | chr.start = start |
| 932 | |
| 933 | return chr |
| 934 | })() |
| 935 |