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

Method breakStatement

rhino/src/main/java/org/mozilla/javascript/Parser.java:2131–2164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2129 }
2130
2131 private BreakStatement breakStatement() throws IOException {
2132 if (currentToken != Token.BREAK) codeBug();
2133 consumeToken();
2134 int lineno = lineNumber(), pos = ts.tokenBeg, end = ts.tokenEnd, column = columnNumber();
2135 Name breakLabel = null;
2136 if (peekTokenOrEOL() == Token.NAME) {
2137 breakLabel = createNameNode();
2138 end = getNodeEnd(breakLabel);
2139 }
2140
2141 // matchJumpLabelName only matches if there is one
2142 LabeledStatement labels = matchJumpLabelName();
2143 // always use first label as target
2144 Jump breakTarget = labels == null ? null : labels.getFirstLabel();
2145
2146 if (breakTarget == null && breakLabel == null) {
2147 if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
2148 reportError("msg.bad.break", pos, end - pos);
2149 } else {
2150 breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1);
2151 }
2152 }
2153
2154 if (breakLabel != null) {
2155 breakLabel.setLineColumnNumber(lineNumber(), columnNumber());
2156 }
2157
2158 BreakStatement pn = new BreakStatement(pos, end - pos);
2159 pn.setBreakLabel(breakLabel);
2160 // can be null if it's a bad break in error-recovery mode
2161 if (breakTarget != null) pn.setBreakTarget(breakTarget);
2162 pn.setLineColumnNumber(lineno, column);
2163 return pn;
2164 }
2165
2166 private ContinueStatement continueStatement() throws IOException {
2167 if (currentToken != Token.CONTINUE) codeBug();

Callers 1

statementHelperMethod · 0.95

Calls 15

codeBugMethod · 0.95
consumeTokenMethod · 0.95
lineNumberMethod · 0.95
columnNumberMethod · 0.95
peekTokenOrEOLMethod · 0.95
createNameNodeMethod · 0.95
getNodeEndMethod · 0.95
matchJumpLabelNameMethod · 0.95
getFirstLabelMethod · 0.95
reportErrorMethod · 0.95
setBreakLabelMethod · 0.95
setBreakTargetMethod · 0.95

Tested by

no test coverage detected