// The constructor. internal Wam() { _h = _hb = new Address(_heap, 0); _a = new Area("A", 9); _p = new Address(_code, 0); _b = new Address(_stack, 0); _b[0] = new ChoicePoint(0, null, null, null, null, null, null, null); _e = _b + 1; _e[0] = new Environment(0, null, null); _tr = new Address(_trail, 0); }
internal void RetryMeElse(Address L) { ChoicePoint b_ = (ChoicePoint)_b._cell; uint n = b_._n; for (uint i = 1; i <= n; i++) { _a[i] = _b[i]; } _e = b_._ce; _cp = b_._cp; b_._bp = L; UnwindTrail(b_._tr._address, _tr._address); _tr = b_._tr; _h = b_._h; _hb = _h; }
internal void TrustMe() { ChoicePoint b_ = (ChoicePoint)_b._cell; uint n = b_._n; for (uint i = 1; i <= n; i++) { _a[i] = _b[i]; } _e = b_._ce; _cp = b_._cp; UnwindTrail(b_._tr._address, _tr._address); _tr = b_._tr; _h = b_._h; _b = b_._b; _hb = ((ChoicePoint)_b._cell)._hb; }
// Choice instructions. There are no indexing instructions, // so try, retry, and trust are unimplemented. internal void TryMeElse(Address L, uint n) { Address b; if (Greater(_e, _b)) { b = _e + 1 + ((Environment)_e._cell)._n; } else { b = _b + 1 + ((ChoicePoint)_b._cell)._n; } ChoicePoint b_ = new ChoicePoint(n, _e, _cp, _b, L, _tr, _h, _hb); b._cell = b_; for (uint i = 1; i <= n; i++) { b[i] = _a[i]; } _b = b; _hb = _h; }