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

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: Rebased against master, plus fixes. Only 4 tests failing (+2 in TurboFan) 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
« no previous file with comments | « src/scopes.cc ('k') | src/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_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 29 matching lines...) Expand all
40 // the context object on the heap, starting at 0. scope() is the 40 // the context object on the heap, starting at 0. scope() is the
41 // corresponding scope. 41 // corresponding scope.
42 CONTEXT, 42 CONTEXT,
43 43
44 // A named slot in a heap context. name() is the variable name in the 44 // A named slot in a heap context. name() is the variable name in the
45 // context object on the heap, with lookup starting at the current 45 // context object on the heap, with lookup starting at the current
46 // context. index() is invalid. 46 // context. index() is invalid.
47 LOOKUP 47 LOOKUP
48 }; 48 };
49 49
50 Variable(Scope* scope, const AstRawString* name, VariableMode mode, 50 Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind,
51 bool is_valid_ref, Kind kind, InitializationFlag initialization_flag, 51 InitializationFlag initialization_flag,
52 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); 52 MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
53 53
54 // Printing support 54 // Printing support
55 static const char* Mode2String(VariableMode mode); 55 static const char* Mode2String(VariableMode mode);
56 56
57 bool IsValidReference() { return is_valid_ref_; }
58
59 // The source code for an eval() call may refer to a variable that is 57 // The source code for an eval() call may refer to a variable that is
60 // in an outer scope about which we don't know anything (it may not 58 // in an outer scope about which we don't know anything (it may not
61 // be the script scope). scope() is NULL in that case. Currently the 59 // be the script scope). scope() is NULL in that case. Currently the
62 // scope is only used to follow the context chain length. 60 // scope is only used to follow the context chain length.
63 Scope* scope() const { return scope_; } 61 Scope* scope() const { return scope_; }
64 62
65 Handle<String> name() const { return name_->string(); } 63 Handle<String> name() const { return name_->string(); }
66 const AstRawString* raw_name() const { return name_; } 64 const AstRawString* raw_name() const { return name_; }
67 VariableMode mode() const { return mode_; } 65 VariableMode mode() const { return mode_; }
68 bool has_forced_context_allocation() const { 66 bool has_forced_context_allocation() const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 Location location_; 135 Location location_;
138 int index_; 136 int index_;
139 int initializer_position_; 137 int initializer_position_;
140 138
141 // If this field is set, this variable references the stored locally bound 139 // If this field is set, this variable references the stored locally bound
142 // variable, but it might be shadowed by variable bindings introduced by 140 // variable, but it might be shadowed by variable bindings introduced by
143 // sloppy 'eval' calls between the reference scope (inclusive) and the 141 // sloppy 'eval' calls between the reference scope (inclusive) and the
144 // binding scope (exclusive). 142 // binding scope (exclusive).
145 Variable* local_if_not_shadowed_; 143 Variable* local_if_not_shadowed_;
146 144
147 // Valid as a reference? (const and this are not valid, for example)
148 bool is_valid_ref_;
149
150 // Usage info. 145 // Usage info.
151 bool force_context_allocation_; // set by variable resolver 146 bool force_context_allocation_; // set by variable resolver
152 bool is_used_; 147 bool is_used_;
153 InitializationFlag initialization_flag_; 148 InitializationFlag initialization_flag_;
154 MaybeAssignedFlag maybe_assigned_; 149 MaybeAssignedFlag maybe_assigned_;
155 }; 150 };
156 151
157 152
158 } } // namespace v8::internal 153 } } // namespace v8::internal
159 154
160 #endif // V8_VARIABLES_H_ 155 #endif // V8_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698