src/jdk/nashorn/internal/ir/FunctionNode.java

Print this page

        

@@ -195,10 +195,13 @@
     public static final int HAS_FUNCTION_DECLARATIONS   = 1 << 13;
 
     /** Can this function be specialized? */
     public static final int CAN_SPECIALIZE              = 1 << 14;
 
+    /** Does this function use the "this" keyword? */
+    public static final int USES_THIS                   = 1 << 15;
+
     /** Does this function or any nested functions contain an eval? */
     private static final int HAS_DEEP_EVAL = HAS_EVAL | HAS_NESTED_EVAL;
 
     /** Does this function need to store all its variables in scope? */
     private static final int HAS_ALL_VARS_IN_SCOPE = HAS_DEEP_EVAL | IS_SPLIT | HAS_LAZY_CHILDREN;

@@ -589,10 +592,19 @@
     public boolean needsCallee() {
         return needsParentScope() || needsSelfSymbol() || isSplit() || (needsArguments() && !isStrict());
     }
 
     /**
+     * Return {@code true} if this function makes use of the {@code this} object.
+     *
+     * @return true if function uses {@code this} object
+     */
+    public boolean usesThis() {
+        return getFlag(USES_THIS);
+    }
+
+    /**
      * Get the identifier for this function, this is its symbol.
      * @return the identifier as an IdentityNode
      */
     public IdentNode getIdent() {
         return ident;