Esempio n. 1
0
        public override void Execute(AbstractMachineState state)
        {
            AMPredicateSet pset = AMPredicateSet.Instance;

            if (pset.IsValidPredicate(_builtinName))
            {
                IAbstractMachinePredicate p = (IAbstractMachinePredicate)pset.CreatePredicate(_builtinName);
                // determine if p is a non-deterministic predicate
                Type pType = p.GetType();
                if (pType.IsInstanceOfType(new AbstractNonDeterministicPredicate()))
                {
                    ((AbstractNonDeterministicPredicate)p).IncrementCallID();
                }
                p.Execute(state);
            }
        }
        public void assertz_1()
        {
            AMPredicateSet set = AMPredicateSet.Instance;

            AbstractMachineState state = SetupMachine();

            IAbstractMachinePredicate pred = set.CreatePredicate("assertz/1");

            AbstractTerm X0 = (AbstractTerm)state["X0"];

            X0.Assign(new ConstantTerm("it_is_sunny"));

            Assert.AreEqual("assertz", pred.Name());
            Assert.AreEqual(1, pred.Arity());

            pred.Execute(state);

            AMProgram program = (AMProgram)state.Program;

            Assert.IsNotNull(program["it_is_sunny/0"]);
        }