jdk.nashorn.internal.ir.BreakNode Java Examples

The following examples show how to use jdk.nashorn.internal.ir.BreakNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSONWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #2
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #3
Source File: JSONWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #4
Source File: JSONWriter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final IdentNode label = breakNode.getLabel();
    property("label");
    if (label != null) {
        label.accept(this);
    } else {
        nullValue();
    }

    return leave();
}
 
Example #5
Source File: SplitIntoFunctions.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #6
Source File: JSONWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #7
Source File: SplitIntoFunctions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #8
Source File: SplitIntoFunctions.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #9
Source File: SplitIntoFunctions.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #10
Source File: JSONWriter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final IdentNode label = breakNode.getLabel();
    property("label");
    if (label != null) {
        label.accept(this);
    } else {
        nullValue();
    }

    return leave();
}
 
Example #11
Source File: SplitIntoFunctions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #12
Source File: SplitIntoFunctions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
int getSplitStateIndex(final JumpStatement jump) {
    if (jump instanceof BreakNode && jump.getLabelName() == null) {
        // Unlabelled break is a special case
        hasBreak = true;
        return BREAK_STATE;
    }

    int i = 0;
    for(final JumpStatement exJump: jumpStatements) {
        if (jump.getClass() == exJump.getClass() && Objects.equals(jump.getLabelName(), exJump.getLabelName())) {
            return i + FIRST_JUMP_STATE;
        }
        ++i;
    }
    jumpStatements.add(jump);
    return i + FIRST_JUMP_STATE;
}
 
Example #13
Source File: JSONWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #14
Source File: JSONWriter.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #15
Source File: JSONWriter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    enterDefault(breakNode);

    type("BreakStatement");
    comma();

    final String label = breakNode.getLabelName();
    if(label != null) {
        property("label", label);
    } else {
        property("label");
        nullValue();
    }

    return leave();
}
 
Example #16
Source File: CodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    lineNumber(breakNode);

    final BreakableNode breakFrom = lc.getBreakable(breakNode.getLabel());
    for (int i = 0; i < lc.getScopeNestingLevelTo(breakFrom); i++) {
        closeWith();
    }
    method.splitAwareGoto(lc, breakFrom.getBreakLabel());

    return false;
}
 
Example #17
Source File: CodeGenerator.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    lineNumber(breakNode);

    final BreakableNode breakFrom = lc.getBreakable(breakNode.getLabel());
    for (int i = 0; i < lc.getScopeNestingLevelTo(breakFrom); i++) {
        closeWith();
    }
    method.splitAwareGoto(lc, breakFrom.getBreakLabel());

    return false;
}
 
Example #18
Source File: Lower.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    addStatement(breakNode);
    return false;
}
 
Example #19
Source File: WeighNodes.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Node leaveBreakNode(final BreakNode breakNode) {
    weight += BREAK_WEIGHT;
    return breakNode;
}
 
Example #20
Source File: Lower.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor.
 */
Lower(final CodeInstaller<?> installer) {
    super(new BlockLexicalContext() {

        @Override
        public List<Statement> popStatements() {
            final List<Statement> newStatements = new ArrayList<>();
            boolean terminated = false;

            final List<Statement> statements = super.popStatements();
            for (final Statement statement : statements) {
                if (!terminated) {
                    newStatements.add(statement);
                    if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //TODO hasGoto? But some Loops are hasGoto too - why?
                        terminated = true;
                    }
                } else {
                    statement.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
                        @Override
                        public boolean enterVarNode(final VarNode varNode) {
                            newStatements.add(varNode.setInit(null));
                            return false;
                        }
                    });
                }
            }
            return newStatements;
        }

        @Override
        protected Block afterSetStatements(final Block block) {
            final List<Statement> stmts = block.getStatements();
            for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) {
                final Statement stmt = li.previous();
                // popStatements() guarantees that the only thing after a terminal statement are uninitialized
                // VarNodes. We skip past those, and set the terminal state of the block to the value of the
                // terminal state of the first statement that is not an uninitialized VarNode.
                if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) {
                    return block.setIsTerminal(this, stmt.isTerminal());
                }
            }
            return block.setIsTerminal(this, false);
        }
    });
    this.installer = installer;
}
 
Example #21
Source File: Parser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * BreakStatement :
 *      break Identifier? ; // [no LineTerminator here]
 *
 * See 12.8
 *
 */
private void breakStatement() {
    // Capture BREAK token.
    final int  breakLine  = line;
    final long breakToken = token;
    // BREAK tested in caller.
    nextOrEOL();

    LabelNode labelNode = null;

    // SEMICOLON or label.
    switch (type) {
    case RBRACE:
    case SEMICOLON:
    case EOL:
    case EOF:
        break;

    default:
        final IdentNode ident = getIdent();
        labelNode = lc.findLabel(ident.getName());

        if (labelNode == null) {
            throw error(AbstractParser.message("undefined.label", ident.getName()), ident.getToken());
        }

        break;
    }

    //either an explicit label - then get its node or just a "break" - get first breakable
    //targetNode is what we are breaking out from.
    final IdentNode label = labelNode == null ? null : labelNode.getLabel();
    final BreakableNode targetNode = lc.getBreakable(label);
    if (targetNode == null) {
        throw error(AbstractParser.message("illegal.break.stmt"), breakToken);
    }

    endOfLine();

    // Construct and add BREAK node.
    appendStatement(new BreakNode(breakLine, breakToken, finish, label == null ? null : new IdentNode(label)));
}
 
Example #22
Source File: Lower.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    addStatement(breakNode);
    return false;
}
 
Example #23
Source File: BreakTreeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
BreakTreeImpl(final BreakNode node) {
    super(node);
    this.label = node.getLabelName();
}
 
Example #24
Source File: WeighNodes.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Node leaveBreakNode(final BreakNode breakNode) {
    weight += BREAK_WEIGHT;
    return breakNode;
}
 
Example #25
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    return enterJumpStatement(breakNode);
}
 
Example #26
Source File: WeighNodes.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Node leaveBreakNode(final BreakNode breakNode) {
    weight += BREAK_WEIGHT;
    return breakNode;
}
 
Example #27
Source File: SplitIntoFunctions.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Node leaveBreakNode(final BreakNode breakNode) {
    return leaveJumpNode(breakNode);
}
 
Example #28
Source File: Lower.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode breakNode) {
    addStatement(breakNode);
    return false;
}
 
Example #29
Source File: PrintVisitor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode node) {
    node.toString(sb, printTypes);
    printLocalVariableConversion(node);
    return false;
}
 
Example #30
Source File: PrintVisitor.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBreakNode(final BreakNode node) {
    node.toString(sb, printTypes);
    printLocalVariableConversion(node);
    return false;
}