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

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: 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 | « src/ast/scopes.cc ('k') | src/ast/variables.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 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 bool binding_needs_init() const { 75 bool binding_needs_init() const {
76 DCHECK(initialization_flag_ != kNeedsInitialization || 76 DCHECK(initialization_flag_ != kNeedsInitialization ||
77 IsLexicalVariableMode(mode_)); 77 IsLexicalVariableMode(mode_));
78 return initialization_flag_ == kNeedsInitialization; 78 return initialization_flag_ == kNeedsInitialization;
79 } 79 }
80 80
81 bool is_function() const { return kind_ == FUNCTION; } 81 bool is_function() const { return kind_ == FUNCTION; }
82 bool is_this() const { return kind_ == THIS; } 82 bool is_this() const { return kind_ == THIS; }
83 bool is_arguments() const { return kind_ == ARGUMENTS; } 83 bool is_arguments() const { return kind_ == ARGUMENTS; }
84 84
85 // For script scopes, the "this" binding is provided by a ScriptContext added
86 // to the global's ScriptContextTable. This binding might not statically
87 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However
88 // any variable named "this" does indeed refer to a Variable::THIS binding;
89 // the grammar ensures this to be the case. So wherever a "this" binding
90 // might be provided by the global, use HasThisName instead of is_this().
91 bool HasThisName(Isolate* isolate,
92 HandleDereferenceMode deref_mode =
93 HandleDereferenceMode::kAllowed) const {
94 // Note: it is safe to dereference isolate->factory()->this_string() here
95 // regardless of |deref_mode| because it is a constant root and so will
96 // never be updated or moved.
97 return is_this() ||
98 name_is_identical_to(isolate->factory()->this_string(), deref_mode);
99 }
100
101 // True if the variable is named eval and not known to be shadowed. 85 // True if the variable is named eval and not known to be shadowed.
102 bool is_possibly_eval(Isolate* isolate, 86 bool is_possibly_eval(Isolate* isolate,
103 HandleDereferenceMode deref_mode = 87 HandleDereferenceMode deref_mode =
104 HandleDereferenceMode::kAllowed) const { 88 HandleDereferenceMode::kAllowed) const {
105 // Note: it is safe to dereference isolate->factory()->eval_string() here 89 // Note: it is safe to dereference isolate->factory()->eval_string() here
106 // regardless of |deref_mode| because it is a constant root and so will 90 // regardless of |deref_mode| because it is a constant root and so will
107 // never be updated or moved. 91 // never be updated or moved.
108 return !is_this() && 92 return !is_this() &&
109 name_is_identical_to(isolate->factory()->eval_string(), deref_mode); 93 name_is_identical_to(isolate->factory()->eval_string(), deref_mode);
110 } 94 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Usage info. 147 // Usage info.
164 bool force_context_allocation_; // set by variable resolver 148 bool force_context_allocation_; // set by variable resolver
165 bool is_used_; 149 bool is_used_;
166 InitializationFlag initialization_flag_; 150 InitializationFlag initialization_flag_;
167 MaybeAssignedFlag maybe_assigned_; 151 MaybeAssignedFlag maybe_assigned_;
168 }; 152 };
169 } // namespace internal 153 } // namespace internal
170 } // namespace v8 154 } // namespace v8
171 155
172 #endif // V8_AST_VARIABLES_H_ 156 #endif // V8_AST_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/ast/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698