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