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

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

Issue 2233673003: Remove CONST_LEGACY VariableMode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_VARIABLES_H_ 5 #ifndef V8_AST_VARIABLES_H_
6 #define V8_AST_VARIABLES_H_ 6 #define V8_AST_VARIABLES_H_
7 7
8 #include "src/ast/ast-value-factory.h" 8 #include "src/ast/ast-value-factory.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 // The AST refers to variables via VariableProxies - placeholders for the actual 14 // The AST refers to variables via VariableProxies - placeholders for the actual
15 // variables. Variables themselves are never directly referred to from the AST, 15 // variables. Variables themselves are never directly referred to from the AST,
16 // they are maintained by scopes, and referred to from VariableProxies and Slots 16 // they are maintained by scopes, and referred to from VariableProxies and Slots
17 // after binding and variable allocation. 17 // after binding and variable allocation.
18 class Variable: public ZoneObject { 18 class Variable: public ZoneObject {
19 public: 19 public:
20 enum Kind { NORMAL, FUNCTION, THIS, ARGUMENTS }; 20 enum Kind { NORMAL, FUNCTION, THIS, ARGUMENTS, SLOPPY_FUNCTION_NAME };
21 21
22 Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind, 22 Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind,
23 InitializationFlag initialization_flag, 23 InitializationFlag initialization_flag,
24 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); 24 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
25 25
26 virtual ~Variable() {} 26 virtual ~Variable() {}
27 27
28 // Printing support 28 // Printing support
29 static const char* Mode2String(VariableMode mode); 29 static const char* Mode2String(VariableMode mode);
30 30
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool IsContextSlot() const { return location_ == VariableLocation::CONTEXT; } 64 bool IsContextSlot() const { return location_ == VariableLocation::CONTEXT; }
65 bool IsGlobalSlot() const { return location_ == VariableLocation::GLOBAL; } 65 bool IsGlobalSlot() const { return location_ == VariableLocation::GLOBAL; }
66 bool IsUnallocatedOrGlobalSlot() const { 66 bool IsUnallocatedOrGlobalSlot() const {
67 return IsUnallocated() || IsGlobalSlot(); 67 return IsUnallocated() || IsGlobalSlot();
68 } 68 }
69 bool IsLookupSlot() const { return location_ == VariableLocation::LOOKUP; } 69 bool IsLookupSlot() const { return location_ == VariableLocation::LOOKUP; }
70 bool IsGlobalObjectProperty() const; 70 bool IsGlobalObjectProperty() const;
71 bool IsStaticGlobalObjectProperty() const; 71 bool IsStaticGlobalObjectProperty() const;
72 72
73 bool is_dynamic() const { return IsDynamicVariableMode(mode_); } 73 bool is_dynamic() const { return IsDynamicVariableMode(mode_); }
74 bool is_const_mode() const { return IsImmutableVariableMode(mode_); }
75 bool binding_needs_init() const { 74 bool binding_needs_init() const {
76 return initialization_flag_ == kNeedsInitialization; 75 return initialization_flag_ == kNeedsInitialization;
77 } 76 }
77 bool throw_on_const_assignment(LanguageMode language_mode) const {
78 return kind_ != SLOPPY_FUNCTION_NAME || is_strict(language_mode);
79 }
78 80
79 bool is_function() const { return kind_ == FUNCTION; } 81 bool is_function() const { return kind_ == FUNCTION; }
80 bool is_this() const { return kind_ == THIS; } 82 bool is_this() const { return kind_ == THIS; }
81 bool is_arguments() const { return kind_ == ARGUMENTS; } 83 bool is_arguments() const { return kind_ == ARGUMENTS; }
82 84
83 // For script scopes, the "this" binding is provided by a ScriptContext added 85 // For script scopes, the "this" binding is provided by a ScriptContext added
84 // to the global's ScriptContextTable. This binding might not statically 86 // to the global's ScriptContextTable. This binding might not statically
85 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However 87 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However
86 // any variable named "this" does indeed refer to a Variable::THIS binding; 88 // any variable named "this" does indeed refer to a Variable::THIS binding;
87 // the grammar ensures this to be the case. So wherever a "this" binding 89 // the grammar ensures this to be the case. So wherever a "this" binding
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Usage info. 163 // Usage info.
162 bool force_context_allocation_; // set by variable resolver 164 bool force_context_allocation_; // set by variable resolver
163 bool is_used_; 165 bool is_used_;
164 InitializationFlag initialization_flag_; 166 InitializationFlag initialization_flag_;
165 MaybeAssignedFlag maybe_assigned_; 167 MaybeAssignedFlag maybe_assigned_;
166 }; 168 };
167 } // namespace internal 169 } // namespace internal
168 } // namespace v8 170 } // namespace v8
169 171
170 #endif // V8_AST_VARIABLES_H_ 172 #endif // V8_AST_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/ast/variables.cc » ('j') | src/compiler/ast-graph-builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698