Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

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