Chromium Code Reviews

Side by Side Diff: src/ast/scopes.h

Issue 2218083002: Remove bool result from analyze since it's always true (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: undo zone change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/pending-compilation-error-handler.h" 11 #include "src/pending-compilation-error-handler.h"
adamk 2016/08/05 17:51:10 I think you can drop this include now.
12 #include "src/zone.h" 12 #include "src/zone.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 class ParseInfo; 17 class ParseInfo;
18 18
19 // A hash map to support fast variable declaration and lookup. 19 // A hash map to support fast variable declaration and lookup.
20 class VariableMap: public ZoneHashMap { 20 class VariableMap: public ZoneHashMap {
21 public: 21 public:
(...skipping 98 matching lines...)
120 private: 120 private:
121 Scope* outer_scope_; 121 Scope* outer_scope_;
122 Scope* top_inner_scope_; 122 Scope* top_inner_scope_;
123 VariableProxy* top_unresolved_; 123 VariableProxy* top_unresolved_;
124 int top_temp_; 124 int top_temp_;
125 }; 125 };
126 126
127 // Compute top scope and allocate variables. For lazy compilation the top 127 // Compute top scope and allocate variables. For lazy compilation the top
128 // scope only contains the single lazily compiled function, so this 128 // scope only contains the single lazily compiled function, so this
129 // doesn't re-allocate variables repeatedly. 129 // doesn't re-allocate variables repeatedly.
130 static bool Analyze(ParseInfo* info); 130 static void Analyze(ParseInfo* info);
131 131
132 enum class DeserializationMode { kDeserializeOffHeap, kKeepScopeInfo }; 132 enum class DeserializationMode { kDeserializeOffHeap, kKeepScopeInfo };
133 133
134 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, 134 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
135 Context* context, 135 Context* context,
136 DeclarationScope* script_scope, 136 DeclarationScope* script_scope,
137 AstValueFactory* ast_value_factory, 137 AstValueFactory* ast_value_factory,
138 DeserializationMode deserialization_mode); 138 DeserializationMode deserialization_mode);
139 139
140 // Checks if the block scope is redundant, i.e. it does not contain any 140 // Checks if the block scope is redundant, i.e. it does not contain any
(...skipping 448 matching lines...)
589 DYNAMIC_LOOKUP 589 DYNAMIC_LOOKUP
590 }; 590 };
591 591
592 // Lookup a variable reference given by name recursively starting with this 592 // Lookup a variable reference given by name recursively starting with this
593 // scope, but only until max_outer_scope (if not nullptr). If the code is 593 // scope, but only until max_outer_scope (if not nullptr). If the code is
594 // executed because of a call to 'eval', the context parameter should be set 594 // executed because of a call to 'eval', the context parameter should be set
595 // to the calling context of 'eval'. 595 // to the calling context of 'eval'.
596 Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind, 596 Variable* LookupRecursive(VariableProxy* proxy, BindingKind* binding_kind,
597 AstNodeFactory* factory, 597 AstNodeFactory* factory,
598 Scope* max_outer_scope = nullptr); 598 Scope* max_outer_scope = nullptr);
599 MUST_USE_RESULT 599 void ResolveVariable(ParseInfo* info, VariableProxy* proxy,
600 bool ResolveVariable(ParseInfo* info, VariableProxy* proxy,
601 AstNodeFactory* factory); 600 AstNodeFactory* factory);
602 MUST_USE_RESULT 601 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
603 bool ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
604 602
605 // Tries to resolve local variables inside max_outer_scope; migrates those 603 // Tries to resolve local variables inside max_outer_scope; migrates those
606 // which cannot be resolved into migrate_to. 604 // which cannot be resolved into migrate_to.
607 void MigrateUnresolvableLocals(DeclarationScope* migrate_to, 605 void MigrateUnresolvableLocals(DeclarationScope* migrate_to,
608 AstNodeFactory* ast_node_factory, 606 AstNodeFactory* ast_node_factory,
609 DeclarationScope* max_outer_scope); 607 DeclarationScope* max_outer_scope);
610 608
611 // Scope analysis. 609 // Scope analysis.
612 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); 610 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval);
613 bool HasTrivialContext() const; 611 bool HasTrivialContext() const;
(...skipping 229 matching lines...)
843 } 841 }
844 842
845 // Resolve and fill in the allocation information for all variables 843 // Resolve and fill in the allocation information for all variables
846 // in this scopes. Must be called *after* all scopes have been 844 // in this scopes. Must be called *after* all scopes have been
847 // processed (parsed) to ensure that unresolved variables can be 845 // processed (parsed) to ensure that unresolved variables can be
848 // resolved properly. 846 // resolved properly.
849 // 847 //
850 // In the case of code compiled and run using 'eval', the context 848 // In the case of code compiled and run using 'eval', the context
851 // parameter is the context in which eval was called. In all other 849 // parameter is the context in which eval was called. In all other
852 // cases the context parameter is an empty handle. 850 // cases the context parameter is an empty handle.
853 MUST_USE_RESULT 851 void AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
854 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
855 852
856 // To be called during parsing. Do just enough scope analysis that we can 853 // To be called during parsing. Do just enough scope analysis that we can
857 // discard the Scope for lazily compiled functions. In particular, this 854 // discard the Scope for lazily compiled functions. In particular, this
858 // records variables which cannot be resolved inside the Scope (we don't yet 855 // records variables which cannot be resolved inside the Scope (we don't yet
859 // know what they will resolve to since the outer Scopes are incomplete) and 856 // know what they will resolve to since the outer Scopes are incomplete) and
860 // migrates them into migrate_to. 857 // migrates them into migrate_to.
861 void AnalyzePartially(DeclarationScope* migrate_to, 858 void AnalyzePartially(DeclarationScope* migrate_to,
862 AstNodeFactory* ast_node_factory); 859 AstNodeFactory* ast_node_factory);
863 860
864 #ifdef DEBUG 861 #ifdef DEBUG
(...skipping 31 matching lines...)
896 // Function variable, if any; function scopes only. 893 // Function variable, if any; function scopes only.
897 VariableDeclaration* function_; 894 VariableDeclaration* function_;
898 // new.target variable, function scopes only. 895 // new.target variable, function scopes only.
899 Variable* new_target_; 896 Variable* new_target_;
900 // Convenience variable; function scopes only. 897 // Convenience variable; function scopes only.
901 Variable* arguments_; 898 Variable* arguments_;
902 // Convenience variable; Subclass constructor only 899 // Convenience variable; Subclass constructor only
903 Variable* this_function_; 900 Variable* this_function_;
904 // Module descriptor; module scopes only. 901 // Module descriptor; module scopes only.
905 ModuleDescriptor* module_descriptor_; 902 ModuleDescriptor* module_descriptor_;
906 PendingCompilationErrorHandler pending_error_handler_;
907 }; 903 };
908 904
909 } // namespace internal 905 } // namespace internal
910 } // namespace v8 906 } // namespace v8
911 907
912 #endif // V8_AST_SCOPES_H_ 908 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine