OLD | NEW |
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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // function, or eval scope. Same as DeclarationScope(), but skips declaration | 404 // function, or eval scope. Same as DeclarationScope(), but skips declaration |
405 // "block" scopes. Used for differentiating associated function objects (i.e., | 405 // "block" scopes. Used for differentiating associated function objects (i.e., |
406 // the scope for which a function prologue allocates a context) or declaring | 406 // the scope for which a function prologue allocates a context) or declaring |
407 // temporaries. | 407 // temporaries. |
408 DeclarationScope* GetClosureScope(); | 408 DeclarationScope* GetClosureScope(); |
409 | 409 |
410 // Find the first (non-arrow) function or script scope. This is where | 410 // Find the first (non-arrow) function or script scope. This is where |
411 // 'this' is bound, and what determines the function kind. | 411 // 'this' is bound, and what determines the function kind. |
412 DeclarationScope* GetReceiverScope(); | 412 DeclarationScope* GetReceiverScope(); |
413 | 413 |
| 414 // Creates a scope info if it doesn't already exist. |
414 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate); | 415 Handle<ScopeInfo> GetScopeInfo(Isolate* isolate); |
415 | 416 |
| 417 // GetScopeInfo() must have been called once to create the ScopeInfo. |
| 418 Handle<ScopeInfo> scope_info() { |
| 419 DCHECK(!scope_info_.is_null()); |
| 420 return scope_info_; |
| 421 } |
| 422 |
416 // --------------------------------------------------------------------------- | 423 // --------------------------------------------------------------------------- |
417 // Strict mode support. | 424 // Strict mode support. |
418 bool IsDeclared(const AstRawString* name) { | 425 bool IsDeclared(const AstRawString* name) { |
419 // During formal parameter list parsing the scope only contains | 426 // During formal parameter list parsing the scope only contains |
420 // two variables inserted at initialization: "this" and "arguments". | 427 // two variables inserted at initialization: "this" and "arguments". |
421 // "this" is an invalid parameter name and "arguments" is invalid parameter | 428 // "this" is an invalid parameter name and "arguments" is invalid parameter |
422 // name in strict mode. Therefore looking up with the map which includes | 429 // name in strict mode. Therefore looking up with the map which includes |
423 // "this" and "arguments" in addition to all formal parameters is safe. | 430 // "this" and "arguments" in addition to all formal parameters is safe. |
424 return variables_.Lookup(name) != NULL; | 431 return variables_.Lookup(name) != NULL; |
425 } | 432 } |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 void AllocateModuleVariables(); | 898 void AllocateModuleVariables(); |
892 | 899 |
893 private: | 900 private: |
894 ModuleDescriptor* module_descriptor_; | 901 ModuleDescriptor* module_descriptor_; |
895 }; | 902 }; |
896 | 903 |
897 } // namespace internal | 904 } // namespace internal |
898 } // namespace v8 | 905 } // namespace v8 |
899 | 906 |
900 #endif // V8_AST_SCOPES_H_ | 907 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |