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

Side by Side Diff: src/ast/scopes.cc

Issue 2388183003: PreParsing inner functions: Fix declaration-only variables. (Closed)
Patch Set: flag off Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 if (var == next) { 990 if (var == next) {
991 current->set_next_unresolved(next->next_unresolved()); 991 current->set_next_unresolved(next->next_unresolved());
992 var->set_next_unresolved(nullptr); 992 var->set_next_unresolved(nullptr);
993 return true; 993 return true;
994 } 994 }
995 current = next; 995 current = next;
996 } 996 }
997 return false; 997 return false;
998 } 998 }
999 999
1000 bool Scope::RemoveUnresolved(const AstRawString* name) {
1001 if (unresolved_->raw_name() == name) {
1002 VariableProxy* removed = unresolved_;
1003 unresolved_ = unresolved_->next_unresolved();
1004 removed->set_next_unresolved(nullptr);
1005 return true;
1006 }
1007 VariableProxy* current = unresolved_;
1008 while (current != nullptr) {
1009 VariableProxy* next = current->next_unresolved();
1010 if (next->raw_name() == name) {
1011 current->set_next_unresolved(next->next_unresolved());
1012 next->set_next_unresolved(nullptr);
1013 return true;
1014 }
1015 current = next;
1016 }
1017 return false;
1018 }
1000 1019
1001 Variable* Scope::NewTemporary(const AstRawString* name) { 1020 Variable* Scope::NewTemporary(const AstRawString* name) {
1002 DeclarationScope* scope = GetClosureScope(); 1021 DeclarationScope* scope = GetClosureScope();
1003 Variable* var = new (zone()) 1022 Variable* var = new (zone())
1004 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized); 1023 Variable(scope, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized);
1005 scope->AddLocal(var); 1024 scope->AddLocal(var);
1006 return var; 1025 return var;
1007 } 1026 }
1008 1027
1009 Declaration* Scope::CheckConflictingVarDeclarations() { 1028 Declaration* Scope::CheckConflictingVarDeclarations() {
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 Variable* function = 1923 Variable* function =
1905 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 1924 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
1906 bool is_function_var_in_context = 1925 bool is_function_var_in_context =
1907 function != nullptr && function->IsContextSlot(); 1926 function != nullptr && function->IsContextSlot();
1908 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1927 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1909 (is_function_var_in_context ? 1 : 0); 1928 (is_function_var_in_context ? 1 : 0);
1910 } 1929 }
1911 1930
1912 } // namespace internal 1931 } // namespace internal
1913 } // namespace v8 1932 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698