/** * Initialize the choice point state. * * @param interpreter the parent interpreter whose state is to be preserved here, its arg stack * defines the parameters for the target goal */ @Override public void init(LPInterpreter interpreter) { super.init(interpreter); context = interpreter.getContext(); generator = interpreter.getEngine().generatorFor(goal); generator.addConsumer(this); resultIndex = 0; }
/** Restore the state of an interpreter from this frame */ public void restoreState(LPInterpreter interp) { interp.unwindTrail(0); for (int i = 0; i < trailLength; i++) { interp.bind(trailVars[i], trailValues[i]); } if (pVars != null) { System.arraycopy(pVars, 0, envFrame.pVars, 0, pVars.length); } }
/** Return a safe copy of the list of matched subgoals in this subderivation. */ public List<Triple> getMatchList() { ArrayList<Triple> matchList = new ArrayList<>(); for (TriplePattern matche : matches) { matchList.add(LPInterpreter.deref(matche)); } return matchList; }
/** Return the final instantiated goal given the current binding state. */ public Triple getResult() { return new Triple( LPInterpreter.deref(argVars[0]), LPInterpreter.deref(argVars[1]), LPInterpreter.derefPossFunctor(argVars[2])); }