public void PopGoal(Frame th) { bt = new Choice(bt, -1, st); bt.st.subrule_iter = th.LexicalFind("$*GOAL"); th.LexicalBind("$*GOAL", (Variable)st.ns.cut_to.st.subrule_iter); st.ns = st.ns.next; }
public void PushGoal(Frame th, string newGoal) { bt = new Choice(bt, -1, st); bt.st.subrule_iter = th.LexicalFind("$*GOAL"); th.LexicalBind("$*GOAL", Builtins.MakeStr(newGoal)); st.ns = new NState(bt, "GOAL", st.ns); st.ns.quant = st.pos; }
public Frame Backtrack(Frame th) { // throw away cut or mark-only frames while (bt != rootf && (bt.ip < 0)) { if (bt.ip == -1) { // Special frame that does $*GOAL cleanup ... th.LexicalBind("$*GOAL", (Variable)bt.st.subrule_iter); } bt = bt.prev; } if (st.pos > global.highwater) global.IncHighwater(st.pos); if (bt == rootf) { if ((flags & RETURN_ONE) != 0) { if (Cursor.Trace) Console.WriteLine("Failing {0}@{1} after no matches", name, from); return Kernel.Take(th, Kernel.NewROScalar(Kernel.EMPTYP)); } else { if (Cursor.Trace) Console.WriteLine("Failing {0}@{1} after some matches", name, from); if (EmptyList == null) { P6opaque lst = new P6opaque(Kernel.ListMO); lst.slots[0 /*items*/] = new VarDeque(); lst.slots[1 /*rest*/ ] = new VarDeque(); EmptyList = Kernel.NewRWListVar(lst); } th.caller.resultSlot = EmptyList; } return th.Return(); } else { th.ip = bt.ip; st = bt.st; bt = bt.prev; return th; } }