/** Updates the stack
* @return true if another element is ready for execution
*/
public boolean updateElementStack(ExecutionContext executionContext) {
ElementTree tree = executionContext.getExecutor().getExecutionTree();
// push the root element onto the stack if the stack is empty
if (tree.getElementStack().isEmpty()) {
tree.pushElement(tree.getRootElement());
ElementUtils.initialize(tree.getRootElement());
}
// make sure we don't loop forever
int x=0;
while (x < 100) {
if (isTopExecutable(tree)) {
return true;
}
else if (runTopSelectors(executionContext, tree)) {
continue;
}
else if (hasTemporaryElement(tree)) {
continue;
}
/*else if (isTopMarkedForReexecution(tree)) {
return true;
}*/
// top element is used, pop it from the stack
else {
tree.popElement();
// check whether the whole tree has been executed
if (tree.getElementStack().isEmpty()) {
return false;
}
}
}
// remove the Execution outcome property if set
Misc.getOutcomeProperty().clearValue(executionContext);
// ensure that the top element contains an executable element
Element top = tree.getTop();
return top != null && top.getExecutable() != null;
}