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

Unified Diff: src/ast/scopes.cc

Issue 2520883002: [parser] Fix scopes in rewriting of for-of and destructuring assignments. (Closed)
Patch Set: Remove incorrect DCHECK. Created 4 years, 1 month 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
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index c150336668545eb1a8bf78b3af3823f70bb476c1..46591678f90896506d6e4cec86093b5c489e8b2e 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -636,6 +636,35 @@ Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name) {
return function_;
}
+bool Scope::HasBeenRemoved() const {
+ // TODO(neis): Store this information somewhere instead of calculating it.
+
+ if (!is_block_scope() || is_declaration_scope()) return false;
+
+ Scope* parent = outer_scope();
+ if (parent == nullptr) {
+ DCHECK(is_script_scope());
+ return false;
+ }
+
+ Scope* sibling = parent->inner_scope();
+ for (; sibling != nullptr; sibling = sibling->sibling()) {
+ if (sibling == this) return false;
+ }
+
+ DCHECK_NULL(inner_scope_);
+ return true;
+}
+
+Scope* Scope::GetUnremovedScope() {
+ Scope* scope = this;
+ while (scope != nullptr && scope->HasBeenRemoved()) {
+ scope = scope->outer_scope();
+ }
+ DCHECK_NOT_NULL(scope);
+ return scope;
+}
+
Scope* Scope::FinalizeBlockScope() {
DCHECK(is_block_scope());
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698