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

Side by Side Diff: src/variables.h

Issue 18901003: Compute expected type for variables (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_VARIABLES_H_ 28 #ifndef V8_VARIABLES_H_
29 #define V8_VARIABLES_H_ 29 #define V8_VARIABLES_H_
30 30
31 #include "zone.h" 31 #include "zone.h"
32 #include "types.h"
32 #include "interface.h" 33 #include "interface.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 // The AST refers to variables via VariableProxies - placeholders for the actual 38 // The AST refers to variables via VariableProxies - placeholders for the actual
38 // variables. Variables themselves are never directly referred to from the AST, 39 // variables. Variables themselves are never directly referred to from the AST,
39 // they are maintained by scopes, and referred to from VariableProxies and Slots 40 // they are maintained by scopes, and referred to from VariableProxies and Slots
40 // after binding and variable allocation. 41 // after binding and variable allocation.
41 42
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 137
137 Variable* local_if_not_shadowed() const { 138 Variable* local_if_not_shadowed() const {
138 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL); 139 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL);
139 return local_if_not_shadowed_; 140 return local_if_not_shadowed_;
140 } 141 }
141 142
142 void set_local_if_not_shadowed(Variable* local) { 143 void set_local_if_not_shadowed(Variable* local) {
143 local_if_not_shadowed_ = local; 144 local_if_not_shadowed_ = local;
144 } 145 }
145 146
147 Handle<Type> expected_type() { return expected_type_; }
148 void set_expected_type(Handle<Type> type) { expected_type_ = type; }
149
146 Location location() const { return location_; } 150 Location location() const { return location_; }
147 int index() const { return index_; } 151 int index() const { return index_; }
148 InitializationFlag initialization_flag() const { 152 InitializationFlag initialization_flag() const {
149 return initialization_flag_; 153 return initialization_flag_;
150 } 154 }
151 Interface* interface() const { return interface_; } 155 Interface* interface() const { return interface_; }
152 156
153 void AllocateTo(Location location, int index) { 157 void AllocateTo(Location location, int index) {
154 location_ = location; 158 location_ = location;
155 index_ = index; 159 index_ = index;
156 } 160 }
157 161
158 static int CompareIndex(Variable* const* v, Variable* const* w); 162 static int CompareIndex(Variable* const* v, Variable* const* w);
159 163
160 private: 164 private:
161 Scope* scope_; 165 Scope* scope_;
162 Handle<String> name_; 166 Handle<String> name_;
163 VariableMode mode_; 167 VariableMode mode_;
164 Kind kind_; 168 Kind kind_;
169 Handle<Type> expected_type_; // Intersection of all reads
Jakob Kummerow 2013/07/09 16:01:50 nit: trailing full stop. And, uhm, "Union" ;-)
165 Location location_; 170 Location location_;
166 int index_; 171 int index_;
167 int initializer_position_; 172 int initializer_position_;
168 173
169 // If this field is set, this variable references the stored locally bound 174 // If this field is set, this variable references the stored locally bound
170 // variable, but it might be shadowed by variable bindings introduced by 175 // variable, but it might be shadowed by variable bindings introduced by
171 // non-strict 'eval' calls between the reference scope (inclusive) and the 176 // non-strict 'eval' calls between the reference scope (inclusive) and the
172 // binding scope (exclusive). 177 // binding scope (exclusive).
173 Variable* local_if_not_shadowed_; 178 Variable* local_if_not_shadowed_;
174 179
175 // Valid as a LHS? (const and this are not valid LHS, for example) 180 // Valid as a LHS? (const and this are not valid LHS, for example)
176 bool is_valid_LHS_; 181 bool is_valid_LHS_;
177 182
178 // Usage info. 183 // Usage info.
179 bool force_context_allocation_; // set by variable resolver 184 bool force_context_allocation_; // set by variable resolver
180 bool is_used_; 185 bool is_used_;
181 InitializationFlag initialization_flag_; 186 InitializationFlag initialization_flag_;
182 187
183 // Module type info. 188 // Module type info.
184 Interface* interface_; 189 Interface* interface_;
185 }; 190 };
186 191
187 192
188 } } // namespace v8::internal 193 } } // namespace v8::internal
189 194
190 #endif // V8_VARIABLES_H_ 195 #endif // V8_VARIABLES_H_
OLDNEW
« src/typing.cc ('K') | « src/typing.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698