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

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

Issue 2231813003: Make Variable::is_this always return the correct value (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove patch 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
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_); } 74 bool is_const_mode() const { return IsImmutableVariableMode(mode_); }
75 bool binding_needs_init() const { 75 bool binding_needs_init() const {
76 return initialization_flag_ == kNeedsInitialization; 76 return initialization_flag_ == kNeedsInitialization;
77 } 77 }
78 78
79 bool is_function() const { return kind_ == FUNCTION; } 79 bool is_function() const { return kind_ == FUNCTION; }
80 bool is_this() const { return kind_ == THIS; } 80 bool is_this() const { return kind_ == THIS; }
81 bool is_arguments() const { return kind_ == ARGUMENTS; } 81 bool is_arguments() const { return kind_ == ARGUMENTS; }
82 82
83 // For script scopes, the "this" binding is provided by a ScriptContext added
84 // to the global's ScriptContextTable. This binding might not statically
85 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However
86 // 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
88 // might be provided by the global, use HasThisName instead of is_this().
89 bool HasThisName(Isolate* isolate,
90 HandleDereferenceMode deref_mode =
91 HandleDereferenceMode::kAllowed) const {
92 // Note: it is safe to dereference isolate->factory()->this_string() here
93 // regardless of |deref_mode| because it is a constant root and so will
94 // never be updated or moved.
95 return is_this() ||
96 name_is_identical_to(isolate->factory()->this_string(), deref_mode);
97 }
98
99 // True if the variable is named eval and not known to be shadowed. 83 // True if the variable is named eval and not known to be shadowed.
100 bool is_possibly_eval(Isolate* isolate, 84 bool is_possibly_eval(Isolate* isolate,
101 HandleDereferenceMode deref_mode = 85 HandleDereferenceMode deref_mode =
102 HandleDereferenceMode::kAllowed) const { 86 HandleDereferenceMode::kAllowed) const {
103 // Note: it is safe to dereference isolate->factory()->eval_string() here 87 // Note: it is safe to dereference isolate->factory()->eval_string() here
104 // regardless of |deref_mode| because it is a constant root and so will 88 // regardless of |deref_mode| because it is a constant root and so will
105 // never be updated or moved. 89 // never be updated or moved.
106 return !is_this() && 90 return !is_this() &&
107 name_is_identical_to(isolate->factory()->eval_string(), deref_mode); 91 name_is_identical_to(isolate->factory()->eval_string(), deref_mode);
108 } 92 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Usage info. 145 // Usage info.
162 bool force_context_allocation_; // set by variable resolver 146 bool force_context_allocation_; // set by variable resolver
163 bool is_used_; 147 bool is_used_;
164 InitializationFlag initialization_flag_; 148 InitializationFlag initialization_flag_;
165 MaybeAssignedFlag maybe_assigned_; 149 MaybeAssignedFlag maybe_assigned_;
166 }; 150 };
167 } // namespace internal 151 } // namespace internal
168 } // namespace v8 152 } // namespace v8
169 153
170 #endif // V8_AST_VARIABLES_H_ 154 #endif // V8_AST_VARIABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698