< prev index next >

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

Print this page




  68     public static final int NEEDS_SCOPE = 1 << 0;
  69 
  70     /**
  71      * Is this block tagged as terminal based on its contents
  72      * (usually the last statement)
  73      */
  74     public static final int IS_TERMINAL = 1 << 2;
  75 
  76     /**
  77      * Is this block the eager global scope - i.e. the original program. This isn't true for the
  78      * outermost level of recompiles
  79      */
  80     public static final int IS_GLOBAL_SCOPE = 1 << 3;
  81 
  82     /**
  83      * Is this block a synthetic one introduced by Parser?
  84      */
  85     public static final int IS_SYNTHETIC = 1 << 4;
  86 
  87     /**















  88      * Constructor
  89      *
  90      * @param token      The first token of the block
  91      * @param finish     The index of the last character
  92      * @param flags      The flags of the block
  93      * @param statements All statements in the block
  94      */
  95     public Block(final long token, final int finish, final int flags, final Statement... statements) {
  96         super(token, finish);
  97 
  98         this.statements = Arrays.asList(statements);
  99         this.symbols    = new LinkedHashMap<>();
 100         this.entryLabel = new Label("block_entry");
 101         this.breakLabel = new Label("block_break");
 102         final int len = statements.length;
 103         final int terminalFlags = len > 0 && statements[len - 1].hasTerminalFlags() ? IS_TERMINAL : 0;
 104         this.flags = terminalFlags | flags;
 105         this.conversion = null;
 106     }
 107 


 471      */
 472     public boolean providesScopeCreator() {
 473         return needsScope() && isSynthetic()
 474                 && (getLastStatement() instanceof ForNode)
 475                 && ((ForNode) getLastStatement()).needsScopeCreator();
 476     }
 477 
 478     @Override
 479     public boolean isBreakableWithoutLabel() {
 480         return false;
 481     }
 482 
 483     @Override
 484     public List<Label> getLabels() {
 485         return Collections.unmodifiableList(Arrays.asList(entryLabel, breakLabel));
 486     }
 487 
 488     @Override
 489     public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
 490         return Acceptor.accept(this, visitor);



























 491     }
 492 }


  68     public static final int NEEDS_SCOPE        = 1 << 0;
  69 
  70     /**
  71      * Is this block tagged as terminal based on its contents
  72      * (usually the last statement)
  73      */
  74     public static final int IS_TERMINAL        = 1 << 2;
  75 
  76     /**
  77      * Is this block the eager global scope - i.e. the original program. This isn't true for the
  78      * outermost level of recompiles
  79      */
  80     public static final int IS_GLOBAL_SCOPE    = 1 << 3;
  81 
  82     /**
  83      * Is this block a synthetic one introduced by Parser?
  84      */
  85     public static final int IS_SYNTHETIC       = 1 << 4;
  86 
  87     /**
  88      * Is this the function body block? May not be the first, if parameter list contains expressions.
  89      */
  90     public static final int IS_BODY            = 1 << 5;
  91 
  92     /**
  93      * Is this the parameter initialization block? If present, must be the first block, immediately wrapping the function body block.
  94      */
  95     public static final int IS_PARAMETER_BLOCK = 1 << 6;
  96 
  97     /**
  98      * Marks the variable declaration block for case clauses of a switch statement.
  99      */
 100     public static final int IS_SWITCH_BLOCK    = 1 << 7;
 101 
 102     /**
 103      * Constructor
 104      *
 105      * @param token      The first token of the block
 106      * @param finish     The index of the last character
 107      * @param flags      The flags of the block
 108      * @param statements All statements in the block
 109      */
 110     public Block(final long token, final int finish, final int flags, final Statement... statements) {
 111         super(token, finish);
 112 
 113         this.statements = Arrays.asList(statements);
 114         this.symbols    = new LinkedHashMap<>();
 115         this.entryLabel = new Label("block_entry");
 116         this.breakLabel = new Label("block_break");
 117         final int len = statements.length;
 118         final int terminalFlags = len > 0 && statements[len - 1].hasTerminalFlags() ? IS_TERMINAL : 0;
 119         this.flags = terminalFlags | flags;
 120         this.conversion = null;
 121     }
 122 


 486      */
 487     public boolean providesScopeCreator() {
 488         return needsScope() && isSynthetic()
 489                 && (getLastStatement() instanceof ForNode)
 490                 && ((ForNode) getLastStatement()).needsScopeCreator();
 491     }
 492 
 493     @Override
 494     public boolean isBreakableWithoutLabel() {
 495         return false;
 496     }
 497 
 498     @Override
 499     public List<Label> getLabels() {
 500         return Collections.unmodifiableList(Arrays.asList(entryLabel, breakLabel));
 501     }
 502 
 503     @Override
 504     public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
 505         return Acceptor.accept(this, visitor);
 506     }
 507 
 508     /**
 509      * Checks if this is a function body.
 510      *
 511      * @return true if the function body flag is set
 512      */
 513     public boolean isFunctionBody() {
 514         return getFlag(IS_BODY);
 515     }
 516 
 517     /**
 518      * Checks if this is a parameter block.
 519      *
 520      * @return true if the parameter block flag is set
 521      */
 522     public boolean isParameterBlock() {
 523         return getFlag(IS_PARAMETER_BLOCK);
 524     }
 525 
 526     /**
 527      * Checks whether this is a switch block.
 528      *
 529      * @return true if this is a switch block
 530      */
 531     public boolean isSwitchBlock() {
 532         return getFlag(IS_SWITCH_BLOCK);
 533     }
 534 }
< prev index next >