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

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

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: . 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // function, or eval scope. Same as DeclarationScope(), but skips declaration 368 // function, or eval scope. Same as DeclarationScope(), but skips declaration
369 // "block" scopes. Used for differentiating associated function objects (i.e., 369 // "block" scopes. Used for differentiating associated function objects (i.e.,
370 // the scope for which a function prologue allocates a context) or declaring 370 // the scope for which a function prologue allocates a context) or declaring
371 // temporaries. 371 // temporaries.
372 DeclarationScope* GetClosureScope(); 372 DeclarationScope* GetClosureScope();
373 373
374 // Find the first (non-arrow) function or script scope. This is where 374 // Find the first (non-arrow) function or script scope. This is where
375 // 'this' is bound, and what determines the function kind. 375 // 'this' is bound, and what determines the function kind.
376 DeclarationScope* GetReceiverScope(); 376 DeclarationScope* GetReceiverScope();
377 377
378 // Find the module scope, assuming there is one.
379 ModuleScope* GetModuleScope();
380
378 // Analyze() must have been called once to create the ScopeInfo. 381 // Analyze() must have been called once to create the ScopeInfo.
379 Handle<ScopeInfo> scope_info() { 382 Handle<ScopeInfo> scope_info() {
380 DCHECK(!scope_info_.is_null()); 383 DCHECK(!scope_info_.is_null());
381 return scope_info_; 384 return scope_info_;
382 } 385 }
383 386
384 // --------------------------------------------------------------------------- 387 // ---------------------------------------------------------------------------
385 // Strict mode support. 388 // Strict mode support.
386 bool IsDeclared(const AstRawString* name) { 389 bool IsDeclared(const AstRawString* name) {
387 // During formal parameter list parsing the scope only contains 390 // During formal parameter list parsing the scope only contains
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 Variable* new_target_var() { return new_target_; } 674 Variable* new_target_var() { return new_target_; }
672 675
673 // The variable holding the function literal for named function 676 // The variable holding the function literal for named function
674 // literals, or NULL. Only valid for function scopes. 677 // literals, or NULL. Only valid for function scopes.
675 Variable* function_var() const { 678 Variable* function_var() const {
676 DCHECK(is_function_scope()); 679 DCHECK(is_function_scope());
677 return function_; 680 return function_;
678 } 681 }
679 682
680 // Parameters. The left-most parameter has index 0. 683 // Parameters. The left-most parameter has index 0.
681 // Only valid for function scopes. 684 // Only valid for function and module scopes.
682 Variable* parameter(int index) const { 685 Variable* parameter(int index) const {
683 DCHECK(is_function_scope()); 686 DCHECK(is_function_scope() || is_module_scope());
684 return params_[index]; 687 return params_[index];
685 } 688 }
686 689
687 // Returns the default function arity excluding default or rest parameters. 690 // Returns the default function arity excluding default or rest parameters.
688 int default_function_length() const { return arity_; } 691 int default_function_length() const { return arity_; }
689 692
690 // Returns the number of formal parameters, excluding a possible rest 693 // Returns the number of formal parameters, excluding a possible rest
691 // parameter. Examples: 694 // parameter. Examples:
692 // function foo(a, b) {} ==> 2 695 // function foo(a, b) {} ==> 2
693 // function foo(a, b, ...c) {} ==> 2 696 // function foo(a, b, ...c) {} ==> 2
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 void AllocateModuleVariables(); 855 void AllocateModuleVariables();
853 856
854 private: 857 private:
855 ModuleDescriptor* module_descriptor_; 858 ModuleDescriptor* module_descriptor_;
856 }; 859 };
857 860
858 } // namespace internal 861 } // namespace internal
859 } // namespace v8 862 } // namespace v8
860 863
861 #endif // V8_AST_SCOPES_H_ 864 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/scopeinfo.cc ('k') | src/ast/scopes.cc » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698