equal
deleted
inserted
replaced
216 private static final int HAS_DEEP_WITH_OR_EVAL = HAS_EVAL | HAS_WITH | HAS_DESCENDANT_WITH_OR_EVAL; |
216 private static final int HAS_DEEP_WITH_OR_EVAL = HAS_EVAL | HAS_WITH | HAS_DESCENDANT_WITH_OR_EVAL; |
217 /** Does this function need to store all its variables in scope? */ |
217 /** Does this function need to store all its variables in scope? */ |
218 private static final int HAS_ALL_VARS_IN_SCOPE = HAS_DEEP_WITH_OR_EVAL | IS_SPLIT | HAS_LAZY_CHILDREN; |
218 private static final int HAS_ALL_VARS_IN_SCOPE = HAS_DEEP_WITH_OR_EVAL | IS_SPLIT | HAS_LAZY_CHILDREN; |
219 /** Does this function potentially need "arguments"? Note that this is not a full test, as further negative check of REDEFINES_ARGS is needed. */ |
219 /** Does this function potentially need "arguments"? Note that this is not a full test, as further negative check of REDEFINES_ARGS is needed. */ |
220 private static final int MAYBE_NEEDS_ARGUMENTS = USES_ARGUMENTS | HAS_EVAL; |
220 private static final int MAYBE_NEEDS_ARGUMENTS = USES_ARGUMENTS | HAS_EVAL; |
221 /** Does this function need the parent scope? It needs it if either it or its descendants use variables from it, or have a deep with or eval. */ |
221 /** Does this function need the parent scope? It needs it if either it or its descendants use variables from it, or have a deep with or eval. |
222 private static final int NEEDS_PARENT_SCOPE = USES_ANCESTOR_SCOPE | HAS_DEEP_WITH_OR_EVAL; |
222 * We also pessimistically need a parent scope if we have lazy children that have not yet been compiled */ |
|
223 private static final int NEEDS_PARENT_SCOPE = USES_ANCESTOR_SCOPE | HAS_DEEP_WITH_OR_EVAL | HAS_LAZY_CHILDREN; |
223 |
224 |
224 /** What is the return type of this function? */ |
225 /** What is the return type of this function? */ |
225 private Type returnType = Type.UNKNOWN; |
226 private Type returnType = Type.UNKNOWN; |
226 |
227 |
227 /** |
228 /** |
722 /** |
723 /** |
723 * Check if this function's generated Java method needs a {@code callee} parameter. Functions that need access to |
724 * Check if this function's generated Java method needs a {@code callee} parameter. Functions that need access to |
724 * their parent scope, functions that reference themselves, and non-strict functions that need an Arguments object |
725 * their parent scope, functions that reference themselves, and non-strict functions that need an Arguments object |
725 * (since it exposes {@code arguments.callee} property) will need to have a callee parameter. |
726 * (since it exposes {@code arguments.callee} property) will need to have a callee parameter. |
726 * |
727 * |
727 * We also conservatively need a callee if we have lazy children, i.e. nested function nodes that have not yet |
|
728 * been evaluated. _They_ may need the callee and we don't know it |
|
729 * |
|
730 * @return true if the function's generated Java method needs a {@code callee} parameter. |
728 * @return true if the function's generated Java method needs a {@code callee} parameter. |
731 */ |
729 */ |
732 public boolean needsCallee() { |
730 public boolean needsCallee() { |
733 return hasLazyChildren() || needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); |
731 return needsParentScope() || needsSelfSymbol() || (needsArguments() && !isStrictMode()); |
734 } |
732 } |
735 |
733 |
736 /** |
734 /** |
737 * If this is a function where {@code arguments} is used, return the node used as the {@code arguments} |
735 * If this is a function where {@code arguments} is used, return the node used as the {@code arguments} |
738 * variable |
736 * variable |
1074 if(symbol.getBlock() == this) { |
1072 if(symbol.getBlock() == this) { |
1075 setNeedsScope(); |
1073 setNeedsScope(); |
1076 } else { |
1074 } else { |
1077 this.flags |= USES_ANCESTOR_SCOPE; |
1075 this.flags |= USES_ANCESTOR_SCOPE; |
1078 final FunctionNode parentFn = findParentFunction(); |
1076 final FunctionNode parentFn = findParentFunction(); |
1079 if(parentFn != null) { |
1077 if (parentFn != null) { |
1080 parentFn.setUsesScopeSymbol(symbol); |
1078 parentFn.setUsesScopeSymbol(symbol); |
1081 } |
1079 } |
1082 } |
1080 } |
1083 } |
1081 } |
1084 |
1082 |