Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: src/scopes.h

Issue 1104223002: [es6] implement optional parameters via desugaring (with scoping) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Finalize function body scope if it's not needed Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index 5e3dc1f0654bf65c3ee738665fcb7bf2107be63b..2220d9167199f03fe07d3097fc6e0a93d0161131 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
@@ -276,10 +276,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 +295,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_);
@@ -410,6 +415,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_; }
@@ -521,6 +529,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_;
« src/preparser.cc ('K') | « src/runtime/runtime-debug.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698