Java 类org.mozilla.javascript.ast.BreakStatement 实例源码

项目:HL4A    文件:IRFactory.java   
private Node transformBreak(BreakStatement node) {
    decompiler.addToken(Token.BREAK);
    if (node.getBreakLabel() != null) {
        decompiler.addName(node.getBreakLabel().getIdentifier());
    }
    decompiler.addEOL(Token.SEMI);
    return node;
}
项目:HL4A    文件:Parser.java   
private BreakStatement breakStatement()
    throws IOException
{
    if (currentToken != Token.BREAK) codeBug();
    consumeToken();
    int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd;
    Name breakLabel = null;
    if (peekTokenOrEOL() == Token.NAME) {
        breakLabel = createNameNode();
        end = getNodeEnd(breakLabel);
    }

    // matchJumpLabelName only matches if there is one
    LabeledStatement labels = matchJumpLabelName();
    // always use first label as target
    Jump breakTarget = labels == null ? null : labels.getFirstLabel();

    if (breakTarget == null && breakLabel == null) {
        if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
            if (breakLabel == null) {
                reportError("msg.bad.break", pos, end - pos);
            }
        } else {
            breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1);
        }
    }

    BreakStatement pn = new BreakStatement(pos, end - pos);
    pn.setBreakLabel(breakLabel);
    // can be null if it's a bad break in error-recovery mode
    if (breakTarget != null)
        pn.setBreakTarget(breakTarget);
    pn.setLineno(lineno);
    return pn;
}
项目:LoboEvolution    文件:IRFactory.java   
private Node transformBreak(BreakStatement node) {
    decompiler.addToken(Token.BREAK);
    if (node.getBreakLabel() != null) {
        decompiler.addName(node.getBreakLabel().getIdentifier());
    }
    decompiler.addEOL(Token.SEMI);
    return node;
}
项目:LoboEvolution    文件:Parser.java   
private BreakStatement breakStatement()
    throws IOException
{
    if (currentToken != Token.BREAK) codeBug();
    consumeToken();
    int lineno = ts.lineno, pos = ts.tokenBeg, end = ts.tokenEnd;
    Name breakLabel = null;
    if (peekTokenOrEOL() == Token.NAME) {
        breakLabel = createNameNode();
        end = getNodeEnd(breakLabel);
    }

    // matchJumpLabelName only matches if there is one
    LabeledStatement labels = matchJumpLabelName();
    // always use first label as target
    Jump breakTarget = labels == null ? null : labels.getFirstLabel();

    if (breakTarget == null && breakLabel == null) {
        if (loopAndSwitchSet == null || loopAndSwitchSet.size() == 0) {
            if (breakLabel == null) {
                reportError("msg.bad.break", pos, end - pos);
            }
        } else {
            breakTarget = loopAndSwitchSet.get(loopAndSwitchSet.size() - 1);
        }
    }

    BreakStatement pn = new BreakStatement(pos, end - pos);
    pn.setBreakLabel(breakLabel);
    // can be null if it's a bad break in error-recovery mode
    if (breakTarget != null)
        pn.setBreakTarget(breakTarget);
    pn.setLineno(lineno);
    return pn;
}
项目:teavm    文件:AstWriter.java   
private void print(BreakStatement node) throws IOException {
    writer.append("break");
    if (node.getBreakLabel() != null) {
        writer.append(' ').append(node.getBreakLabel().getString());
    }
    writer.append(';');
}
项目:SJS    文件:ConstraintVisitor.java   
/**
 * This method generates constraints for all relevant AstNodes. It delegates its work to various
 * processXXX() methods that handle AstNodes of type XXX.
 */
@Override
public boolean visit(AstNode node) {
    if (node instanceof VariableInitializer){
        processVariableInitializer(node);
    } else if (node instanceof ReturnStatement){
        processReturnStatement((ReturnStatement)node);
    } else if (node instanceof ExpressionStatement){
        processExpressionStatement((ExpressionStatement)node);
    } else if (node instanceof ForLoop){
        processForLoop((ForLoop)node);
    } else if (node instanceof ForInLoop){
        processForInLoop((ForInLoop)node);
    }else if (node instanceof WhileLoop){
        processWhileLoop((WhileLoop)node);
    } else if (node instanceof DoLoop){
        processDoLoop((DoLoop)node);
    } else if (node instanceof NewExpression){
        processNewExpression((NewExpression)node);
    } else if (node instanceof FunctionCall){
        processFunctionCall((FunctionCall)node);
    } else if (node instanceof ElementGet){
        processElementGet((ElementGet)node);
    } else if (node instanceof FunctionNode){
        processFunctionNode((FunctionNode)node);
    } else if (node instanceof IfStatement){
        processIfStatement((IfStatement)node);
    } else if (node instanceof KeywordLiteral){
        processKeywordLiteral((KeywordLiteral)node);
    } else if (node instanceof SwitchStatement){
        processSwitchStatement((SwitchStatement)node);
    } else if (node instanceof SwitchCase){
        processSwitchCase((SwitchCase)node);
    } else if ((node instanceof AstRoot) || //AstRoot: no constraints need to be generated
        (node instanceof BreakStatement) || //BreakStatement: no constraints need to be generated
        (node instanceof VariableDeclaration) || //VariableDeclaration: we generate constraints for its constituent VariableInitializer nodes
        (node instanceof Name) || //Name: generate constraints for complex expressions that refer to names
        (node instanceof NumberLiteral) || //NumberLiteral: generate constraints for complex expressions that refer to names
        (node instanceof StringLiteral) || //StringLiteral: generate constraints for complex expressions that refer to names
        (node instanceof Assignment) || // Assignment is a special case of InfixExpression
        (node instanceof ArrayLiteral) ||
        (node instanceof UnaryExpression) ||
        (node instanceof InfixExpression) ||
        (node instanceof ConditionalExpression) ||
        (node instanceof ParenthesizedExpression) ||
        (node instanceof EmptyExpression) ||
        (node instanceof ObjectLiteral) ||
        (node instanceof EmptyStatement) ||
        (node instanceof ContinueStatement) ||
        (node instanceof Scope) ||
        (node instanceof Block)){ // // occurs in programs with for loops -- nothing to be done here?
        /* nothing */
    } else {
        error("unsupported node " + node.toSource().trim() + " of type: " + node.getClass().getName(), node);
    }
    return true;
}