/** * Determine whether a term is a functor. * * @param term The term to examine. * * @return <tt>true</tt> if the term is a functor, <tt>false</tt> if it is not. */ public boolean evaluate(Term term) { return term.isFunctor(); } }
/** * Determine whether a term is a functor. * * @param term The term to examine. * * @return <tt>true</tt> if the term is a functor, <tt>false</tt> if it is not. */ public boolean evaluate(Term term) { return term.isFunctor(); } }
/** * Creates an instruction for the specified mnemonic that takes a single register argument. * * @param mnemonic The instruction mnemonic. * @param mode1 The addressing mode to use with the register argument. * @param reg1 The single register argument. * @param reg1Term The term that is assigned or associated with reg1. */ public WAMInstruction(WAMInstructionSet mnemonic, byte mode1, byte reg1, Term reg1Term) { this.mnemonic = mnemonic; this.mode1 = mode1; this.reg1 = reg1; // Record the symbol keys of the term that resulted in the creation of the instruction, and are associated // with reg1 of the instruction. symbolKeyReg1 = reg1Term.getSymbolKey(); functorNameReg1 = reg1Term.isFunctor() ? ((Functor) reg1Term).getName() : null; }
/** * Creates an instruction for the specified mnemonic that takes one register and one functor argument. * * @param mnemonic The instruction mnemonic. * @param mode1 The addressing mode to use with the register argument. * @param reg1 The register argument. * @param fn The functor argument. * @param reg1Term The term that is assigned or associated with reg1. */ public WAMInstruction(WAMInstructionSet mnemonic, byte mode1, byte reg1, FunctorName fn, Term reg1Term) { this.mnemonic = mnemonic; this.mode1 = mode1; this.reg1 = reg1; this.fn = fn; // Record the symbol keys of the term that resulted in the creation of the instruction, and are associated // with reg1 of the instruction. symbolKeyReg1 = reg1Term.getSymbolKey(); functorNameReg1 = reg1Term.isFunctor() ? ((Functor) reg1Term).getName() : null; }
/** {@inheritDoc} */ public boolean proofStep(ResolutionState state) { Functor goalTerm = state.getGoalStack().poll().getFunctor(); Term argument = goalTerm.getArgument(0).getValue(); // Check that the argument is not a free variable. if (argument.isVar()) { throw new IllegalStateException( "instantiation_error, 'call' expects a fully instantiated term to unify against."); } // Check that the argument is callable. if (!argument.isFunctor() && !argument.isAtom()) { throw new IllegalStateException("type_error, callable expected as argument to 'call'."); } // Set up the argument to call as a new goal. state.getGoalStack().offer(state.getBuiltInTransform().apply((Functor) argument)); return true; } }
if (nextTerm.isFunctor())
else if (nextOutermostArg.isFunctor())