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

Side by Side Diff: src/variables.h

Issue 6811012: Remove some dead code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 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
« no previous file with comments | « src/rewriter.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 2006-2008 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
11 // with the distribution. 11 // with the distribution.
(...skipping 14 matching lines...) Expand all
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 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 // Variables and AST expression nodes can track their "type" to enable
37 // optimizations and removal of redundant checks when generating code.
38
39 class StaticType {
40 public:
41 enum Kind {
42 UNKNOWN,
43 LIKELY_SMI
44 };
45
46 StaticType() : kind_(UNKNOWN) {}
47
48 bool Is(Kind kind) const { return kind_ == kind; }
49
50 bool IsKnown() const { return !Is(UNKNOWN); }
51 bool IsUnknown() const { return Is(UNKNOWN); }
52 bool IsLikelySmi() const { return Is(LIKELY_SMI); }
53
54 void CopyFrom(StaticType* other) {
55 kind_ = other->kind_;
56 }
57
58 static const char* Type2String(StaticType* type);
59
60 // LIKELY_SMI accessors
61 void SetAsLikelySmi() {
62 kind_ = LIKELY_SMI;
63 }
64
65 void SetAsLikelySmiIfUnknown() {
66 if (IsUnknown()) {
67 SetAsLikelySmi();
68 }
69 }
70
71 private:
72 Kind kind_;
73 };
74
75
76 // The AST refers to variables via VariableProxies - placeholders for the actual 36 // The AST refers to variables via VariableProxies - placeholders for the actual
77 // variables. Variables themselves are never directly referred to from the AST, 37 // variables. Variables themselves are never directly referred to from the AST,
78 // they are maintained by scopes, and referred to from VariableProxies and Slots 38 // they are maintained by scopes, and referred to from VariableProxies and Slots
79 // after binding and variable allocation. 39 // after binding and variable allocation.
80 40
81 class Variable: public ZoneObject { 41 class Variable: public ZoneObject {
82 public: 42 public:
83 enum Mode { 43 enum Mode {
84 // User declared variables: 44 // User declared variables:
85 VAR, // declared via 'var', and 'function' declarations 45 VAR, // declared via 'var', and 'function' declarations
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return local_if_not_shadowed_; 134 return local_if_not_shadowed_;
175 } 135 }
176 136
177 void set_local_if_not_shadowed(Variable* local) { 137 void set_local_if_not_shadowed(Variable* local) {
178 local_if_not_shadowed_ = local; 138 local_if_not_shadowed_ = local;
179 } 139 }
180 140
181 Expression* rewrite() const { return rewrite_; } 141 Expression* rewrite() const { return rewrite_; }
182 void set_rewrite(Expression* expr) { rewrite_ = expr; } 142 void set_rewrite(Expression* expr) { rewrite_ = expr; }
183 143
184 StaticType* type() { return &type_; }
185
186 private: 144 private:
187 Scope* scope_; 145 Scope* scope_;
188 Handle<String> name_; 146 Handle<String> name_;
189 Mode mode_; 147 Mode mode_;
190 Kind kind_; 148 Kind kind_;
191 149
192 Variable* local_if_not_shadowed_; 150 Variable* local_if_not_shadowed_;
193 151
194 // Static type information
195 StaticType type_;
196
197 // Code generation. 152 // Code generation.
198 // rewrite_ is usually a Slot or a Property, but may be any expression. 153 // rewrite_ is usually a Slot or a Property, but may be any expression.
199 Expression* rewrite_; 154 Expression* rewrite_;
200 155
201 // Valid as a LHS? (const and this are not valid LHS, for example) 156 // Valid as a LHS? (const and this are not valid LHS, for example)
202 bool is_valid_LHS_; 157 bool is_valid_LHS_;
203 158
204 // Usage info. 159 // Usage info.
205 bool is_accessed_from_inner_scope_; // set by variable resolver 160 bool is_accessed_from_inner_scope_; // set by variable resolver
206 bool is_used_; 161 bool is_used_;
207 }; 162 };
208 163
209 164
210 } } // namespace v8::internal 165 } } // namespace v8::internal
211 166
212 #endif // V8_VARIABLES_H_ 167 #endif // V8_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/rewriter.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698