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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 // Determine if we can parse a function literal in this scope lazily. | 376 // Determine if we can parse a function literal in this scope lazily. |
377 bool AllowsLazyParsing() const; | 377 bool AllowsLazyParsing() const; |
378 | 378 |
379 // Determine if we can use lazy compilation for this scope. | 379 // Determine if we can use lazy compilation for this scope. |
380 bool AllowsLazyCompilation() const; | 380 bool AllowsLazyCompilation() const; |
381 | 381 |
382 // Determine if we can use lazy compilation for this scope without a context. | 382 // Determine if we can use lazy compilation for this scope without a context. |
383 bool AllowsLazyCompilationWithoutContext() const; | 383 bool AllowsLazyCompilationWithoutContext() const; |
384 | 384 |
385 // True if the outer context of this scope is always the native context. | |
386 bool HasTrivialOuterContext() const; | |
387 | |
388 // The number of contexts between this and scope; zero if this == scope. | 385 // The number of contexts between this and scope; zero if this == scope. |
389 int ContextChainLength(Scope* scope); | 386 int ContextChainLength(Scope* scope); |
390 | 387 |
391 // The maximum number of nested contexts required for this scope and any inner | 388 // The maximum number of nested contexts required for this scope and any inner |
392 // scopes. | 389 // scopes. |
393 int MaxNestedContextChainLength(); | 390 int MaxNestedContextChainLength(); |
394 | 391 |
395 // Find the first function, script, eval or (declaration) block scope. This is | 392 // Find the first function, script, eval or (declaration) block scope. This is |
396 // the scope where var declarations will be hoisted to in the implementation. | 393 // the scope where var declarations will be hoisted to in the implementation. |
397 DeclarationScope* GetDeclarationScope(); | 394 DeclarationScope* GetDeclarationScope(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 AstNodeFactory* factory); | 583 AstNodeFactory* factory); |
587 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); | 584 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); |
588 | 585 |
589 // Finds free variables of this scope. This mutates the unresolved variables | 586 // Finds free variables of this scope. This mutates the unresolved variables |
590 // list along the way, so full resolution cannot be done afterwards. | 587 // list along the way, so full resolution cannot be done afterwards. |
591 // If a ParseInfo* is passed, non-free variables will be resolved. | 588 // If a ParseInfo* is passed, non-free variables will be resolved. |
592 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, | 589 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, |
593 ParseInfo* info = nullptr, | 590 ParseInfo* info = nullptr, |
594 VariableProxy* stack = nullptr); | 591 VariableProxy* stack = nullptr); |
595 | 592 |
596 bool InsideWithScope() const { | |
597 for (const Scope* scope = this; scope != nullptr; | |
598 scope = scope->outer_scope()) { | |
599 if (scope->is_with_scope()) return true; | |
600 } | |
601 return false; | |
602 } | |
603 | |
604 // Scope analysis. | 593 // Scope analysis. |
605 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); | 594 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); |
606 bool HasTrivialContext() const; | |
607 | 595 |
608 // Predicates. | 596 // Predicates. |
609 bool MustAllocate(Variable* var); | 597 bool MustAllocate(Variable* var); |
610 bool MustAllocateInContext(Variable* var); | 598 bool MustAllocateInContext(Variable* var); |
611 | 599 |
612 // Variable allocation. | 600 // Variable allocation. |
613 void AllocateStackSlot(Variable* var); | 601 void AllocateStackSlot(Variable* var); |
614 void AllocateHeapSlot(Variable* var); | 602 void AllocateHeapSlot(Variable* var); |
615 void AllocateNonParameterLocal(Variable* var); | 603 void AllocateNonParameterLocal(Variable* var); |
616 void AllocateDeclaredGlobal(Variable* var); | 604 void AllocateDeclaredGlobal(Variable* var); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 void AllocateModuleVariables(); | 893 void AllocateModuleVariables(); |
906 | 894 |
907 private: | 895 private: |
908 ModuleDescriptor* module_descriptor_; | 896 ModuleDescriptor* module_descriptor_; |
909 }; | 897 }; |
910 | 898 |
911 } // namespace internal | 899 } // namespace internal |
912 } // namespace v8 | 900 } // namespace v8 |
913 | 901 |
914 #endif // V8_AST_SCOPES_H_ | 902 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |