public Object executeLoop( RArray array, Selector selectorI, Selector selectorJ, boolean dropVal, int exactVal) { Selector selI = selectorI; Selector selJ = selectorJ; for (; ; ) { try { return execute(array, selI, selJ, dropVal, exactVal); } catch (UnexpectedResultException e) { Selector failedSelector = (Selector) e.getResult(); if (failedSelector == selI) { RAny index = selI.getIndex(); selectorIExpr.replace( Selector.createSelectorNode( ast, subset, index, selectorIExpr.child, false, selectorI.getTransition())); selI = selectorIExpr.executeSelector(index); } else { // failedSelector == selectorJ RAny index = selJ.getIndex(); selectorJExpr.replace( Selector.createSelectorNode( ast, subset, index, selectorJExpr.child, false, selectorJ.getTransition())); selJ = selectorJExpr.executeSelector(index); } } } }
/** * Execute method which evaluates the lhs, selectors and optional expressions, checks that the * array selection can proceed and then proceeds optionally replacing the falling selectors. * * <p>The valued variant of execute is called for the production of the result, on failure the * responsible selector is replaced and the valued variant is called again. */ protected final Object executeLoop(RArray array, boolean dropVal, int exactVal) { while (true) { try { return execute(array, dropVal, exactVal); } catch (UnexpectedResultException e) { Selector failedSelector = (Selector) e.getResult(); for (int i = 0; i < selectorVals.length; ++i) { if (selectorVals[i] == failedSelector) { RAny index = failedSelector.getIndex(); SelectorNode newSelector = Selector.createSelectorNode( ast, subset, index, selectorExprs[i], false, failedSelector.getTransition()); selectorExprs[i] = adoptChild(newSelector); selectorVals[i] = newSelector.executeSelector(index); } } } } }