nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/FunctionNode.java
changeset 39662 e2b36a3779b9
parent 37732 3673fec68d16
child 47040 4ed4c4eba60c
equal deleted inserted replaced
39604:8e45018bde9d 39662:e2b36a3779b9
    33 import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE_VALUES;
    33 import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_TRACE_VALUES;
    34 
    34 
    35 import java.util.Collections;
    35 import java.util.Collections;
    36 import java.util.Iterator;
    36 import java.util.Iterator;
    37 import java.util.List;
    37 import java.util.List;
       
    38 import java.util.Map;
    38 import jdk.nashorn.internal.codegen.CompileUnit;
    39 import jdk.nashorn.internal.codegen.CompileUnit;
    39 import jdk.nashorn.internal.codegen.Compiler;
    40 import jdk.nashorn.internal.codegen.Compiler;
    40 import jdk.nashorn.internal.codegen.CompilerConstants;
    41 import jdk.nashorn.internal.codegen.CompilerConstants;
    41 import jdk.nashorn.internal.codegen.Namespace;
    42 import jdk.nashorn.internal.codegen.Namespace;
    42 import jdk.nashorn.internal.codegen.types.Type;
    43 import jdk.nashorn.internal.codegen.types.Type;
   104     private final Kind kind;
   105     private final Kind kind;
   105 
   106 
   106     /** List of parameters. */
   107     /** List of parameters. */
   107     private final List<IdentNode> parameters;
   108     private final List<IdentNode> parameters;
   108 
   109 
       
   110     /** Map of ES6 function parameter expressions. */
       
   111     private final Map<IdentNode, Expression> parameterExpressions;
       
   112 
   109     /** First token of function. **/
   113     /** First token of function. **/
   110     private final long firstToken;
   114     private final long firstToken;
   111 
   115 
   112     /** Last token of function. **/
   116     /** Last token of function. **/
   113     private final long lastToken;
   117     private final long lastToken;
   239     /** is this a strong mode function? */
   243     /** is this a strong mode function? */
   240     public static final int ES6_IS_STRONG               = 1 << 24;
   244     public static final int ES6_IS_STRONG               = 1 << 24;
   241 
   245 
   242     /** Does this function use new.target? */
   246     /** Does this function use new.target? */
   243     public static final int ES6_USES_NEW_TARGET         = 1 << 25;
   247     public static final int ES6_USES_NEW_TARGET         = 1 << 25;
       
   248 
       
   249     /** Does this function have expression as its body? */
       
   250     public static final int HAS_EXPRESSION_BODY         = 1 << 26;
   244 
   251 
   245     /** Does this function or any nested functions contain an eval? */
   252     /** Does this function or any nested functions contain an eval? */
   246     private static final int HAS_DEEP_EVAL = HAS_EVAL | HAS_NESTED_EVAL;
   253     private static final int HAS_DEEP_EVAL = HAS_EVAL | HAS_NESTED_EVAL;
   247 
   254 
   248     /** Does this function need to store all its variables in scope? */
   255     /** Does this function need to store all its variables in scope? */
   304      * @param lastToken  lastToken
   311      * @param lastToken  lastToken
   305      * @param namespace  the namespace
   312      * @param namespace  the namespace
   306      * @param ident      the identifier
   313      * @param ident      the identifier
   307      * @param name       the name of the function
   314      * @param name       the name of the function
   308      * @param parameters parameter list
   315      * @param parameters parameter list
       
   316      * @param paramExprs the ES6 function parameter expressions
   309      * @param kind       kind of function as in {@link FunctionNode.Kind}
   317      * @param kind       kind of function as in {@link FunctionNode.Kind}
   310      * @param flags      initial flags
   318      * @param flags      initial flags
   311      * @param body       body of the function
   319      * @param body       body of the function
   312      * @param endParserState The parser state at the end of the parsing.
   320      * @param endParserState The parser state at the end of the parsing.
   313      * @param module     the module
   321      * @param module     the module
   322         final long lastToken,
   330         final long lastToken,
   323         final Namespace namespace,
   331         final Namespace namespace,
   324         final IdentNode ident,
   332         final IdentNode ident,
   325         final String name,
   333         final String name,
   326         final List<IdentNode> parameters,
   334         final List<IdentNode> parameters,
       
   335         final Map<IdentNode, Expression> paramExprs,
   327         final FunctionNode.Kind kind,
   336         final FunctionNode.Kind kind,
   328         final int flags,
   337         final int flags,
   329         final Block body,
   338         final Block body,
   330         final Object endParserState,
   339         final Object endParserState,
   331         final Module module,
   340         final Module module,
   336         this.lineNumber       = lineNumber;
   345         this.lineNumber       = lineNumber;
   337         this.ident            = ident;
   346         this.ident            = ident;
   338         this.name             = name;
   347         this.name             = name;
   339         this.kind             = kind;
   348         this.kind             = kind;
   340         this.parameters       = parameters;
   349         this.parameters       = parameters;
       
   350         this.parameterExpressions = paramExprs;
   341         this.firstToken       = firstToken;
   351         this.firstToken       = firstToken;
   342         this.lastToken        = lastToken;
   352         this.lastToken        = lastToken;
   343         this.namespace        = namespace;
   353         this.namespace        = namespace;
   344         this.flags            = flags;
   354         this.flags            = flags;
   345         this.compileUnit      = null;
   355         this.compileUnit      = null;
   373         this.returnType       = returnType;
   383         this.returnType       = returnType;
   374         this.compileUnit      = compileUnit;
   384         this.compileUnit      = compileUnit;
   375         this.lastToken        = lastToken;
   385         this.lastToken        = lastToken;
   376         this.body             = body;
   386         this.body             = body;
   377         this.parameters       = parameters;
   387         this.parameters       = parameters;
       
   388         this.parameterExpressions = functionNode.parameterExpressions;
   378         this.thisProperties   = thisProperties;
   389         this.thisProperties   = thisProperties;
   379         this.rootClass        = rootClass;
   390         this.rootClass        = rootClass;
   380         this.source           = source;
   391         this.source           = source;
   381         this.namespace        = namespace;
   392         this.namespace        = namespace;
   382 
   393 
   975     public List<IdentNode> getParameters() {
   986     public List<IdentNode> getParameters() {
   976         return Collections.unmodifiableList(parameters);
   987         return Collections.unmodifiableList(parameters);
   977     }
   988     }
   978 
   989 
   979     /**
   990     /**
       
   991      * Get the ES6 style parameter expressions of this function. This may be null.
       
   992      *
       
   993      * @return a Map of parameter IdentNode to Expression node (for ES6 parameter expressions)
       
   994      */
       
   995     public Map<IdentNode, Expression> getParameterExpressions() {
       
   996         return parameterExpressions;
       
   997     }
       
   998 
       
   999     /**
   980      * Return the number of parameters to this function
  1000      * Return the number of parameters to this function
   981      * @return the number of parameters
  1001      * @return the number of parameters
   982      */
  1002      */
   983     public int getNumOfParams() {
  1003     public int getNumOfParams() {
   984         return parameters.size();
  1004         return parameters.size();