Index: src/scopes.h |
diff --git a/src/scopes.h b/src/scopes.h |
index 5e3dc1f0654bf65c3ee738665fcb7bf2107be63b..1613b283e5cb3f6e8e25332de33708edb767534a 100644 |
--- a/src/scopes.h |
+++ b/src/scopes.h |
@@ -87,7 +87,7 @@ class Scope: public ZoneObject { |
void SetScopeName(const AstRawString* scope_name) { |
scope_name_ = scope_name; |
} |
- |
+ const AstRawString* scope_name() const { return scope_name_; } |
void Initialize(); |
// Checks if the block scope is redundant, i.e. it does not contain any |
@@ -126,7 +126,7 @@ class Scope: public ZoneObject { |
// parameters the rightmost one 'wins'. However, the implementation |
// expects all parameters to be declared and from left to right. |
Variable* DeclareParameter(const AstRawString* name, VariableMode mode, |
- bool is_rest, bool* is_duplicate); |
+ int pos, bool is_rest, bool* is_duplicate); |
// Declare a local variable in this scope. If the variable has been |
// declared before, the previously declared variable is returned. |
@@ -134,7 +134,10 @@ class Scope: public ZoneObject { |
InitializationFlag init_flag, Variable::Kind kind, |
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, |
int declaration_group_start = -1); |
- |
+ Variable* RedeclareLocal(const AstRawString* name, VariableMode mode, |
+ InitializationFlag init_flag, Variable::Kind kind, |
+ MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, |
+ int declaration_group_start = -1); |
// Declare an implicit global variable in this scope which must be a |
// script scope. The variable was introduced (possibly from an inner |
// scope) by a reference to an unresolved variable with no intervening |
@@ -276,10 +279,15 @@ class Scope: public ZoneObject { |
bool is_function_scope() const { |
return scope_type_ == FUNCTION_SCOPE || scope_type_ == ARROW_SCOPE; |
} |
+ bool is_function_body_scope() const { |
+ return scope_type_ == FUNCTION_BODY_SCOPE; |
+ } |
bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; } |
bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; } |
bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } |
- bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } |
+ bool is_block_scope() const { |
+ return scope_type_ == BLOCK_SCOPE || scope_type_ == FUNCTION_BODY_SCOPE; |
+ } |
bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } |
bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } |
void tag_as_class_scope() { |
@@ -290,8 +298,8 @@ class Scope: public ZoneObject { |
return is_block_scope() && block_scope_is_class_scope_; |
} |
bool is_declaration_scope() const { |
- return is_eval_scope() || is_function_scope() || |
- is_module_scope() || is_script_scope(); |
+ return is_eval_scope() || is_function_scope() || is_module_scope() || |
+ is_script_scope() || is_function_body_scope(); |
} |
bool is_strict_eval_scope() const { |
return is_eval_scope() && is_strict(language_mode_); |
@@ -364,6 +372,10 @@ class Scope: public ZoneObject { |
DCHECK(is_function_scope()); |
return params_[index]; |
} |
+ int parameter_position(int index) const { |
+ DCHECK(is_function_scope()); |
+ return param_positions_[index]; |
+ } |
// Returns the default function arity --- does not include rest parameters. |
int default_function_length() const { |
@@ -410,6 +422,9 @@ class Scope: public ZoneObject { |
// The scope immediately surrounding this scope, or NULL. |
Scope* outer_scope() const { return outer_scope_; } |
+ // The inner scope which contains the main "body" of a function (may be null) |
+ Scope* function_body() const { return function_body_; } |
+ |
// The ModuleDescriptor for this scope; only for module scopes. |
ModuleDescriptor* module() const { return module_descriptor_; } |
@@ -438,7 +453,6 @@ class Scope: public ZoneObject { |
// Result of variable allocation. |
int num_stack_slots() const { return num_stack_slots_; } |
int num_heap_slots() const { return num_heap_slots_; } |
- |
int StackLocalCount() const; |
int ContextLocalCount() const; |
@@ -521,6 +535,7 @@ class Scope: public ZoneObject { |
// Scope tree. |
Scope* outer_scope_; // the immediately enclosing outer scope, or NULL |
ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes |
+ Scope* function_body_; // The scope for a function body |
// The scope type. |
ScopeType scope_type_; |
@@ -544,6 +559,8 @@ class Scope: public ZoneObject { |
ZoneList<Variable*> temps_; |
// Parameter list in source order. |
ZoneList<Variable*> params_; |
+ // List of positions, in source order. |
+ ZoneList<int> param_positions_; |
// Variables that must be looked up dynamically. |
DynamicScopePart* dynamics_; |
// Unresolved variables referred to from this scope. |