public override Node MakeNode(PrologMachine pm) { if (Functor is Primitive) { return(new PrimitiveNode(pm, this)); } return(new FactNode(this, pm)); }
public override PrologObject Evaluate(PrologMachine pm) { if (Functor is Primitive) { return(((Primitive)(Functor)).Evaluate(pm, this)); } return(this); }
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])); }
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])); }
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); }
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); } }
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); } }
public AndNode(PrologMachine pm, StructureObject st) : base(pm, st) { }
public AndNode(PrologMachine pm, Primitive obj) : base(pm, obj) { }
public Node(PrologMachine mach, PrologObject obj) { mMachine = mach; mObject = obj; }
public override bool Execute(PrologMachine pm, PrologObject[] pars) { return(true); }
public virtual PrologObject Evaluate(PrologMachine pm) { return(this); }
public override Node MakeNode(PrologMachine pm) { return(new PrimitiveStatusNode(pm, this)); }
public PrimitiveStatusNode(PrologMachine pm, StructureObject st) : base(pm, st) { }
public virtual PrologObject Evaluate(PrologMachine pm, StructureObject st) { return(st); }
public virtual bool Execute(PrologMachine pm, params PrologObject[] parameters) { return(true); }
public Variable(int id, PrologMachine mach) { this.id = id; this.machine = mach; }
public override PrologObject Evaluate(PrologMachine pm) { return(this.Dereference()); }
public override Node MakeNode(PrologMachine pm) { return(new AndNode(pm, this)); }
public PrimitiveNode(PrologMachine pm, StructureObject st) : base(pm, st) { primitive = ((Primitive)(st.Functor)); parameters = st.Parameters; }
public virtual Node MakeNode(PrologMachine pm) { return(new FactNode(this, pm)); }
public PrimitiveNode(PrologMachine pm, Primitive obj) : base(pm, obj) { primitive = obj; parameters = null; }
public PrimitiveStatusNode(PrologMachine pm, Primitive obj) : base(pm, obj) { }
public FactNode(PrologObject obj, PrologMachine mach) : base(mach, obj) { }