/** * Creates a traversable state for the specified label term. * * @param labelTerm The label term to create a traversable state for. */ public LabelState(Functor labelTerm) { this.labelTerm = labelTerm; labelPath = new String[] { ((StringLiteral) labelTerm.getArgument(0)).stringValue() }; isLeaf = labelTerm.getArity() <= 1; }
/** * Creates a traversable state for the specified label term. * * @param labelTerm The label term to create a traversable state for. * @param labelPath The label path of the parent state, that this state extends with a child label. */ private LabelState(Functor labelTerm, String[] labelPath) { this.labelTerm = labelTerm; this.labelPath = Arrays.copyOf(labelPath, labelPath.length + 1); this.getLabelPath()[labelPath.length] = ((StringLiteral) labelTerm.getArgument(0)).stringValue(); isLeaf = labelTerm.getArity() <= 1; }
Term termToExtract = op.getArgument(0); nextTerm = op.getArgument(1);
Term termToExtract = op.getArgument(0); nextTerm = op.getArgument(1);
/** {@inheritDoc} */ public boolean proofStep(ResolutionState state) { Functor isOp = state.getGoalStack().poll().getFunctor(); // Evaluate both sides of the comparison, checking that they are fully instantiated numbers. NumericType n1 = BuiltInUtils.evaluateAsNumeric(isOp.getArgument(0)); NumericType n2 = BuiltInUtils.evaluateAsNumeric(isOp.getArgument(1)); // Evaluate the comparison operator. return evaluate(n1, n2); }
/** * {@inheritDoc} * * <p/>Checks if the label term has more than one argument, and for each child label argument creates an * operator leadning to a new state for that child label. */ public Iterator<Operator<LabelState>> validOperators(boolean reverse) { // Check if the label has any child labels. if (!isLeaf) { List<Operator<LabelState>> childLabels = new LinkedList<Operator<LabelState>>(); for (int i = 1; i < labelTerm.getArity(); i++) { childLabels.add(new OperatorImpl<LabelState>( new LabelState((Functor) labelTerm.getArgument(i), labelPath))); } return childLabels.iterator(); } else { return new EmptyIterator<Operator<LabelState>>(); } }
Term termToExtract = op.getArgument(0); nextTerm = op.getArgument(1);
Term termToExtract = op.getArgument(0); nextTerm = op.getArgument(1);
/** {@inheritDoc} */ public boolean proofStep(ResolutionState state) { Functor isOp = state.getGoalStack().poll().getFunctor(); // Evaluate the second argument as a fully instantiated numeric value. Term expressionValue = BuiltInUtils.evaluateAsNumeric(isOp.getArgument(1)); // This is used to record variables bound during the unification, so that they may be undone if the resolution // state is backtracked over. List<Variable> boundVariables = new LinkedList<Variable>(); // Unify against the LHS. boolean matched = state.getUnifier().unifyInternal(isOp.getArgument(0), expressionValue, boundVariables, boundVariables); for (Variable binding : boundVariables) { state.getVariableBindings().offer(binding); } return matched; } }
Term leftArg = goalTerm.getArgument(0); Term rightArg = goalTerm.getArgument(1);
String fieldName = engine.getFunctorName((Functor) fieldFunctor.getArgument(0)); String fieldTypeName = engine.getFunctorName((Functor) fieldFunctor.getArgument(1)); Term presentAsTerm = fieldFunctor.getArgument(2).getValue(); String fieldName = engine.getFunctorName((Functor) fieldFunctor.getArgument(0)); String fieldTypeName = engine.getFunctorName((Functor) fieldFunctor.getArgument(1)); Functor collectionKindFunctor = (Functor) fieldFunctor.getArgument(0).getValue(); String collectionKindName = engine.getFunctorName(collectionKindFunctor); String fieldName = engine.getFunctorName((Functor) fieldFunctor.getArgument(1).getValue()); String fieldTypeName = engine.getFunctorName((Functor) ((Functor) fieldFunctor.getArgument(2).getValue()).getArgument(1) .getValue()); engine.getFunctorName((Functor) collectionKindFunctor.getArgument(0).getValue());
Term firstGoalArg = goal.getFunctor().getArgument(index); Term firstClauseArg = clause.getHead().getArgument(index);
Term term = expression.getArgument(reg);
/** {@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. return argument.isNumber() && ((NumericType) argument.getValue()).isReal(); } }
/** {@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. return argument.isNumber() && ((NumericType) argument.getValue()).isInteger(); } }
/** {@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; } }
Term leftArgument = leftFunctor.getArgument(i); Term rightArgument = rightFunctor.getArgument(i);
Term leftArgument = leftFunctor.getArgument(i); Term rightArgument = rightFunctor.getArgument(i);
Term nextArg = nextFunctor.getArgument(i); allocation = (Integer) symbolTable.get(nextArg.getSymbolKey(), SymbolTableKeys.SYMKEY_ALLOCATION); addrMode = (byte) ((allocation & 0xff00) >> 8);
Term nextOutermostArg = expression.getArgument(j); int allocation = (Integer) symbolTable.get(nextOutermostArg.getSymbolKey(), SymbolTableKeys.SYMKEY_ALLOCATION); Term nextArg = nextFunctor.getArgument(i); allocation = (Integer) symbolTable.get(nextArg.getSymbolKey(), SymbolTableKeys.SYMKEY_ALLOCATION);