blob: 22ec66fd38b2004f64a8ecc4a6bab70c98ce19ea [file] [log] [blame]
Leon Clarke4515c472010-02-03 11:58:03 +00001// Copyright 2010 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28#include "v8.h"
29
30#include "data-flow.h"
31
32namespace v8 {
33namespace internal {
34
35
Andrei Popescu31002712010-02-23 13:46:05 +000036void AstLabeler::Label(CompilationInfo* info) {
37 info_ = info;
38 VisitStatements(info_->function()->body());
Leon Clarke4515c472010-02-03 11:58:03 +000039}
40
41
42void AstLabeler::VisitStatements(ZoneList<Statement*>* stmts) {
43 for (int i = 0, len = stmts->length(); i < len; i++) {
44 Visit(stmts->at(i));
45 }
46}
47
48
49void AstLabeler::VisitDeclarations(ZoneList<Declaration*>* decls) {
50 UNREACHABLE();
51}
52
53
54void AstLabeler::VisitBlock(Block* stmt) {
55 VisitStatements(stmt->statements());
56}
57
58
59void AstLabeler::VisitExpressionStatement(
60 ExpressionStatement* stmt) {
61 Visit(stmt->expression());
62}
63
64
65void AstLabeler::VisitEmptyStatement(EmptyStatement* stmt) {
66 // Do nothing.
67}
68
69
70void AstLabeler::VisitIfStatement(IfStatement* stmt) {
71 UNREACHABLE();
72}
73
74
75void AstLabeler::VisitContinueStatement(ContinueStatement* stmt) {
76 UNREACHABLE();
77}
78
79
80void AstLabeler::VisitBreakStatement(BreakStatement* stmt) {
81 UNREACHABLE();
82}
83
84
85void AstLabeler::VisitReturnStatement(ReturnStatement* stmt) {
86 UNREACHABLE();
87}
88
89
90void AstLabeler::VisitWithEnterStatement(
91 WithEnterStatement* stmt) {
92 UNREACHABLE();
93}
94
95
96void AstLabeler::VisitWithExitStatement(WithExitStatement* stmt) {
97 UNREACHABLE();
98}
99
100
101void AstLabeler::VisitSwitchStatement(SwitchStatement* stmt) {
102 UNREACHABLE();
103}
104
105
106void AstLabeler::VisitDoWhileStatement(DoWhileStatement* stmt) {
107 UNREACHABLE();
108}
109
110
111void AstLabeler::VisitWhileStatement(WhileStatement* stmt) {
112 UNREACHABLE();
113}
114
115
116void AstLabeler::VisitForStatement(ForStatement* stmt) {
117 UNREACHABLE();
118}
119
120
121void AstLabeler::VisitForInStatement(ForInStatement* stmt) {
122 UNREACHABLE();
123}
124
125
126void AstLabeler::VisitTryCatchStatement(TryCatchStatement* stmt) {
127 UNREACHABLE();
128}
129
130
131void AstLabeler::VisitTryFinallyStatement(
132 TryFinallyStatement* stmt) {
133 UNREACHABLE();
134}
135
136
137void AstLabeler::VisitDebuggerStatement(
138 DebuggerStatement* stmt) {
139 UNREACHABLE();
140}
141
142
143void AstLabeler::VisitFunctionLiteral(FunctionLiteral* expr) {
144 UNREACHABLE();
145}
146
147
148void AstLabeler::VisitFunctionBoilerplateLiteral(
149 FunctionBoilerplateLiteral* expr) {
150 UNREACHABLE();
151}
152
153
154void AstLabeler::VisitConditional(Conditional* expr) {
155 UNREACHABLE();
156}
157
158
159void AstLabeler::VisitSlot(Slot* expr) {
160 UNREACHABLE();
161}
162
163
164void AstLabeler::VisitVariableProxy(VariableProxy* expr) {
165 expr->set_num(next_number_++);
Andrei Popescu31002712010-02-23 13:46:05 +0000166 Variable* var = expr->var();
167 if (var->is_global() && !var->is_this()) {
168 info_->set_has_globals(true);
169 }
Leon Clarke4515c472010-02-03 11:58:03 +0000170}
171
172
173void AstLabeler::VisitLiteral(Literal* expr) {
174 UNREACHABLE();
175}
176
177
178void AstLabeler::VisitRegExpLiteral(RegExpLiteral* expr) {
179 UNREACHABLE();
180}
181
182
183void AstLabeler::VisitObjectLiteral(ObjectLiteral* expr) {
184 UNREACHABLE();
185}
186
187
188void AstLabeler::VisitArrayLiteral(ArrayLiteral* expr) {
189 UNREACHABLE();
190}
191
192
193void AstLabeler::VisitCatchExtensionObject(
194 CatchExtensionObject* expr) {
195 UNREACHABLE();
196}
197
198
199void AstLabeler::VisitAssignment(Assignment* expr) {
200 Property* prop = expr->target()->AsProperty();
201 ASSERT(prop != NULL);
202 if (prop != NULL) {
203 ASSERT(prop->key()->IsPropertyName());
204 VariableProxy* proxy = prop->obj()->AsVariableProxy();
205 if (proxy != NULL && proxy->var()->is_this()) {
Andrei Popescu31002712010-02-23 13:46:05 +0000206 info()->set_has_this_properties(true);
Leon Clarke4515c472010-02-03 11:58:03 +0000207 } else {
208 Visit(prop->obj());
209 }
210 }
211 Visit(expr->value());
212 expr->set_num(next_number_++);
213}
214
215
216void AstLabeler::VisitThrow(Throw* expr) {
217 UNREACHABLE();
218}
219
220
221void AstLabeler::VisitProperty(Property* expr) {
222 UNREACHABLE();
223}
224
225
226void AstLabeler::VisitCall(Call* expr) {
227 UNREACHABLE();
228}
229
230
231void AstLabeler::VisitCallNew(CallNew* expr) {
232 UNREACHABLE();
233}
234
235
236void AstLabeler::VisitCallRuntime(CallRuntime* expr) {
237 UNREACHABLE();
238}
239
240
241void AstLabeler::VisitUnaryOperation(UnaryOperation* expr) {
242 UNREACHABLE();
243}
244
245
246void AstLabeler::VisitCountOperation(CountOperation* expr) {
247 UNREACHABLE();
248}
249
250
251void AstLabeler::VisitBinaryOperation(BinaryOperation* expr) {
252 Visit(expr->left());
253 Visit(expr->right());
254 expr->set_num(next_number_++);
255}
256
257
258void AstLabeler::VisitCompareOperation(CompareOperation* expr) {
259 UNREACHABLE();
260}
261
262
263void AstLabeler::VisitThisFunction(ThisFunction* expr) {
264 UNREACHABLE();
265}
266
267
268void AstLabeler::VisitDeclaration(Declaration* decl) {
269 UNREACHABLE();
270}
271
272} } // namespace v8::internal