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

Print this page

        

@@ -54,11 +54,11 @@
     private final Label entryLabel;
 
     /** Break label. */
     private final Label breakLabel;
 
-    /** Does the block/function need a new scope? */
+    /** Does the block/function need a new scope? Is this synthetic? */
     protected final int flags;
 
     /**
      * @see JoinPredecessor
      */

@@ -78,10 +78,15 @@
      * outermost level of recompiles
      */
     public static final int IS_GLOBAL_SCOPE = 1 << 3;
 
     /**
+     * Is this block a synthetic one introduced by Parser?
+     */
+    public static final int IS_SYNTHETIC = 1 << 4;
+
+    /**
      * Constructor
      *
      * @param token      The first token of the block
      * @param finish     The index of the last character
      * @param flags      The flags of the block

@@ -106,22 +111,22 @@
      * @param token The first token of the block
      * @param finish The index of the last character
      * @param statements All statements in the block
      */
     public Block(final long token, final int finish, final Statement...statements){
-        this(token, finish, 0, statements);
+        this(token, finish, IS_SYNTHETIC, statements);
     }
 
     /**
      * Constructs a new block
      *
      * @param token The first token of the block
      * @param finish The index of the last character
      * @param statements All statements in the block
      */
     public Block(final long token, final int finish, final List<Statement> statements){
-        this(token, finish, 0, statements);
+        this(token, finish, IS_SYNTHETIC, statements);
     }
 
     /**
      * Constructor
      *

@@ -364,10 +369,19 @@
      */
     public boolean needsScope() {
         return (flags & NEEDS_SCOPE) == NEEDS_SCOPE;
     }
 
+    /**
+     * Check whether this block is synthetic or not.
+     *
+     * @return true if this is a synthetic block
+     */
+    public boolean isSynthetic() {
+        return (flags & IS_SYNTHETIC) == IS_SYNTHETIC;
+    }
+
     @Override
     public Block setFlags(final LexicalContext lc, final int flags) {
         if (this.flags == flags) {
             return this;
         }