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/parsing/rewriter.h" | 5 #include "src/parsing/rewriter.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/parsing/parse-info.h" | 9 #include "src/parsing/parse-info.h" |
10 #include "src/parsing/parser.h" | 10 #include "src/parsing/parser.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 // Declarations are never visited. | 347 // Declarations are never visited. |
348 #define DEF_VISIT(type) \ | 348 #define DEF_VISIT(type) \ |
349 void Processor::Visit##type(type* expr) { UNREACHABLE(); } | 349 void Processor::Visit##type(type* expr) { UNREACHABLE(); } |
350 DECLARATION_NODE_LIST(DEF_VISIT) | 350 DECLARATION_NODE_LIST(DEF_VISIT) |
351 #undef DEF_VISIT | 351 #undef DEF_VISIT |
352 | 352 |
353 | 353 |
354 // Assumes code has been parsed. Mutates the AST, so the AST should not | 354 // Assumes code has been parsed. Mutates the AST, so the AST should not |
355 // continue to be used in the case of failure. | 355 // continue to be used in the case of failure. |
356 bool Rewriter::Rewrite(ParseInfo* info) { | 356 bool Rewriter::Rewrite(ParseInfo* info) { |
357 RuntimeCallTimerScope runtimeTimer( | |
358 info->isolate(), &RuntimeCallStats::CompileRewriteReturnResult); | |
rmcilroy
2017/01/09 13:55:26
nit - would it work as just CompileRewriteAst or s
| |
357 FunctionLiteral* function = info->literal(); | 359 FunctionLiteral* function = info->literal(); |
358 DCHECK_NOT_NULL(function); | 360 DCHECK_NOT_NULL(function); |
359 Scope* scope = function->scope(); | 361 Scope* scope = function->scope(); |
360 DCHECK_NOT_NULL(scope); | 362 DCHECK_NOT_NULL(scope); |
361 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; | 363 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; |
362 DeclarationScope* closure_scope = scope->GetClosureScope(); | 364 DeclarationScope* closure_scope = scope->GetClosureScope(); |
363 | 365 |
364 ZoneList<Statement*>* body = function->body(); | 366 ZoneList<Statement*>* body = function->body(); |
365 if (!body->is_empty()) { | 367 if (!body->is_empty()) { |
366 Variable* result = closure_scope->NewTemporary( | 368 Variable* result = closure_scope->NewTemporary( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 processor.SetResult(undef), expr->position()); | 412 processor.SetResult(undef), expr->position()); |
411 body->Add(completion, factory->zone()); | 413 body->Add(completion, factory->zone()); |
412 } | 414 } |
413 } | 415 } |
414 return true; | 416 return true; |
415 } | 417 } |
416 | 418 |
417 | 419 |
418 } // namespace internal | 420 } // namespace internal |
419 } // namespace v8 | 421 } // namespace v8 |
OLD | NEW |