Java Code Examples for jdk.nashorn.internal.ir.Statement#accept()
The following examples show how to use
jdk.nashorn.internal.ir.Statement#accept() .
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 TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 2
Source File: PrintVisitor.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 3
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final Compiler compiler) { 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 JumpStatement) { //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.log = initLogger(compiler.getContext()); }
Example 4
Source File: PrintVisitor.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 5
Source File: PrintVisitor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 6
Source File: PrintVisitor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 7
Source File: PrintVisitor.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 8
Source File: Lower.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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 9
Source File: Lower.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 10
Source File: PrintVisitor.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); 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('}'); printLocalVariableConversion(block); return false; }
Example 11
Source File: Lower.java From nashorn with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower() { 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); } }); }