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

Side by Side Diff: src/variables.h

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mjsunit/debug-scopes: Skip "this" the same as "arguments" Created 5 years, 10 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_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/interface.h" 9 #include "src/interface.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // corresponding scope. 46 // corresponding scope.
47 CONTEXT, 47 CONTEXT,
48 48
49 // A named slot in a heap context. name() is the variable name in the 49 // A named slot in a heap context. name() is the variable name in the
50 // context object on the heap, with lookup starting at the current 50 // context object on the heap, with lookup starting at the current
51 // context. index() is invalid. 51 // context. index() is invalid.
52 LOOKUP 52 LOOKUP
53 }; 53 };
54 54
55 Variable(Scope* scope, const AstRawString* name, VariableMode mode, 55 Variable(Scope* scope, const AstRawString* name, VariableMode mode,
56 bool is_valid_ref, Kind kind, InitializationFlag initialization_flag, 56 Kind kind, InitializationFlag initialization_flag,
57 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, 57 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
58 Interface* interface = Interface::NewValue()); 58 Interface* interface = Interface::NewValue());
59 59
60 // Printing support 60 // Printing support
61 static const char* Mode2String(VariableMode mode); 61 static const char* Mode2String(VariableMode mode);
62 62
63 bool IsValidReference() { return is_valid_ref_; }
64
65 // The source code for an eval() call may refer to a variable that is 63 // The source code for an eval() call may refer to a variable that is
66 // in an outer scope about which we don't know anything (it may not 64 // in an outer scope about which we don't know anything (it may not
67 // be the script scope). scope() is NULL in that case. Currently the 65 // be the script scope). scope() is NULL in that case. Currently the
68 // scope is only used to follow the context chain length. 66 // scope is only used to follow the context chain length.
69 Scope* scope() const { return scope_; } 67 Scope* scope() const { return scope_; }
70 68
71 Handle<String> name() const { return name_->string(); } 69 Handle<String> name() const { return name_->string(); }
72 const AstRawString* raw_name() const { return name_; } 70 const AstRawString* raw_name() const { return name_; }
73 VariableMode mode() const { return mode_; } 71 VariableMode mode() const { return mode_; }
74 bool has_forced_context_allocation() const { 72 bool has_forced_context_allocation() const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 Location location_; 141 Location location_;
144 int index_; 142 int index_;
145 int initializer_position_; 143 int initializer_position_;
146 144
147 // If this field is set, this variable references the stored locally bound 145 // If this field is set, this variable references the stored locally bound
148 // variable, but it might be shadowed by variable bindings introduced by 146 // variable, but it might be shadowed by variable bindings introduced by
149 // sloppy 'eval' calls between the reference scope (inclusive) and the 147 // sloppy 'eval' calls between the reference scope (inclusive) and the
150 // binding scope (exclusive). 148 // binding scope (exclusive).
151 Variable* local_if_not_shadowed_; 149 Variable* local_if_not_shadowed_;
152 150
153 // Valid as a reference? (const and this are not valid, for example)
154 bool is_valid_ref_;
155
156 // Usage info. 151 // Usage info.
157 bool force_context_allocation_; // set by variable resolver 152 bool force_context_allocation_; // set by variable resolver
158 bool is_used_; 153 bool is_used_;
159 InitializationFlag initialization_flag_; 154 InitializationFlag initialization_flag_;
160 MaybeAssignedFlag maybe_assigned_; 155 MaybeAssignedFlag maybe_assigned_;
161 156
162 // Module type info. 157 // Module type info.
163 Interface* interface_; 158 Interface* interface_;
164 }; 159 };
165 160
166 161
167 } } // namespace v8::internal 162 } } // namespace v8::internal
168 163
169 #endif // V8_VARIABLES_H_ 164 #endif // V8_VARIABLES_H_
OLDNEW
« src/scopes.h ('K') | « src/scopes.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698