示例#1
0
 public override Node MakeNode(PrologMachine pm)
 {
     if (Functor is Primitive)
     {
         return(new PrimitiveNode(pm, this));
     }
     return(new FactNode(this, pm));
 }
示例#2
0
 public override PrologObject Evaluate(PrologMachine pm)
 {
     if (Functor is Primitive)
     {
         return(((Primitive)(Functor)).Evaluate(pm, this));
     }
     return(this);
 }
示例#3
0
        public override bool Execute(PrologMachine pm, PrologObject[] pars)
        {
            if (pars == null || pars.Length != 1)
            {
                throw new ArgumentException("IntegerPrimitive expects one argument");
            }

            return(Utilities.IsInteger(pars[0]));
        }
示例#4
0
        public override bool Execute(PrologMachine pm, PrologObject[] pars)
        {
            if (pars == null || pars.Length != 2)
            {
                throw new ArgumentException("EqualPrimitive expects two arguments");
            }

            return(pm.Unify(pars[0], pars[1]));
        }
示例#5
0
 public override bool Execute(PrologMachine pm, params PrologObject[] pars)
 {
     if (pars == null || pars.Length != 2)
     {
         throw new ArgumentException("AndPrimitive expects two arguments");
     }
     Add(pm, pars[1]);
     Add(pm, pars[0]);
     return(true);
 }
示例#6
0
 private void Add(PrologMachine pm, PrologObject po)
 {
     if (po is StructureObject && ((StructureObject)(po)).Functor == this)
     {
         StructureObject ast = ((StructureObject)(po));
         Add(pm, ast.Parameters[1]);
         Add(pm, ast.Parameters[0]);
     }
     else
     {
         pm.PushPending(po);
     }
 }
示例#7
0
        public StructureObject(StructureObject st, PrologMachine pm, ArrayList vars, int offset)
        {
            this.functor = pm.AdjustVariables(st.Functor, vars, offset);

            if (st.Arity == 0)
            {
                this.parameters = null;
            }
            else
            {
                this.parameters = new PrologObject[st.Arity];
            }

            for (int np = 0; np <= st.Arity - 1; np++)
            {
                this.parameters[np] = pm.AdjustVariables(st.Parameters[np], vars, offset);
            }
        }
示例#8
0
 public AndNode(PrologMachine pm, StructureObject st)
     : base(pm, st)
 {
 }
示例#9
0
 public AndNode(PrologMachine pm, Primitive obj)
     : base(pm, obj)
 {
 }
示例#10
0
 public Node(PrologMachine mach, PrologObject obj)
 {
     mMachine = mach;
     mObject  = obj;
 }
示例#11
0
 public override bool Execute(PrologMachine pm, PrologObject[] pars)
 {
     return(true);
 }
示例#12
0
 public virtual PrologObject Evaluate(PrologMachine pm)
 {
     return(this);
 }
示例#13
0
 public override Node MakeNode(PrologMachine pm)
 {
     return(new PrimitiveStatusNode(pm, this));
 }
 public PrimitiveStatusNode(PrologMachine pm, StructureObject st)
     : base(pm, st)
 {
 }
示例#15
0
 public virtual PrologObject Evaluate(PrologMachine pm, StructureObject st)
 {
     return(st);
 }
示例#16
0
 public virtual bool Execute(PrologMachine pm, params PrologObject[] parameters)
 {
     return(true);
 }
示例#17
0
 public Variable(int id, PrologMachine mach)
 {
     this.id      = id;
     this.machine = mach;
 }
示例#18
0
 public override PrologObject Evaluate(PrologMachine pm)
 {
     return(this.Dereference());
 }
示例#19
0
 public override Node MakeNode(PrologMachine pm)
 {
     return(new AndNode(pm, this));
 }
示例#20
0
 public PrimitiveNode(PrologMachine pm, StructureObject st)
     : base(pm, st)
 {
     primitive  = ((Primitive)(st.Functor));
     parameters = st.Parameters;
 }
示例#21
0
 public virtual Node MakeNode(PrologMachine pm)
 {
     return(new FactNode(this, pm));
 }
示例#22
0
 public PrimitiveNode(PrologMachine pm, Primitive obj)
     : base(pm, obj)
 {
     primitive  = obj;
     parameters = null;
 }
 public PrimitiveStatusNode(PrologMachine pm, Primitive obj)
     : base(pm, obj)
 {
 }
示例#24
0
 public FactNode(PrologObject obj, PrologMachine mach)
     : base(mach, obj)
 {
 }