Backtrack() public method

public Backtrack ( ) : void
return void
Esempio n. 1
0
        public override void Execute(AbstractMachineState state)
        {
            AMProgram prog = (AMProgram)state.Program;

            AbstractTerm X0 = ((AbstractTerm)state["X0"]).Dereference();
            AbstractTerm X1 = ((AbstractTerm)state["X1"]).Dereference();

            if (!X0.IsConstant)
            {
                Console.WriteLine("Invalid class type of object/2");
                state.Backtrack();
            }

            if (X1.IsConstant)
            {
                Console.WriteLine("object/2: object instantiation error.");
                state.Backtrack();
            }

            if (CreateObject(X0.Data() as string, X1, state))
            {
                prog.Next();
            }
            else
            {
                state.Backtrack();
            }
        }
        public void Backtrack()
        {
            AbstractMachineState state = new AbstractMachineState(new AMFactory());
            AMProgram program = (AMProgram)state.Program;

            state.Backtrack();
            Assert.IsNotNull(program.P);

            ProgramClause nextClause = new ProgramClause();

            state.B = new Choicepoint(2, null, null, null, nextClause, 3, null);

            state.Backtrack();

            Assert.AreSame(program.P, nextClause);
        }
Esempio n. 3
0
        public override void Execute(AbstractMachineState state)
        {
            AMProgram prog = (AMProgram)state.Program;

            runtime = state;
            // invoke(+ClassObj,+meth(+x..),-Return).
            AbstractTerm X0 = (state["X0"] as AbstractTerm).Dereference();
            AbstractTerm X1 = (state["X1"] as AbstractTerm).Dereference();
            AbstractTerm X2 = (state["X2"] as AbstractTerm).Dereference();

            if (Getproperty(X0, X1, X2))
            {
                prog.Next();
            }
            else
            {
                state.Backtrack();
            }
        }