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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // parameters the rightmost one 'wins'. However, the implementation | 708 // parameters the rightmost one 'wins'. However, the implementation |
708 // expects all parameters to be declared and from left to right. | 709 // expects all parameters to be declared and from left to right. |
709 Variable* DeclareParameter(const AstRawString* name, VariableMode mode, | 710 Variable* DeclareParameter(const AstRawString* name, VariableMode mode, |
710 bool is_optional, bool is_rest, bool* is_duplicate, | 711 bool is_optional, bool is_rest, bool* is_duplicate, |
711 AstValueFactory* ast_value_factory); | 712 AstValueFactory* ast_value_factory); |
712 | 713 |
713 // Declare an implicit global variable in this scope which must be a | 714 // Declare an implicit global variable in this scope which must be a |
714 // script scope. The variable was introduced (possibly from an inner | 715 // script scope. The variable was introduced (possibly from an inner |
715 // scope) by a reference to an unresolved variable with no intervening | 716 // scope) by a reference to an unresolved variable with no intervening |
716 // with statements or eval calls. | 717 // with statements or eval calls. |
717 Variable* DeclareDynamicGlobal(const AstRawString* name); | 718 Variable* DeclareDynamicGlobal(const AstRawString* name, |
| 719 Variable::Kind variable_kind); |
718 | 720 |
719 // The variable corresponding to the 'this' value. | 721 // The variable corresponding to the 'this' value. |
720 Variable* receiver() { | 722 Variable* receiver() { |
721 DCHECK(has_this_declaration()); | 723 DCHECK(has_this_declaration()); |
722 DCHECK_NOT_NULL(receiver_); | 724 DCHECK_NOT_NULL(receiver_); |
723 return receiver_; | 725 return receiver_; |
724 } | 726 } |
725 | 727 |
726 // TODO(wingo): Add a GLOBAL_SCOPE scope type which will lexically allocate | 728 // TODO(wingo): Add a GLOBAL_SCOPE scope type which will lexically allocate |
727 // "this" (and no other variable) on the native context. Script scopes then | 729 // "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... |
897 // Convenience variable; Subclass constructor only | 899 // Convenience variable; Subclass constructor only |
898 Variable* this_function_; | 900 Variable* this_function_; |
899 // Module descriptor; module scopes only. | 901 // Module descriptor; module scopes only. |
900 ModuleDescriptor* module_descriptor_; | 902 ModuleDescriptor* module_descriptor_; |
901 }; | 903 }; |
902 | 904 |
903 } // namespace internal | 905 } // namespace internal |
904 } // namespace v8 | 906 } // namespace v8 |
905 | 907 |
906 #endif // V8_AST_SCOPES_H_ | 908 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |