src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/BlockStatement.java

Print this page




  73         return createReplacement(stmt, stmt.getFinish(), newStmts);
  74     }
  75 
  76     /**
  77      * Use this method to create a block statement meant to replace a single statement.
  78      * @param stmt the statement to replace
  79      * @param finish the new finish for the block
  80      * @param newStmts the statements for the new block statement
  81      * @return a block statement with the new statements. It will have the line number, and token of the
  82      * original statement.
  83      */
  84     public static BlockStatement createReplacement(final Statement stmt, final int finish, final List<Statement> newStmts) {
  85         return new BlockStatement(stmt.getLineNumber(), new Block(stmt.getToken(), finish, newStmts));
  86     }
  87 
  88     @Override
  89     public boolean isTerminal() {
  90         return block.isTerminal();
  91     }
  92 









  93     @Override
  94     public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
  95         if (visitor.enterBlockStatement(this)) {
  96             return visitor.leaveBlockStatement(setBlock((Block)block.accept(visitor)));
  97         }
  98 
  99         return this;
 100     }
 101 
 102     @Override
 103     public void toString(final StringBuilder sb, final boolean printType) {
 104         block.toString(sb, printType);
 105     }
 106 
 107     /**
 108      * Return the block to be executed
 109      * @return the block
 110      */
 111     public Block getBlock() {
 112         return block;


  73         return createReplacement(stmt, stmt.getFinish(), newStmts);
  74     }
  75 
  76     /**
  77      * Use this method to create a block statement meant to replace a single statement.
  78      * @param stmt the statement to replace
  79      * @param finish the new finish for the block
  80      * @param newStmts the statements for the new block statement
  81      * @return a block statement with the new statements. It will have the line number, and token of the
  82      * original statement.
  83      */
  84     public static BlockStatement createReplacement(final Statement stmt, final int finish, final List<Statement> newStmts) {
  85         return new BlockStatement(stmt.getLineNumber(), new Block(stmt.getToken(), finish, newStmts));
  86     }
  87 
  88     @Override
  89     public boolean isTerminal() {
  90         return block.isTerminal();
  91     }
  92 
  93     /**
  94      * Tells if this is a synthetic block statement or not.
  95      *
  96      * @return true if this is a synthetic statement
  97      */
  98     public boolean isSynthetic() {
  99         return block.isSynthetic();
 100     }
 101 
 102     @Override
 103     public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
 104         if (visitor.enterBlockStatement(this)) {
 105             return visitor.leaveBlockStatement(setBlock((Block)block.accept(visitor)));
 106         }
 107 
 108         return this;
 109     }
 110 
 111     @Override
 112     public void toString(final StringBuilder sb, final boolean printType) {
 113         block.toString(sb, printType);
 114     }
 115 
 116     /**
 117      * Return the block to be executed
 118      * @return the block
 119      */
 120     public Block getBlock() {
 121         return block;