/** {@inheritDoc} */ public String getFunctorName(Functor functor) { return getFunctorName(functor.getName()); }
/** {@inheritDoc} */ public String getFunctorName(Functor functor) { return getFunctorName(functor.getName()); }
/** {@inheritDoc} */ public FunctorName getFunctorFunctorName(Functor functor) { return getDeinternedFunctorName(functor.getName()); }
/** {@inheritDoc} */ public int getFunctorArity(Functor functor) { return getFunctorArity(functor.getName()); } }
/** {@inheritDoc} */ public void addToDomain(PrologCompiledClause term) { List<PrologCompiledClause> predicate = domain.get(term.getHead().getName()); if (predicate == null) { predicate = new LinkedList<PrologCompiledClause>(); domain.put(term.getHead().getName(), predicate); } predicate.add(term); }
/** * Creates a built-in for the specified functor. * * @param functor The functor to create a built-in for. */ public BuiltInFunctor(Functor functor) { super(functor.getName(), functor.getArguments()); this.functor = functor; }
/** * Creates a cut built-in to implement the specified functor. * * @param functor The functor to implement as a built-in. * @param defaultBuiltIn The default built in, for standard compilation and interners and symbol tables. */ public Cut(Functor functor, DefaultBuiltIn defaultBuiltIn) { // Here the cut functor is transformed from ! to !(Y), where Y is a level variable that may be needed // to hold the current choice point. super(new Functor(functor.getName(), new Term[] { CutLevelVariable.CUT_LEVEL_VARIABLE }), defaultBuiltIn); }
/** {@inheritDoc} */ public int getFunctorArity(Functor functor) { return getFunctorArity(functor.getName()); } }
/** {@inheritDoc} */ public FunctorName getFunctorFunctorName(Functor functor) { return getDeinternedFunctorName(functor.getName()); }
/** * 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; }
/** * Applies a built-in replacement transformation to functors. If the functor matches built-in, a * {@link BuiltInFunctor} is created with a mapping to the functors built-in implementation, and the functors * arguments are copied into this new functor. If the functor does not match a built-in, it is returned unmodified. * * @param functor The functor to attempt to map onto a built-in. * * @return The functor umodified, or a {@link BuiltInFunctor} replacement for it. */ public Functor transform(Functor functor) { FunctorName functorName = interner.getFunctorFunctorName(functor); if (builtInExpressions.containsKey(functorName)) { Class<? extends Functor> builtInExpressionClass = builtInExpressions.get(functorName); return ReflectionUtils.newInstance(ReflectionUtils.getConstructor(builtInExpressionClass, new Class[] { Integer.TYPE, Term[].class }), new Object[] { functor.getName(), functor.getArguments() }); } else { return functor; } } }
result = new WAMCompiledPredicate(clause.getHead().getName());
SymbolKey predicateKey = scopeTable.getSymbolKey(clause.getHead().getName()); Collection<Clause> clauseList = (List<Clause>) scopeTable.get(predicateKey, SymbolTableKeys.SYMKEY_PREDICATES);
List<PrologCompiledClause> predicate = domain.get(goal.getFunctor().getName());
predicateName = head.getName();
predicateName = head.getName();
/** * Evaluates a query against the resolver or adds a clause to the resolvers domain. * * @param sentence The clausal sentence to run as a query or as a clause to add to the domain. * * @throws SourceCodeException If the query or domain clause fails to compile or link into the resolver. */ private void evaluate(Sentence<Clause> sentence) throws SourceCodeException { Clause clause = sentence.getT(); if (clause.isQuery()) { engine.endScope(); engine.compile(sentence); evaluateQuery(); } else { // Check if the program clause is new, or a continuation of the current predicate. int name = clause.getHead().getName(); if ((currentPredicateName == null) || (currentPredicateName != name)) { engine.endScope(); currentPredicateName = name; } addProgramClause(sentence); } }