| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 32 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 33 void VisitArguments(ZoneList<Expression*>* arguments); | 33 void VisitArguments(ZoneList<Expression*>* arguments); |
| 34 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 34 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
| 35 | 35 |
| 36 int ReserveIdRange(int n) { | 36 int ReserveIdRange(int n) { |
| 37 int tmp = next_id_; | 37 int tmp = next_id_; |
| 38 next_id_ += n; | 38 next_id_ += n; |
| 39 return tmp; | 39 return tmp; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void IncrementNodeCount() { properties_.add_node_count(1); } |
| 43 |
| 42 int next_id_; | 44 int next_id_; |
| 45 AstProperties properties_; |
| 43 | 46 |
| 44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 47 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 45 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); | 48 DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 | 51 |
| 49 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { | 52 void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
| 53 IncrementNodeCount(); |
| 50 VisitVariableProxy(node->proxy()); | 54 VisitVariableProxy(node->proxy()); |
| 51 } | 55 } |
| 52 | 56 |
| 53 | 57 |
| 54 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { | 58 void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { |
| 59 IncrementNodeCount(); |
| 55 VisitVariableProxy(node->proxy()); | 60 VisitVariableProxy(node->proxy()); |
| 56 } | 61 } |
| 57 | 62 |
| 58 | 63 |
| 59 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) {} | 64 void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) { |
| 65 IncrementNodeCount(); |
| 66 } |
| 60 | 67 |
| 61 | 68 |
| 62 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) {} | 69 void AstNumberingVisitor::VisitEmptyStatement(EmptyStatement* node) { |
| 70 IncrementNodeCount(); |
| 71 } |
| 63 | 72 |
| 64 | 73 |
| 65 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) {} | 74 void AstNumberingVisitor::VisitContinueStatement(ContinueStatement* node) { |
| 75 IncrementNodeCount(); |
| 76 } |
| 66 | 77 |
| 67 | 78 |
| 68 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) {} | 79 void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) { |
| 80 IncrementNodeCount(); |
| 81 } |
| 69 | 82 |
| 70 | 83 |
| 71 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { | 84 void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { |
| 85 IncrementNodeCount(); |
| 72 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); | 86 node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); |
| 73 } | 87 } |
| 74 | 88 |
| 75 | 89 |
| 76 void AstNumberingVisitor::VisitNativeFunctionLiteral( | 90 void AstNumberingVisitor::VisitNativeFunctionLiteral( |
| 77 NativeFunctionLiteral* node) { | 91 NativeFunctionLiteral* node) { |
| 92 IncrementNodeCount(); |
| 78 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); | 93 node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); |
| 79 } | 94 } |
| 80 | 95 |
| 81 | 96 |
| 82 void AstNumberingVisitor::VisitLiteral(Literal* node) { | 97 void AstNumberingVisitor::VisitLiteral(Literal* node) { |
| 98 IncrementNodeCount(); |
| 83 node->set_base_id(ReserveIdRange(Literal::num_ids())); | 99 node->set_base_id(ReserveIdRange(Literal::num_ids())); |
| 84 } | 100 } |
| 85 | 101 |
| 86 | 102 |
| 87 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { | 103 void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { |
| 104 IncrementNodeCount(); |
| 88 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); | 105 node->set_base_id(ReserveIdRange(RegExpLiteral::num_ids())); |
| 89 } | 106 } |
| 90 | 107 |
| 91 | 108 |
| 92 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { | 109 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { |
| 110 IncrementNodeCount(); |
| 93 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); | 111 node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); |
| 94 } | 112 } |
| 95 | 113 |
| 96 | 114 |
| 97 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { | 115 void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { |
| 116 IncrementNodeCount(); |
| 98 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); | 117 node->set_base_id(ReserveIdRange(ThisFunction::num_ids())); |
| 99 } | 118 } |
| 100 | 119 |
| 101 | 120 |
| 102 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { | 121 void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { |
| 122 IncrementNodeCount(); |
| 103 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); | 123 node->set_base_id(ReserveIdRange(SuperReference::num_ids())); |
| 104 Visit(node->this_var()); | 124 Visit(node->this_var()); |
| 105 } | 125 } |
| 106 | 126 |
| 107 | 127 |
| 108 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { | 128 void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { |
| 129 IncrementNodeCount(); |
| 109 VisitVariableProxy(node->proxy()); | 130 VisitVariableProxy(node->proxy()); |
| 110 Visit(node->module()); | 131 Visit(node->module()); |
| 111 } | 132 } |
| 112 | 133 |
| 113 | 134 |
| 114 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { | 135 void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { |
| 136 IncrementNodeCount(); |
| 115 VisitVariableProxy(node->proxy()); | 137 VisitVariableProxy(node->proxy()); |
| 116 Visit(node->module()); | 138 Visit(node->module()); |
| 117 } | 139 } |
| 118 | 140 |
| 119 | 141 |
| 120 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { | 142 void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { |
| 143 IncrementNodeCount(); |
| 121 Visit(node->proxy()); | 144 Visit(node->proxy()); |
| 122 } | 145 } |
| 123 | 146 |
| 124 | 147 |
| 125 void AstNumberingVisitor::VisitModulePath(ModulePath* node) { | 148 void AstNumberingVisitor::VisitModulePath(ModulePath* node) { |
| 149 IncrementNodeCount(); |
| 126 Visit(node->module()); | 150 Visit(node->module()); |
| 127 } | 151 } |
| 128 | 152 |
| 129 | 153 |
| 130 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { | 154 void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { |
| 155 IncrementNodeCount(); |
| 131 Visit(node->body()); | 156 Visit(node->body()); |
| 132 } | 157 } |
| 133 | 158 |
| 134 | 159 |
| 135 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { | 160 void AstNumberingVisitor::VisitExpressionStatement(ExpressionStatement* node) { |
| 161 IncrementNodeCount(); |
| 136 Visit(node->expression()); | 162 Visit(node->expression()); |
| 137 } | 163 } |
| 138 | 164 |
| 139 | 165 |
| 140 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { | 166 void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { |
| 167 IncrementNodeCount(); |
| 141 Visit(node->expression()); | 168 Visit(node->expression()); |
| 142 } | 169 } |
| 143 | 170 |
| 144 | 171 |
| 145 void AstNumberingVisitor::VisitYield(Yield* node) { | 172 void AstNumberingVisitor::VisitYield(Yield* node) { |
| 173 IncrementNodeCount(); |
| 146 node->set_base_id(ReserveIdRange(Yield::num_ids())); | 174 node->set_base_id(ReserveIdRange(Yield::num_ids())); |
| 147 Visit(node->generator_object()); | 175 Visit(node->generator_object()); |
| 148 Visit(node->expression()); | 176 Visit(node->expression()); |
| 149 } | 177 } |
| 150 | 178 |
| 151 | 179 |
| 152 void AstNumberingVisitor::VisitThrow(Throw* node) { | 180 void AstNumberingVisitor::VisitThrow(Throw* node) { |
| 181 IncrementNodeCount(); |
| 153 node->set_base_id(ReserveIdRange(Throw::num_ids())); | 182 node->set_base_id(ReserveIdRange(Throw::num_ids())); |
| 154 Visit(node->exception()); | 183 Visit(node->exception()); |
| 155 } | 184 } |
| 156 | 185 |
| 157 | 186 |
| 158 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { | 187 void AstNumberingVisitor::VisitUnaryOperation(UnaryOperation* node) { |
| 188 IncrementNodeCount(); |
| 159 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); | 189 node->set_base_id(ReserveIdRange(UnaryOperation::num_ids())); |
| 160 Visit(node->expression()); | 190 Visit(node->expression()); |
| 161 } | 191 } |
| 162 | 192 |
| 163 | 193 |
| 164 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { | 194 void AstNumberingVisitor::VisitCountOperation(CountOperation* node) { |
| 195 IncrementNodeCount(); |
| 165 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); | 196 node->set_base_id(ReserveIdRange(CountOperation::num_ids())); |
| 166 Visit(node->expression()); | 197 Visit(node->expression()); |
| 167 } | 198 } |
| 168 | 199 |
| 169 | 200 |
| 170 void AstNumberingVisitor::VisitBlock(Block* node) { | 201 void AstNumberingVisitor::VisitBlock(Block* node) { |
| 202 IncrementNodeCount(); |
| 171 node->set_base_id(ReserveIdRange(Block::num_ids())); | 203 node->set_base_id(ReserveIdRange(Block::num_ids())); |
| 172 if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations()); | 204 if (node->scope() != NULL) VisitDeclarations(node->scope()->declarations()); |
| 173 VisitStatements(node->statements()); | 205 VisitStatements(node->statements()); |
| 174 } | 206 } |
| 175 | 207 |
| 176 | 208 |
| 177 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { | 209 void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { |
| 210 IncrementNodeCount(); |
| 178 VisitVariableProxy(node->proxy()); | 211 VisitVariableProxy(node->proxy()); |
| 179 VisitFunctionLiteral(node->fun()); | 212 VisitFunctionLiteral(node->fun()); |
| 180 } | 213 } |
| 181 | 214 |
| 182 | 215 |
| 183 void AstNumberingVisitor::VisitModuleLiteral(ModuleLiteral* node) { | 216 void AstNumberingVisitor::VisitModuleLiteral(ModuleLiteral* node) { |
| 217 IncrementNodeCount(); |
| 184 VisitBlock(node->body()); | 218 VisitBlock(node->body()); |
| 185 } | 219 } |
| 186 | 220 |
| 187 | 221 |
| 188 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { | 222 void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { |
| 223 IncrementNodeCount(); |
| 189 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); | 224 node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); |
| 190 VisitArguments(node->arguments()); | 225 VisitArguments(node->arguments()); |
| 191 } | 226 } |
| 192 | 227 |
| 193 | 228 |
| 194 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { | 229 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
| 230 IncrementNodeCount(); |
| 195 Visit(node->expression()); | 231 Visit(node->expression()); |
| 196 Visit(node->statement()); | 232 Visit(node->statement()); |
| 197 } | 233 } |
| 198 | 234 |
| 199 | 235 |
| 200 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { | 236 void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
| 237 IncrementNodeCount(); |
| 201 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); | 238 node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
| 202 Visit(node->body()); | 239 Visit(node->body()); |
| 203 Visit(node->cond()); | 240 Visit(node->cond()); |
| 204 } | 241 } |
| 205 | 242 |
| 206 | 243 |
| 207 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { | 244 void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
| 245 IncrementNodeCount(); |
| 208 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); | 246 node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); |
| 209 Visit(node->cond()); | 247 Visit(node->cond()); |
| 210 Visit(node->body()); | 248 Visit(node->body()); |
| 211 } | 249 } |
| 212 | 250 |
| 213 | 251 |
| 214 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { | 252 void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { |
| 253 IncrementNodeCount(); |
| 215 Visit(node->try_block()); | 254 Visit(node->try_block()); |
| 216 Visit(node->catch_block()); | 255 Visit(node->catch_block()); |
| 217 } | 256 } |
| 218 | 257 |
| 219 | 258 |
| 220 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { | 259 void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { |
| 260 IncrementNodeCount(); |
| 221 Visit(node->try_block()); | 261 Visit(node->try_block()); |
| 222 Visit(node->finally_block()); | 262 Visit(node->finally_block()); |
| 223 } | 263 } |
| 224 | 264 |
| 225 | 265 |
| 226 void AstNumberingVisitor::VisitProperty(Property* node) { | 266 void AstNumberingVisitor::VisitProperty(Property* node) { |
| 267 IncrementNodeCount(); |
| 227 node->set_base_id(ReserveIdRange(Property::num_ids())); | 268 node->set_base_id(ReserveIdRange(Property::num_ids())); |
| 228 Visit(node->key()); | 269 Visit(node->key()); |
| 229 Visit(node->obj()); | 270 Visit(node->obj()); |
| 230 } | 271 } |
| 231 | 272 |
| 232 | 273 |
| 233 void AstNumberingVisitor::VisitAssignment(Assignment* node) { | 274 void AstNumberingVisitor::VisitAssignment(Assignment* node) { |
| 275 IncrementNodeCount(); |
| 234 node->set_base_id(ReserveIdRange(Assignment::num_ids())); | 276 node->set_base_id(ReserveIdRange(Assignment::num_ids())); |
| 235 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); | 277 if (node->is_compound()) VisitBinaryOperation(node->binary_operation()); |
| 236 Visit(node->target()); | 278 Visit(node->target()); |
| 237 Visit(node->value()); | 279 Visit(node->value()); |
| 238 } | 280 } |
| 239 | 281 |
| 240 | 282 |
| 241 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { | 283 void AstNumberingVisitor::VisitBinaryOperation(BinaryOperation* node) { |
| 284 IncrementNodeCount(); |
| 242 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); | 285 node->set_base_id(ReserveIdRange(BinaryOperation::num_ids())); |
| 243 Visit(node->left()); | 286 Visit(node->left()); |
| 244 Visit(node->right()); | 287 Visit(node->right()); |
| 245 } | 288 } |
| 246 | 289 |
| 247 | 290 |
| 248 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { | 291 void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { |
| 292 IncrementNodeCount(); |
| 249 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); | 293 node->set_base_id(ReserveIdRange(CompareOperation::num_ids())); |
| 250 Visit(node->left()); | 294 Visit(node->left()); |
| 251 Visit(node->right()); | 295 Visit(node->right()); |
| 252 } | 296 } |
| 253 | 297 |
| 254 | 298 |
| 255 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { | 299 void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
| 300 IncrementNodeCount(); |
| 256 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); | 301 node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
| 257 Visit(node->each()); | 302 Visit(node->each()); |
| 258 Visit(node->enumerable()); | 303 Visit(node->enumerable()); |
| 259 Visit(node->body()); | 304 Visit(node->body()); |
| 260 } | 305 } |
| 261 | 306 |
| 262 | 307 |
| 263 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { | 308 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
| 309 IncrementNodeCount(); |
| 264 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); | 310 node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); |
| 265 Visit(node->assign_iterator()); | 311 Visit(node->assign_iterator()); |
| 266 Visit(node->next_result()); | 312 Visit(node->next_result()); |
| 267 Visit(node->result_done()); | 313 Visit(node->result_done()); |
| 268 Visit(node->assign_each()); | 314 Visit(node->assign_each()); |
| 269 Visit(node->body()); | 315 Visit(node->body()); |
| 270 } | 316 } |
| 271 | 317 |
| 272 | 318 |
| 273 void AstNumberingVisitor::VisitConditional(Conditional* node) { | 319 void AstNumberingVisitor::VisitConditional(Conditional* node) { |
| 320 IncrementNodeCount(); |
| 274 node->set_base_id(ReserveIdRange(Conditional::num_ids())); | 321 node->set_base_id(ReserveIdRange(Conditional::num_ids())); |
| 275 Visit(node->condition()); | 322 Visit(node->condition()); |
| 276 Visit(node->then_expression()); | 323 Visit(node->then_expression()); |
| 277 Visit(node->else_expression()); | 324 Visit(node->else_expression()); |
| 278 } | 325 } |
| 279 | 326 |
| 280 | 327 |
| 281 void AstNumberingVisitor::VisitIfStatement(IfStatement* node) { | 328 void AstNumberingVisitor::VisitIfStatement(IfStatement* node) { |
| 329 IncrementNodeCount(); |
| 282 node->set_base_id(ReserveIdRange(IfStatement::num_ids())); | 330 node->set_base_id(ReserveIdRange(IfStatement::num_ids())); |
| 283 Visit(node->condition()); | 331 Visit(node->condition()); |
| 284 Visit(node->then_statement()); | 332 Visit(node->then_statement()); |
| 285 if (node->HasElseStatement()) { | 333 if (node->HasElseStatement()) { |
| 286 Visit(node->else_statement()); | 334 Visit(node->else_statement()); |
| 287 } | 335 } |
| 288 } | 336 } |
| 289 | 337 |
| 290 | 338 |
| 291 void AstNumberingVisitor::VisitSwitchStatement(SwitchStatement* node) { | 339 void AstNumberingVisitor::VisitSwitchStatement(SwitchStatement* node) { |
| 340 IncrementNodeCount(); |
| 292 node->set_base_id(ReserveIdRange(SwitchStatement::num_ids())); | 341 node->set_base_id(ReserveIdRange(SwitchStatement::num_ids())); |
| 293 Visit(node->tag()); | 342 Visit(node->tag()); |
| 294 ZoneList<CaseClause*>* cases = node->cases(); | 343 ZoneList<CaseClause*>* cases = node->cases(); |
| 295 for (int i = 0; i < cases->length(); i++) { | 344 for (int i = 0; i < cases->length(); i++) { |
| 296 VisitCaseClause(cases->at(i)); | 345 VisitCaseClause(cases->at(i)); |
| 297 } | 346 } |
| 298 } | 347 } |
| 299 | 348 |
| 300 | 349 |
| 301 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { | 350 void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { |
| 351 IncrementNodeCount(); |
| 302 node->set_base_id(ReserveIdRange(CaseClause::num_ids())); | 352 node->set_base_id(ReserveIdRange(CaseClause::num_ids())); |
| 303 if (!node->is_default()) Visit(node->label()); | 353 if (!node->is_default()) Visit(node->label()); |
| 304 VisitStatements(node->statements()); | 354 VisitStatements(node->statements()); |
| 305 } | 355 } |
| 306 | 356 |
| 307 | 357 |
| 308 void AstNumberingVisitor::VisitForStatement(ForStatement* node) { | 358 void AstNumberingVisitor::VisitForStatement(ForStatement* node) { |
| 359 IncrementNodeCount(); |
| 309 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); | 360 node->set_base_id(ReserveIdRange(ForStatement::num_ids())); |
| 310 if (node->init() != NULL) Visit(node->init()); | 361 if (node->init() != NULL) Visit(node->init()); |
| 311 if (node->cond() != NULL) Visit(node->cond()); | 362 if (node->cond() != NULL) Visit(node->cond()); |
| 312 if (node->next() != NULL) Visit(node->next()); | 363 if (node->next() != NULL) Visit(node->next()); |
| 313 Visit(node->body()); | 364 Visit(node->body()); |
| 314 } | 365 } |
| 315 | 366 |
| 316 | 367 |
| 317 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { | 368 void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { |
| 369 IncrementNodeCount(); |
| 318 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); | 370 node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); |
| 319 if (node->extends()) Visit(node->extends()); | 371 if (node->extends()) Visit(node->extends()); |
| 320 if (node->constructor()) Visit(node->constructor()); | 372 if (node->constructor()) Visit(node->constructor()); |
| 321 for (int i = 0; i < node->properties()->length(); i++) { | 373 for (int i = 0; i < node->properties()->length(); i++) { |
| 322 VisitObjectLiteralProperty(node->properties()->at(i)); | 374 VisitObjectLiteralProperty(node->properties()->at(i)); |
| 323 } | 375 } |
| 324 } | 376 } |
| 325 | 377 |
| 326 | 378 |
| 327 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { | 379 void AstNumberingVisitor::VisitObjectLiteral(ObjectLiteral* node) { |
| 380 IncrementNodeCount(); |
| 328 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids())); | 381 node->set_base_id(ReserveIdRange(ObjectLiteral::num_ids())); |
| 329 for (int i = 0; i < node->properties()->length(); i++) { | 382 for (int i = 0; i < node->properties()->length(); i++) { |
| 330 VisitObjectLiteralProperty(node->properties()->at(i)); | 383 VisitObjectLiteralProperty(node->properties()->at(i)); |
| 331 } | 384 } |
| 332 } | 385 } |
| 333 | 386 |
| 334 | 387 |
| 335 void AstNumberingVisitor::VisitObjectLiteralProperty( | 388 void AstNumberingVisitor::VisitObjectLiteralProperty( |
| 336 ObjectLiteralProperty* node) { | 389 ObjectLiteralProperty* node) { |
| 337 Visit(node->key()); | 390 Visit(node->key()); |
| 338 Visit(node->value()); | 391 Visit(node->value()); |
| 339 } | 392 } |
| 340 | 393 |
| 341 | 394 |
| 342 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { | 395 void AstNumberingVisitor::VisitArrayLiteral(ArrayLiteral* node) { |
| 396 IncrementNodeCount(); |
| 343 node->set_base_id(ReserveIdRange(node->num_ids())); | 397 node->set_base_id(ReserveIdRange(node->num_ids())); |
| 344 for (int i = 0; i < node->values()->length(); i++) { | 398 for (int i = 0; i < node->values()->length(); i++) { |
| 345 Visit(node->values()->at(i)); | 399 Visit(node->values()->at(i)); |
| 346 } | 400 } |
| 347 } | 401 } |
| 348 | 402 |
| 349 | 403 |
| 350 void AstNumberingVisitor::VisitCall(Call* node) { | 404 void AstNumberingVisitor::VisitCall(Call* node) { |
| 405 IncrementNodeCount(); |
| 351 node->set_base_id(ReserveIdRange(Call::num_ids())); | 406 node->set_base_id(ReserveIdRange(Call::num_ids())); |
| 352 Visit(node->expression()); | 407 Visit(node->expression()); |
| 353 VisitArguments(node->arguments()); | 408 VisitArguments(node->arguments()); |
| 354 } | 409 } |
| 355 | 410 |
| 356 | 411 |
| 357 void AstNumberingVisitor::VisitCallNew(CallNew* node) { | 412 void AstNumberingVisitor::VisitCallNew(CallNew* node) { |
| 413 IncrementNodeCount(); |
| 358 node->set_base_id(ReserveIdRange(CallNew::num_ids())); | 414 node->set_base_id(ReserveIdRange(CallNew::num_ids())); |
| 359 Visit(node->expression()); | 415 Visit(node->expression()); |
| 360 VisitArguments(node->arguments()); | 416 VisitArguments(node->arguments()); |
| 361 } | 417 } |
| 362 | 418 |
| 363 | 419 |
| 364 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { | 420 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { |
| 365 if (statements == NULL) return; | 421 if (statements == NULL) return; |
| 366 for (int i = 0; i < statements->length(); i++) { | 422 for (int i = 0; i < statements->length(); i++) { |
| 367 Visit(statements->at(i)); | 423 Visit(statements->at(i)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 378 | 434 |
| 379 | 435 |
| 380 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { | 436 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { |
| 381 for (int i = 0; i < arguments->length(); i++) { | 437 for (int i = 0; i < arguments->length(); i++) { |
| 382 Visit(arguments->at(i)); | 438 Visit(arguments->at(i)); |
| 383 } | 439 } |
| 384 } | 440 } |
| 385 | 441 |
| 386 | 442 |
| 387 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { | 443 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { |
| 444 IncrementNodeCount(); |
| 388 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); | 445 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); |
| 389 // We don't recurse into the declarations or body of the function literal: | 446 // We don't recurse into the declarations or body of the function literal: |
| 390 // you have to separately Renumber() each FunctionLiteral that you compile. | 447 // you have to separately Renumber() each FunctionLiteral that you compile. |
| 391 } | 448 } |
| 392 | 449 |
| 393 | 450 |
| 394 void AstNumberingVisitor::Renumber(FunctionLiteral* node) { | 451 void AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
| 452 properties_.flags()->Add(*node->flags()); |
| 453 properties_.increase_feedback_slots(node->slot_count()); |
| 454 properties_.increase_ic_feedback_slots(node->ic_slot_count()); |
| 455 |
| 395 if (node->scope()->HasIllegalRedeclaration()) { | 456 if (node->scope()->HasIllegalRedeclaration()) { |
| 396 node->scope()->VisitIllegalRedeclaration(this); | 457 node->scope()->VisitIllegalRedeclaration(this); |
| 397 return; | 458 return; |
| 398 } | 459 } |
| 399 | 460 |
| 400 Scope* scope = node->scope(); | 461 Scope* scope = node->scope(); |
| 401 VisitDeclarations(scope->declarations()); | 462 VisitDeclarations(scope->declarations()); |
| 402 if (scope->is_function_scope() && scope->function() != NULL) { | 463 if (scope->is_function_scope() && scope->function() != NULL) { |
| 403 // Visit the name of the named function expression. | 464 // Visit the name of the named function expression. |
| 404 Visit(scope->function()); | 465 Visit(scope->function()); |
| 405 } | 466 } |
| 406 VisitStatements(node->body()); | 467 VisitStatements(node->body()); |
| 468 |
| 469 node->set_ast_properties(&properties_); |
| 407 } | 470 } |
| 408 | 471 |
| 409 | 472 |
| 410 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { | 473 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { |
| 411 AstNumberingVisitor visitor(zone); | 474 AstNumberingVisitor visitor(zone); |
| 412 visitor.Renumber(function); | 475 visitor.Renumber(function); |
| 413 return !visitor.HasStackOverflow(); | 476 return !visitor.HasStackOverflow(); |
| 414 } | 477 } |
| 415 } | 478 } |
| 416 } // namespace v8::internal | 479 } // namespace v8::internal |
| OLD | NEW |