private void CompileBuiltinPredicateCall(PrologCodePredicate p)
        {
            AMPredicateSet pset = AMPredicateSet.Instance;

            _generator.EmitBCall((IAbstractMachinePredicate)pset.CreatePredicate(p.Name, p.Arity));

            if (_dictionary.InLastGoal)
            {
                if (_dictionary.GoalCount > 2)
                {
                    _generator.Emit(OpCodes.Deallocate);
                }
                // Emit 'proceed'
                _generator.EndProcedure();
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
        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"]);
        }