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

Side by Side Diff: src/variables.h

Issue 1178903003: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Add test Created 5 years, 6 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/snapshot/snapshot-common.cc ('k') | src/x64/full-codegen-x64.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_VARIABLES_H_ 5 #ifndef V8_VARIABLES_H_
6 #define V8_VARIABLES_H_ 6 #define V8_VARIABLES_H_
7 7
8 #include "src/ast-value-factory.h" 8 #include "src/ast-value-factory.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool is_const_mode() const { return IsImmutableVariableMode(mode_); } 98 bool is_const_mode() const { return IsImmutableVariableMode(mode_); }
99 bool binding_needs_init() const { 99 bool binding_needs_init() const {
100 return initialization_flag_ == kNeedsInitialization; 100 return initialization_flag_ == kNeedsInitialization;
101 } 101 }
102 102
103 bool is_function() const { return kind_ == FUNCTION; } 103 bool is_function() const { return kind_ == FUNCTION; }
104 bool is_class() const { return kind_ == CLASS; } 104 bool is_class() const { return kind_ == CLASS; }
105 bool is_this() const { return kind_ == THIS; } 105 bool is_this() const { return kind_ == THIS; }
106 bool is_arguments() const { return kind_ == ARGUMENTS; } 106 bool is_arguments() const { return kind_ == ARGUMENTS; }
107 107
108 // For script scopes, the "this" binding is provided by a ScriptContext added
109 // to the global's ScriptContextTable. This binding might not statically
110 // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However
111 // any variable named "this" does indeed refer to a Variable::THIS binding;
112 // the grammar ensures this to be the case. So wherever a "this" binding
113 // might be provided by the global, use HasThisName instead of is_this().
114 bool HasThisName(Isolate* isolate) const {
115 return is_this() || *name() == *isolate->factory()->this_string();
116 }
117
108 ClassVariable* AsClassVariable() { 118 ClassVariable* AsClassVariable() {
109 DCHECK(is_class()); 119 DCHECK(is_class());
110 return reinterpret_cast<ClassVariable*>(this); 120 return reinterpret_cast<ClassVariable*>(this);
111 } 121 }
112 122
113 // True if the variable is named eval and not known to be shadowed. 123 // True if the variable is named eval and not known to be shadowed.
114 bool is_possibly_eval(Isolate* isolate) const { 124 bool is_possibly_eval(Isolate* isolate) const {
115 return IsVariable(isolate->factory()->eval_string()); 125 return IsVariable(isolate->factory()->eval_string());
116 } 126 }
117 127
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 210
201 private: 211 private:
202 // For classes we keep track of consecutive groups of delcarations. They are 212 // For classes we keep track of consecutive groups of delcarations. They are
203 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement 213 // needed for strong mode scoping checks. TODO(marja, rossberg): Implement
204 // checks for functions too. 214 // checks for functions too.
205 int declaration_group_start_; 215 int declaration_group_start_;
206 }; 216 };
207 } } // namespace v8::internal 217 } } // namespace v8::internal
208 218
209 #endif // V8_VARIABLES_H_ 219 #endif // V8_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/snapshot/snapshot-common.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698