OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 273 |
274 // Specific scope types. | 274 // Specific scope types. |
275 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } | 275 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } |
276 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } | 276 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } |
277 bool is_module_scope() const { return type_ == MODULE_SCOPE; } | 277 bool is_module_scope() const { return type_ == MODULE_SCOPE; } |
278 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } | 278 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } |
279 bool is_catch_scope() const { return type_ == CATCH_SCOPE; } | 279 bool is_catch_scope() const { return type_ == CATCH_SCOPE; } |
280 bool is_block_scope() const { return type_ == BLOCK_SCOPE; } | 280 bool is_block_scope() const { return type_ == BLOCK_SCOPE; } |
281 bool is_with_scope() const { return type_ == WITH_SCOPE; } | 281 bool is_with_scope() const { return type_ == WITH_SCOPE; } |
282 bool is_declaration_scope() const { | 282 bool is_declaration_scope() const { |
283 return is_eval_scope() || is_function_scope() || is_global_scope(); | 283 return is_eval_scope() || is_function_scope() || |
284 is_module_scope() || is_global_scope(); | |
284 } | 285 } |
285 bool is_classic_mode() const { | 286 bool is_classic_mode() const { |
286 return language_mode() == CLASSIC_MODE; | 287 return language_mode() == CLASSIC_MODE; |
287 } | 288 } |
288 bool is_extended_mode() const { | 289 bool is_extended_mode() const { |
289 return language_mode() == EXTENDED_MODE; | 290 return language_mode() == EXTENDED_MODE; |
290 } | 291 } |
291 bool is_strict_or_extended_eval_scope() const { | 292 bool is_strict_or_extended_eval_scope() const { |
292 return is_eval_scope() && !is_classic_mode(); | 293 return is_eval_scope() && !is_classic_mode(); |
293 } | 294 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 // processed (parsed) to ensure that unresolved variables can be | 586 // processed (parsed) to ensure that unresolved variables can be |
586 // resolved properly. | 587 // resolved properly. |
587 // | 588 // |
588 // In the case of code compiled and run using 'eval', the context | 589 // In the case of code compiled and run using 'eval', the context |
589 // parameter is the context in which eval was called. In all other | 590 // parameter is the context in which eval was called. In all other |
590 // cases the context parameter is an empty handle. | 591 // cases the context parameter is an empty handle. |
591 MUST_USE_RESULT | 592 MUST_USE_RESULT |
592 bool AllocateVariables(CompilationInfo* info, | 593 bool AllocateVariables(CompilationInfo* info, |
593 AstNodeFactory<AstNullVisitor>* factory); | 594 AstNodeFactory<AstNullVisitor>* factory); |
594 | 595 |
596 // Instance objects have to be created ahead of time (before code generation) | |
597 // because of potentially cyclic references between them. | |
598 // Linking also has to be a separate stage, since populating one object may | |
599 // may potentially requires (forward) references to others. | |
Michael Starzinger
2012/07/06 10:53:22
Drop one "may" and "s/requires/require".
rossberg
2012/07/06 15:39:28
Done.
| |
600 void AllocateModules(CompilationInfo* info); | |
601 void LinkModules(CompilationInfo* info); | |
602 | |
595 private: | 603 private: |
596 // Construct a scope based on the scope info. | 604 // Construct a scope based on the scope info. |
597 Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info, | 605 Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info, |
598 Zone* zone); | 606 Zone* zone); |
599 | 607 |
600 // Construct a catch scope with a binding for the name. | 608 // Construct a catch scope with a binding for the name. |
601 Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone); | 609 Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone); |
602 | 610 |
603 void AddInnerScope(Scope* inner_scope) { | 611 void AddInnerScope(Scope* inner_scope) { |
604 if (inner_scope != NULL) { | 612 if (inner_scope != NULL) { |
605 inner_scopes_.Add(inner_scope, zone_); | 613 inner_scopes_.Add(inner_scope, zone_); |
606 inner_scope->outer_scope_ = this; | 614 inner_scope->outer_scope_ = this; |
607 } | 615 } |
608 } | 616 } |
609 | 617 |
610 void SetDefaults(ScopeType type, | 618 void SetDefaults(ScopeType type, |
611 Scope* outer_scope, | 619 Scope* outer_scope, |
612 Handle<ScopeInfo> scope_info); | 620 Handle<ScopeInfo> scope_info); |
613 | 621 |
614 Zone* zone_; | 622 Zone* zone_; |
615 }; | 623 }; |
616 | 624 |
617 } } // namespace v8::internal | 625 } } // namespace v8::internal |
618 | 626 |
619 #endif // V8_SCOPES_H_ | 627 #endif // V8_SCOPES_H_ |
OLD | NEW |