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

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

Issue 2631173002: Scope cleanup: add default params for variable declaring functions. (Closed)
Patch Set: Created 3 years, 11 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/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/base/hashmap.h" 9 #include "src/base/hashmap.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 12 matching lines...) Expand all
23 class SloppyBlockFunctionStatement; 23 class SloppyBlockFunctionStatement;
24 class Statement; 24 class Statement;
25 class StringSet; 25 class StringSet;
26 class VariableProxy; 26 class VariableProxy;
27 27
28 // A hash map to support fast variable declaration and lookup. 28 // A hash map to support fast variable declaration and lookup.
29 class VariableMap: public ZoneHashMap { 29 class VariableMap: public ZoneHashMap {
30 public: 30 public:
31 explicit VariableMap(Zone* zone); 31 explicit VariableMap(Zone* zone);
32 32
33 Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name, 33 Variable* Declare(
34 VariableMode mode, VariableKind kind, 34 Zone* zone, Scope* scope, const AstRawString* name, VariableMode mode,
35 InitializationFlag initialization_flag, 35 VariableKind kind = NORMAL_VARIABLE,
36 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, 36 InitializationFlag initialization_flag = kCreatedInitialized,
37 bool* added = nullptr); 37 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
38 bool* added = nullptr);
38 39
39 // Records that "name" exists (if not recorded yet) but doesn't create a 40 // Records that "name" exists (if not recorded yet) but doesn't create a
40 // Variable. Useful for preparsing. 41 // Variable. Useful for preparsing.
41 void DeclareName(Zone* zone, const AstRawString* name, VariableMode mode); 42 void DeclareName(Zone* zone, const AstRawString* name, VariableMode mode);
42 43
43 Variable* Lookup(const AstRawString* name); 44 Variable* Lookup(const AstRawString* name);
44 void Remove(Variable* var); 45 void Remove(Variable* var);
45 void Add(Zone* zone, Variable* var); 46 void Add(Zone* zone, Variable* var);
46 }; 47 };
47 48
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 163
163 Variable* LookupInScopeInfo(const AstRawString* name); 164 Variable* LookupInScopeInfo(const AstRawString* name);
164 165
165 // Lookup a variable in this scope or outer scopes. 166 // Lookup a variable in this scope or outer scopes.
166 // Returns the variable or NULL if not found. 167 // Returns the variable or NULL if not found.
167 Variable* Lookup(const AstRawString* name); 168 Variable* Lookup(const AstRawString* name);
168 169
169 // Declare a local variable in this scope. If the variable has been 170 // Declare a local variable in this scope. If the variable has been
170 // declared before, the previously declared variable is returned. 171 // declared before, the previously declared variable is returned.
171 Variable* DeclareLocal(const AstRawString* name, VariableMode mode, 172 Variable* DeclareLocal(const AstRawString* name, VariableMode mode,
172 InitializationFlag init_flag, VariableKind kind, 173 InitializationFlag init_flag = kCreatedInitialized,
174 VariableKind kind = NORMAL_VARIABLE,
173 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); 175 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
174 176
175 Variable* DeclareVariable(Declaration* declaration, VariableMode mode, 177 Variable* DeclareVariable(Declaration* declaration, VariableMode mode,
176 InitializationFlag init, 178 InitializationFlag init,
177 bool allow_harmony_restrictive_generators, 179 bool allow_harmony_restrictive_generators,
178 bool* sloppy_mode_block_scope_function_redefinition, 180 bool* sloppy_mode_block_scope_function_redefinition,
179 bool* ok); 181 bool* ok);
180 182
181 void DeclareVariableName(const AstRawString* name, VariableMode mode); 183 void DeclareVariableName(const AstRawString* name, VariableMode mode);
182 184
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 462 }
461 463
462 protected: 464 protected:
463 explicit Scope(Zone* zone); 465 explicit Scope(Zone* zone);
464 466
465 void set_language_mode(LanguageMode language_mode) { 467 void set_language_mode(LanguageMode language_mode) {
466 is_strict_ = is_strict(language_mode); 468 is_strict_ = is_strict(language_mode);
467 } 469 }
468 470
469 private: 471 private:
470 Variable* Declare(Zone* zone, const AstRawString* name, VariableMode mode, 472 Variable* Declare(
471 VariableKind kind, InitializationFlag initialization_flag, 473 Zone* zone, const AstRawString* name, VariableMode mode,
472 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); 474 VariableKind kind = NORMAL_VARIABLE,
475 InitializationFlag initialization_flag = kCreatedInitialized,
476 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
473 477
474 // This method should only be invoked on scopes created during parsing (i.e., 478 // This method should only be invoked on scopes created during parsing (i.e.,
475 // not deserialized from a context). Also, since NeedsContext() is only 479 // not deserialized from a context). Also, since NeedsContext() is only
476 // returning a valid result after variables are resolved, NeedsScopeInfo() 480 // returning a valid result after variables are resolved, NeedsScopeInfo()
477 // should also be invoked after resolution. 481 // should also be invoked after resolution.
478 bool NeedsScopeInfo() const; 482 bool NeedsScopeInfo() const;
479 483
480 Zone* zone_; 484 Zone* zone_;
481 485
482 // Scope tree. 486 // Scope tree.
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 void AllocateModuleVariables(); 893 void AllocateModuleVariables();
890 894
891 private: 895 private:
892 ModuleDescriptor* module_descriptor_; 896 ModuleDescriptor* module_descriptor_;
893 }; 897 };
894 898
895 } // namespace internal 899 } // namespace internal
896 } // namespace v8 900 } // namespace v8
897 901
898 #endif // V8_AST_SCOPES_H_ 902 #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