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

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

Issue 2281073002: Create ScopeInfos while analyzing the Scope chain (Closed)
Patch Set: updates Created 4 years, 3 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
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 #ifndef V8_AST_SCOPES_H_ 5 #ifndef V8_AST_SCOPES_H_
6 #define V8_AST_SCOPES_H_ 6 #define V8_AST_SCOPES_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/base/hashmap.h" 9 #include "src/base/hashmap.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // function, or eval scope. Same as DeclarationScope(), but skips declaration 377 // function, or eval scope. Same as DeclarationScope(), but skips declaration
378 // "block" scopes. Used for differentiating associated function objects (i.e., 378 // "block" scopes. Used for differentiating associated function objects (i.e.,
379 // the scope for which a function prologue allocates a context) or declaring 379 // the scope for which a function prologue allocates a context) or declaring
380 // temporaries. 380 // temporaries.
381 DeclarationScope* GetClosureScope(); 381 DeclarationScope* GetClosureScope();
382 382
383 // Find the first (non-arrow) function or script scope. This is where 383 // Find the first (non-arrow) function or script scope. This is where
384 // 'this' is bound, and what determines the function kind. 384 // 'this' is bound, and what determines the function kind.
385 DeclarationScope* GetReceiverScope(); 385 DeclarationScope* GetReceiverScope();
386 386
387 // Creates a scope info if it doesn't already exist. 387 // Analyze() must have been called once to create the ScopeInfo.
388 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate);
389
390 // GetScopeInfo() must have been called once to create the ScopeInfo.
391 Handle<ScopeInfo> scope_info() { 388 Handle<ScopeInfo> scope_info() {
392 DCHECK(!scope_info_.is_null()); 389 DCHECK(!scope_info_.is_null());
393 return scope_info_; 390 return scope_info_;
394 } 391 }
395 392
396 // --------------------------------------------------------------------------- 393 // ---------------------------------------------------------------------------
397 // Strict mode support. 394 // Strict mode support.
398 bool IsDeclared(const AstRawString* name) { 395 bool IsDeclared(const AstRawString* name) {
399 // During formal parameter list parsing the scope only contains 396 // During formal parameter list parsing the scope only contains
400 // two variables inserted at initialization: "this" and "arguments". 397 // two variables inserted at initialization: "this" and "arguments".
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // Predicates. 536 // Predicates.
540 bool MustAllocate(Variable* var); 537 bool MustAllocate(Variable* var);
541 bool MustAllocateInContext(Variable* var); 538 bool MustAllocateInContext(Variable* var);
542 539
543 // Variable allocation. 540 // Variable allocation.
544 void AllocateStackSlot(Variable* var); 541 void AllocateStackSlot(Variable* var);
545 void AllocateHeapSlot(Variable* var); 542 void AllocateHeapSlot(Variable* var);
546 void AllocateNonParameterLocal(Variable* var); 543 void AllocateNonParameterLocal(Variable* var);
547 void AllocateDeclaredGlobal(Variable* var); 544 void AllocateDeclaredGlobal(Variable* var);
548 void AllocateNonParameterLocalsAndDeclaredGlobals(); 545 void AllocateNonParameterLocalsAndDeclaredGlobals();
549 void AllocateVariablesRecursively(); 546 void AllocateVariablesRecursively(Isolate* isolate);
550 547
551 // Construct a scope based on the scope info. 548 // Construct a scope based on the scope info.
552 Scope(Zone* zone, ScopeType type, Handle<ScopeInfo> scope_info); 549 Scope(Zone* zone, ScopeType type, Handle<ScopeInfo> scope_info);
553 550
554 // Construct a catch scope with a binding for the name. 551 // Construct a catch scope with a binding for the name.
555 Scope(Zone* zone, const AstRawString* catch_variable_name); 552 Scope(Zone* zone, const AstRawString* catch_variable_name);
556 553
557 void AddInnerScope(Scope* inner_scope) { 554 void AddInnerScope(Scope* inner_scope) {
558 inner_scope->sibling_ = inner_scope_; 555 inner_scope->sibling_ = inner_scope_;
559 inner_scope_ = inner_scope; 556 inner_scope_ = inner_scope;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 void AllocateModuleVariables(); 845 void AllocateModuleVariables();
849 846
850 private: 847 private:
851 ModuleDescriptor* module_descriptor_; 848 ModuleDescriptor* module_descriptor_;
852 }; 849 };
853 850
854 } // namespace internal 851 } // namespace internal
855 } // namespace v8 852 } // namespace v8
856 853
857 #endif // V8_AST_SCOPES_H_ 854 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | src/ast/scopes.cc » ('j') | src/ast/scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698