Java Code Examples for jdk.nashorn.internal.ir.Node#hasGoto()

The following examples show how to use jdk.nashorn.internal.ir.Node#hasGoto() . 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: PrintVisitor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBlock(final Block block) {
    sb.append(' ');
    sb.append('{');

    indent += TABWIDTH;

    final List<Statement> statements = block.getStatements();

    for (final Node statement : statements) {
        if (printLineNumbers && (statement instanceof Statement)) {
            final int lineNumber = ((Statement)statement).getLineNumber();
            sb.append('\n');
            if (lineNumber != lastLineNumber) {
                indent();
                sb.append("[|").append(lineNumber).append("|];").append('\n');
            }
            lastLineNumber = lineNumber;
        }
        indent();

        statement.accept(this);

        if (statement instanceof FunctionNode) {
            continue;
        }

        int  lastIndex = sb.length() - 1;
        char lastChar  = sb.charAt(lastIndex);
        while (Character.isWhitespace(lastChar) && lastIndex >= 0) {
            lastChar = sb.charAt(--lastIndex);
        }

        if (lastChar != '}' && lastChar != ';') {
            sb.append(';');
        }

        if (statement.hasGoto()) {
            sb.append(" [GOTO]");
        }

        if (statement.isTerminal()) {
            sb.append(" [TERMINAL]");
        }
    }

    indent -= TABWIDTH;

    sb.append(EOLN);
    indent();
    sb.append('}');

    return false;
}
 
Example 2
Source File: PrintVisitor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBlock(final Block block) {
    sb.append(' ');
    sb.append('{');

    indent += TABWIDTH;

    final List<Statement> statements = block.getStatements();

    for (final Node statement : statements) {
        if (printLineNumbers && (statement instanceof Statement)) {
            final int lineNumber = ((Statement)statement).getLineNumber();
            sb.append('\n');
            if (lineNumber != lastLineNumber) {
                indent();
                sb.append("[|").append(lineNumber).append("|];").append('\n');
            }
            lastLineNumber = lineNumber;
        }
        indent();

        statement.accept(this);

        if (statement instanceof FunctionNode) {
            continue;
        }

        int  lastIndex = sb.length() - 1;
        char lastChar  = sb.charAt(lastIndex);
        while (Character.isWhitespace(lastChar) && lastIndex >= 0) {
            lastChar = sb.charAt(--lastIndex);
        }

        if (lastChar != '}' && lastChar != ';') {
            sb.append(';');
        }

        if (statement.hasGoto()) {
            sb.append(" [GOTO]");
        }

        if (statement.isTerminal()) {
            sb.append(" [TERMINAL]");
        }
    }

    indent -= TABWIDTH;

    sb.append(EOLN);
    indent();
    sb.append('}');

    return false;
}
 
Example 3
Source File: PrintVisitor.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterBlock(final Block block) {
    sb.append(' ');
    //sb.append(Debug.id(block));
    sb.append('{');

    indent += TABWIDTH;

    final List<Statement> statements = block.getStatements();

    for (final Node statement : statements) {
        if (printLineNumbers && (statement instanceof Statement)) {
            final int lineNumber = ((Statement)statement).getLineNumber();
            sb.append('\n');
            if (lineNumber != lastLineNumber) {
                indent();
                sb.append("[|").append(lineNumber).append("|];").append('\n');
            }
            lastLineNumber = lineNumber;
        }
        indent();

        statement.accept(this);

        if (statement instanceof FunctionNode) {
            continue;
        }

        int  lastIndex = sb.length() - 1;
        char lastChar  = sb.charAt(lastIndex);
        while (Character.isWhitespace(lastChar) && lastIndex >= 0) {
            lastChar = sb.charAt(--lastIndex);
        }

        if (lastChar != '}' && lastChar != ';') {
            sb.append(';');
        }

        if (statement.hasGoto()) {
            sb.append(" [GOTO]");
        }

        if (statement.isTerminal()) {
            sb.append(" [TERMINAL]");
        }
    }

    indent -= TABWIDTH;

    sb.append(EOLN);
    indent();
    sb.append('}');
   // sb.append(Debug.id(block));

    return false;
}