public override void Execute(AbstractMachineState state)
        {
            AMProgram program = (AMProgram)state.Program;

            AbstractTerm Ai = ((AbstractTerm)state[_ai]).Dereference();

            if (Ai.IsReference)
            {
                Ai.Assign(new ConstantTerm(_constant));
                AMTrail trail = (AMTrail)state.Trail;
                trail.Trail(Ai);
            }
            else if (Ai.IsConstant)
            {
                state.Fail = ((string)Ai.Data() != _constant);
            }
            else
            {
                state.Fail = true;
            }

            if (state.Fail)
            {
                state.Backtrack();
            }
            else
            {
                program.Next();
            }
        }
Exemple #2
0
        public void Trail()
        {
            AMTrail trail = AMTrail.Instance;

            AbstractTerm term = new AbstractTerm();

            trail.Initialize();
            trail.Trail(term);

            Assert.AreEqual(1, trail.TR);
        }
Exemple #3
0
        public override void Execute(AbstractMachineState state)
        {
            AMProgram program = (AMProgram)state.Program;
            AMHeap    heap    = (AMHeap)state.DataArea;
            AMTrail   trail   = (AMTrail)state.Trail;

            if (state.IsReadMode)
            {
                AbstractTerm addr = ((AbstractTerm)state.S).Dereference();
                state.S = state.S.Next;
                if (addr.IsReference)
                {
                    addr.Assign(new ConstantTerm(_constant));
                    trail.Trail(addr);
                }
                else if (addr.IsConstant)
                {
                    state.Fail = !_constant.Equals(addr.Data());
                }
                else
                {
                    state.Fail = true;
                }
            }
            else
            {
                heap.Push(new ConstantTerm(_constant));
            }

            if (state.Fail)
            {
                state.Backtrack();
            }
            else
            {
                program.Next();
            }
        }