Leon Clarke | 4515c47 | 2010-02-03 11:58:03 +0000 | [diff] [blame^] | 1 | // 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 | |
| 32 | namespace v8 { |
| 33 | namespace internal { |
| 34 | |
| 35 | |
| 36 | void AstLabeler::Label(FunctionLiteral* fun) { |
| 37 | VisitStatements(fun->body()); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | void AstLabeler::VisitStatements(ZoneList<Statement*>* stmts) { |
| 42 | for (int i = 0, len = stmts->length(); i < len; i++) { |
| 43 | Visit(stmts->at(i)); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void AstLabeler::VisitDeclarations(ZoneList<Declaration*>* decls) { |
| 49 | UNREACHABLE(); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void AstLabeler::VisitBlock(Block* stmt) { |
| 54 | VisitStatements(stmt->statements()); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | void AstLabeler::VisitExpressionStatement( |
| 59 | ExpressionStatement* stmt) { |
| 60 | Visit(stmt->expression()); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | void AstLabeler::VisitEmptyStatement(EmptyStatement* stmt) { |
| 65 | // Do nothing. |
| 66 | } |
| 67 | |
| 68 | |
| 69 | void AstLabeler::VisitIfStatement(IfStatement* stmt) { |
| 70 | UNREACHABLE(); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | void AstLabeler::VisitContinueStatement(ContinueStatement* stmt) { |
| 75 | UNREACHABLE(); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | void AstLabeler::VisitBreakStatement(BreakStatement* stmt) { |
| 80 | UNREACHABLE(); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | void AstLabeler::VisitReturnStatement(ReturnStatement* stmt) { |
| 85 | UNREACHABLE(); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void AstLabeler::VisitWithEnterStatement( |
| 90 | WithEnterStatement* stmt) { |
| 91 | UNREACHABLE(); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | void AstLabeler::VisitWithExitStatement(WithExitStatement* stmt) { |
| 96 | UNREACHABLE(); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | void AstLabeler::VisitSwitchStatement(SwitchStatement* stmt) { |
| 101 | UNREACHABLE(); |
| 102 | } |
| 103 | |
| 104 | |
| 105 | void AstLabeler::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 106 | UNREACHABLE(); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | void AstLabeler::VisitWhileStatement(WhileStatement* stmt) { |
| 111 | UNREACHABLE(); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | void AstLabeler::VisitForStatement(ForStatement* stmt) { |
| 116 | UNREACHABLE(); |
| 117 | } |
| 118 | |
| 119 | |
| 120 | void AstLabeler::VisitForInStatement(ForInStatement* stmt) { |
| 121 | UNREACHABLE(); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | void AstLabeler::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| 126 | UNREACHABLE(); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | void AstLabeler::VisitTryFinallyStatement( |
| 131 | TryFinallyStatement* stmt) { |
| 132 | UNREACHABLE(); |
| 133 | } |
| 134 | |
| 135 | |
| 136 | void AstLabeler::VisitDebuggerStatement( |
| 137 | DebuggerStatement* stmt) { |
| 138 | UNREACHABLE(); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | void AstLabeler::VisitFunctionLiteral(FunctionLiteral* expr) { |
| 143 | UNREACHABLE(); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | void AstLabeler::VisitFunctionBoilerplateLiteral( |
| 148 | FunctionBoilerplateLiteral* expr) { |
| 149 | UNREACHABLE(); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | void AstLabeler::VisitConditional(Conditional* expr) { |
| 154 | UNREACHABLE(); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | void AstLabeler::VisitSlot(Slot* expr) { |
| 159 | UNREACHABLE(); |
| 160 | } |
| 161 | |
| 162 | |
| 163 | void AstLabeler::VisitVariableProxy(VariableProxy* expr) { |
| 164 | expr->set_num(next_number_++); |
| 165 | } |
| 166 | |
| 167 | |
| 168 | void AstLabeler::VisitLiteral(Literal* expr) { |
| 169 | UNREACHABLE(); |
| 170 | } |
| 171 | |
| 172 | |
| 173 | void AstLabeler::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 174 | UNREACHABLE(); |
| 175 | } |
| 176 | |
| 177 | |
| 178 | void AstLabeler::VisitObjectLiteral(ObjectLiteral* expr) { |
| 179 | UNREACHABLE(); |
| 180 | } |
| 181 | |
| 182 | |
| 183 | void AstLabeler::VisitArrayLiteral(ArrayLiteral* expr) { |
| 184 | UNREACHABLE(); |
| 185 | } |
| 186 | |
| 187 | |
| 188 | void AstLabeler::VisitCatchExtensionObject( |
| 189 | CatchExtensionObject* expr) { |
| 190 | UNREACHABLE(); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | void AstLabeler::VisitAssignment(Assignment* expr) { |
| 195 | Property* prop = expr->target()->AsProperty(); |
| 196 | ASSERT(prop != NULL); |
| 197 | if (prop != NULL) { |
| 198 | ASSERT(prop->key()->IsPropertyName()); |
| 199 | VariableProxy* proxy = prop->obj()->AsVariableProxy(); |
| 200 | if (proxy != NULL && proxy->var()->is_this()) { |
| 201 | has_this_properties_ = true; |
| 202 | } else { |
| 203 | Visit(prop->obj()); |
| 204 | } |
| 205 | } |
| 206 | Visit(expr->value()); |
| 207 | expr->set_num(next_number_++); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | void AstLabeler::VisitThrow(Throw* expr) { |
| 212 | UNREACHABLE(); |
| 213 | } |
| 214 | |
| 215 | |
| 216 | void AstLabeler::VisitProperty(Property* expr) { |
| 217 | UNREACHABLE(); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | void AstLabeler::VisitCall(Call* expr) { |
| 222 | UNREACHABLE(); |
| 223 | } |
| 224 | |
| 225 | |
| 226 | void AstLabeler::VisitCallNew(CallNew* expr) { |
| 227 | UNREACHABLE(); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | void AstLabeler::VisitCallRuntime(CallRuntime* expr) { |
| 232 | UNREACHABLE(); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | void AstLabeler::VisitUnaryOperation(UnaryOperation* expr) { |
| 237 | UNREACHABLE(); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | void AstLabeler::VisitCountOperation(CountOperation* expr) { |
| 242 | UNREACHABLE(); |
| 243 | } |
| 244 | |
| 245 | |
| 246 | void AstLabeler::VisitBinaryOperation(BinaryOperation* expr) { |
| 247 | Visit(expr->left()); |
| 248 | Visit(expr->right()); |
| 249 | expr->set_num(next_number_++); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | void AstLabeler::VisitCompareOperation(CompareOperation* expr) { |
| 254 | UNREACHABLE(); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | void AstLabeler::VisitThisFunction(ThisFunction* expr) { |
| 259 | UNREACHABLE(); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | void AstLabeler::VisitDeclaration(Declaration* decl) { |
| 264 | UNREACHABLE(); |
| 265 | } |
| 266 | |
| 267 | } } // namespace v8::internal |