| 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_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
| 6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
| 10 #include "src/zone.h" | 10 #include "src/zone.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 // Compute top scope and allocate variables. For lazy compilation the top | 78 // Compute top scope and allocate variables. For lazy compilation the top |
| 79 // scope only contains the single lazily compiled function, so this | 79 // scope only contains the single lazily compiled function, so this |
| 80 // doesn't re-allocate variables repeatedly. | 80 // doesn't re-allocate variables repeatedly. |
| 81 static bool Analyze(ParseInfo* info); | 81 static bool Analyze(ParseInfo* info); |
| 82 | 82 |
| 83 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, | 83 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, |
| 84 Context* context, Scope* script_scope); | 84 Context* context, Scope* script_scope); |
| 85 | 85 |
| 86 // The scope name is only used for printing/debugging. | 86 // The scope name is only used for printing/debugging. |
| 87 Handle<String> ScopeName() { return scope_name_->string(); } |
| 87 void SetScopeName(const AstRawString* scope_name) { | 88 void SetScopeName(const AstRawString* scope_name) { |
| 88 scope_name_ = scope_name; | 89 scope_name_ = scope_name; |
| 89 } | 90 } |
| 90 | 91 |
| 91 void Initialize(); | 92 void Initialize(); |
| 92 | 93 |
| 93 // Checks if the block scope is redundant, i.e. it does not contain any | 94 // Checks if the block scope is redundant, i.e. it does not contain any |
| 94 // block scoped declarations. In that case it is removed from the scope | 95 // block scoped declarations. In that case it is removed from the scope |
| 95 // tree and its children are reparented. | 96 // tree and its children are reparented. |
| 96 Scope* FinalizeBlockScope(); | 97 Scope* FinalizeBlockScope(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | 217 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
| 217 | 218 |
| 218 // Inform the scope that the corresponding code uses "super". | 219 // Inform the scope that the corresponding code uses "super". |
| 219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 220 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
| 220 | 221 |
| 221 // Set the language mode flag (unless disabled by a global flag). | 222 // Set the language mode flag (unless disabled by a global flag). |
| 222 void SetLanguageMode(LanguageMode language_mode) { | 223 void SetLanguageMode(LanguageMode language_mode) { |
| 223 language_mode_ = language_mode; | 224 language_mode_ = language_mode; |
| 224 } | 225 } |
| 225 | 226 |
| 227 // Set asm.js mode. |
| 228 void SetAsmMode(AsmMode asm_mode) { |
| 229 DCHECK(FLAG_asm || asm_mode == ASM_NO); |
| 230 asm_mode_ = asm_mode; |
| 231 if (asm_mode == ASM_FUNCTION) ForceEagerCompilation(); |
| 232 } |
| 233 |
| 226 // Set the ASM module flag. | 234 // Set the ASM module flag. |
| 227 void SetAsmModule() { asm_module_ = true; } | 235 void SetAsmModule() { asm_module_ = true; } |
| 228 | 236 |
| 229 // Position in the source where this scope begins and ends. | 237 // Position in the source where this scope begins and ends. |
| 230 // | 238 // |
| 231 // * For the scope of a with statement | 239 // * For the scope of a with statement |
| 232 // with (obj) stmt | 240 // with (obj) stmt |
| 233 // start position: start position of first token of 'stmt' | 241 // start position: start position of first token of 'stmt' |
| 234 // end position: end position of last token of 'stmt' | 242 // end position: end position of last token of 'stmt' |
| 235 // * For the scope of a block | 243 // * For the scope of a block |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // --------------------------------------------------------------------------- | 342 // --------------------------------------------------------------------------- |
| 335 // Accessors. | 343 // Accessors. |
| 336 | 344 |
| 337 // The type of this scope. | 345 // The type of this scope. |
| 338 ScopeType scope_type() const { return scope_type_; } | 346 ScopeType scope_type() const { return scope_type_; } |
| 339 | 347 |
| 340 FunctionKind function_kind() const { return function_kind_; } | 348 FunctionKind function_kind() const { return function_kind_; } |
| 341 | 349 |
| 342 // The language mode of this scope. | 350 // The language mode of this scope. |
| 343 LanguageMode language_mode() const { return language_mode_; } | 351 LanguageMode language_mode() const { return language_mode_; } |
| 352 AsmMode asm_mode() const { return asm_mode_; } |
| 344 | 353 |
| 345 // The variable corresponding to the 'this' value. | 354 // The variable corresponding to the 'this' value. |
| 346 Variable* receiver() { | 355 Variable* receiver() { |
| 347 DCHECK(has_this_declaration()); | 356 DCHECK(has_this_declaration()); |
| 348 DCHECK_NOT_NULL(receiver_); | 357 DCHECK_NOT_NULL(receiver_); |
| 349 return receiver_; | 358 return receiver_; |
| 350 } | 359 } |
| 351 | 360 |
| 352 Variable* LookupThis() { return Lookup(ast_value_factory_->this_string()); } | 361 Variable* LookupThis() { return Lookup(ast_value_factory_->this_string()); } |
| 353 | 362 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // This scope uses "arguments". | 608 // This scope uses "arguments". |
| 600 bool scope_uses_arguments_; | 609 bool scope_uses_arguments_; |
| 601 // This scope uses "super" property ('super.foo'). | 610 // This scope uses "super" property ('super.foo'). |
| 602 bool scope_uses_super_property_; | 611 bool scope_uses_super_property_; |
| 603 // This scope contains an "use asm" annotation. | 612 // This scope contains an "use asm" annotation. |
| 604 bool asm_module_; | 613 bool asm_module_; |
| 605 // This scope's outer context is an asm module. | 614 // This scope's outer context is an asm module. |
| 606 bool asm_function_; | 615 bool asm_function_; |
| 607 // The language mode of this scope. | 616 // The language mode of this scope. |
| 608 LanguageMode language_mode_; | 617 LanguageMode language_mode_; |
| 618 AsmMode asm_mode_; |
| 609 // Source positions. | 619 // Source positions. |
| 610 int start_position_; | 620 int start_position_; |
| 611 int end_position_; | 621 int end_position_; |
| 612 | 622 |
| 613 // Computed via PropagateScopeInfo. | 623 // Computed via PropagateScopeInfo. |
| 614 bool outer_scope_calls_sloppy_eval_; | 624 bool outer_scope_calls_sloppy_eval_; |
| 615 bool inner_scope_calls_eval_; | 625 bool inner_scope_calls_eval_; |
| 616 bool inner_scope_uses_arguments_; | 626 bool inner_scope_uses_arguments_; |
| 617 bool force_eager_compilation_; | 627 bool force_eager_compilation_; |
| 618 bool force_context_allocation_; | 628 bool force_context_allocation_; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 PendingCompilationErrorHandler pending_error_handler_; | 776 PendingCompilationErrorHandler pending_error_handler_; |
| 767 | 777 |
| 768 // For tracking which classes are declared consecutively. Needed for strong | 778 // For tracking which classes are declared consecutively. Needed for strong |
| 769 // mode. | 779 // mode. |
| 770 int class_declaration_group_start_; | 780 int class_declaration_group_start_; |
| 771 }; | 781 }; |
| 772 | 782 |
| 773 } } // namespace v8::internal | 783 } } // namespace v8::internal |
| 774 | 784 |
| 775 #endif // V8_SCOPES_H_ | 785 #endif // V8_SCOPES_H_ |
| OLD | NEW |