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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // True if it doesn't need scope resolution (e.g., if the scope was | 515 // True if it doesn't need scope resolution (e.g., if the scope was |
516 // constructed based on a serialized scope info or a catch context). | 516 // constructed based on a serialized scope info or a catch context). |
517 bool already_resolved_ : 1; | 517 bool already_resolved_ : 1; |
518 bool already_resolved() { return already_resolved_; } | 518 bool already_resolved() { return already_resolved_; } |
519 | 519 |
520 // True if it holds 'var' declarations. | 520 // True if it holds 'var' declarations. |
521 bool is_declaration_scope_ : 1; | 521 bool is_declaration_scope_ : 1; |
522 | 522 |
523 // Create a non-local variable with a given name. | 523 // Create a non-local variable with a given name. |
524 // These variables are looked up dynamically at runtime. | 524 // These variables are looked up dynamically at runtime. |
525 Variable* NonLocal(const AstRawString* name, VariableMode mode); | 525 Variable* NonLocal(const AstRawString* name, VariableMode mode, |
| 526 Variable::Kind variable_kind); |
526 | 527 |
527 // Variable resolution. | 528 // Variable resolution. |
528 // Possible results of a recursive variable lookup telling if and how a | 529 // Possible results of a recursive variable lookup telling if and how a |
529 // variable is bound. These are returned in the output parameter *binding_kind | 530 // variable is bound. These are returned in the output parameter *binding_kind |
530 // of the LookupRecursive function. | 531 // of the LookupRecursive function. |
531 enum BindingKind { | 532 enum BindingKind { |
532 // The variable reference could be statically resolved to a variable binding | 533 // The variable reference could be statically resolved to a variable binding |
533 // which is returned. There is no 'with' statement between the reference and | 534 // which is returned. There is no 'with' statement between the reference and |
534 // the binding and no scope between the reference scope (inclusive) and | 535 // the binding and no scope between the reference scope (inclusive) and |
535 // binding scope (exclusive) makes a sloppy 'eval' call. | 536 // binding scope (exclusive) makes a sloppy 'eval' call. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 // parameters the rightmost one 'wins'. However, the implementation | 701 // parameters the rightmost one 'wins'. However, the implementation |
701 // expects all parameters to be declared and from left to right. | 702 // expects all parameters to be declared and from left to right. |
702 Variable* DeclareParameter(const AstRawString* name, VariableMode mode, | 703 Variable* DeclareParameter(const AstRawString* name, VariableMode mode, |
703 bool is_optional, bool is_rest, bool* is_duplicate, | 704 bool is_optional, bool is_rest, bool* is_duplicate, |
704 AstValueFactory* ast_value_factory); | 705 AstValueFactory* ast_value_factory); |
705 | 706 |
706 // Declare an implicit global variable in this scope which must be a | 707 // Declare an implicit global variable in this scope which must be a |
707 // script scope. The variable was introduced (possibly from an inner | 708 // script scope. The variable was introduced (possibly from an inner |
708 // scope) by a reference to an unresolved variable with no intervening | 709 // scope) by a reference to an unresolved variable with no intervening |
709 // with statements or eval calls. | 710 // with statements or eval calls. |
710 Variable* DeclareDynamicGlobal(const AstRawString* name); | 711 Variable* DeclareDynamicGlobal(const AstRawString* name, |
| 712 Variable::Kind variable_kind); |
711 | 713 |
712 // The variable corresponding to the 'this' value. | 714 // The variable corresponding to the 'this' value. |
713 Variable* receiver() { | 715 Variable* receiver() { |
714 DCHECK(has_this_declaration()); | 716 DCHECK(has_this_declaration()); |
715 DCHECK_NOT_NULL(receiver_); | 717 DCHECK_NOT_NULL(receiver_); |
716 return receiver_; | 718 return receiver_; |
717 } | 719 } |
718 | 720 |
719 // TODO(wingo): Add a GLOBAL_SCOPE scope type which will lexically allocate | 721 // TODO(wingo): Add a GLOBAL_SCOPE scope type which will lexically allocate |
720 // "this" (and no other variable) on the native context. Script scopes then | 722 // "this" (and no other variable) on the native context. Script scopes then |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // Convenience variable; Subclass constructor only | 892 // Convenience variable; Subclass constructor only |
891 Variable* this_function_; | 893 Variable* this_function_; |
892 // Module descriptor; module scopes only. | 894 // Module descriptor; module scopes only. |
893 ModuleDescriptor* module_descriptor_; | 895 ModuleDescriptor* module_descriptor_; |
894 }; | 896 }; |
895 | 897 |
896 } // namespace internal | 898 } // namespace internal |
897 } // namespace v8 | 899 } // namespace v8 |
898 | 900 |
899 #endif // V8_AST_SCOPES_H_ | 901 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |