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"]);
        }
        private void InstallExternalPredicates()
        {
            AMPluginManager p = new AMPluginManager();

            foreach (ExternalPredicate e in p.Plugins)
            {
                IAbstractMachinePredicate predicate = LoadExternalPredicate(e.Path, e.Name);
                if (predicate == null)
                {
                    throw new Exception("Remote predicate " + e.Name + " does not implement correct interface.");
                }

                if (!e.Name.Equals(predicate.Name() + "/" + predicate.Arity().ToString()))
                {
                    throw new Exception("Cannot install corrupted remote predicate: " + e.Name);
                }

                // Add new external predicate
                _predicates[e.Name] = predicate;
            }
        }
Beispiel #3
0
 public void EmitBCall(IAbstractMachinePredicate pred)
 {
     _instructions.Add(_instructionSet.CreateInstruction("bcall", pred.Name() + "/" + pred.Arity()));
 }
 public void EmitBCall(IAbstractMachinePredicate pred)
 {
     _instructions.Add(_instructionSet.CreateInstruction("bcall", pred.Name() + "/" + pred.Arity()));
 }