MCPcopy Create free account
hub / github.com/mozilla/rhino / endCheckLoop

Method endCheckLoop

rhino/src/main/java/org/mozilla/javascript/Node.java:799–823  ·  view source on GitHub ↗

Return statement in the loop body must be consistent. The default assumption for any kind of a loop is that it will eventually terminate. The only exception is a loop with a constant true condition. Code that follows such a loop is examined only if one can statically determine that there is a break

()

Source from the content-addressed store, hash-verified

797 * @return logical OR of END_* flags
798 */
799 private int endCheckLoop() {
800 Node n;
801 int rv = END_UNREACHED;
802
803 // To find the loop body, we look at the second to last node of the
804 // loop node, which should be the predicate that the loop should
805 // satisfy.
806 // The target of the predicate is the loop-body for all 4 kinds of
807 // loops.
808 for (n = first; n.next != last; n = n.next) {
809 /* skip */
810 }
811 if (n.type != Token.IFEQ) return END_DROPS_OFF;
812
813 // The target's next is the loop body block
814 rv = ((Jump) n).target.next.endCheck();
815
816 // check to see if the loop condition is true
817 if (n.first.type == Token.TRUE) rv &= ~END_DROPS_OFF;
818
819 // look for effect of breaks
820 rv |= getIntProp(CONTROL_BLOCK_PROP, END_UNREACHED);
821
822 return rv;
823 }
824
825 /**
826 * A general block of code is examined statement by statement. If any statement (even compound

Callers 1

endCheckMethod · 0.95

Calls 2

getIntPropMethod · 0.95
endCheckMethod · 0.80

Tested by

no test coverage detected