| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 HInstruction errorMessage = | 490 HInstruction errorMessage = |
| 491 graph.addConstantString(new DartString.literal(message), closedWorld); | 491 graph.addConstantString(new DartString.literal(message), closedWorld); |
| 492 HInstruction trap = new HForeignCode(js.js.parseForeignJS("#.#"), | 492 HInstruction trap = new HForeignCode(js.js.parseForeignJS("#.#"), |
| 493 commonMasks.dynamicType, <HInstruction>[nullValue, errorMessage]); | 493 commonMasks.dynamicType, <HInstruction>[nullValue, errorMessage]); |
| 494 trap.sideEffects | 494 trap.sideEffects |
| 495 ..setAllSideEffects() | 495 ..setAllSideEffects() |
| 496 ..setDependsOnSomething(); | 496 ..setDependsOnSomething(); |
| 497 push(trap); | 497 push(trap); |
| 498 } | 498 } |
| 499 | 499 |
| 500 /// Returns the current source element. | 500 /// Returns the current source element. This is used by the type builder. |
| 501 /// | 501 /// |
| 502 /// The returned element is a declaration element. | 502 /// The returned element is a declaration element. |
| 503 // TODO(efortuna): Update this when we implement inlining. | 503 // TODO(efortuna): Update this when we implement inlining. |
| 504 // TODO(sra): Re-implement type builder using Kernel types and the |
| 505 // `target` for context. |
| 504 @override | 506 @override |
| 505 Element get sourceElement => astAdapter.getElement(target); | 507 Element get sourceElement => _sourceElementForTarget(target); |
| 508 |
| 509 Element _sourceElementForTarget(ir.Node target) { |
| 510 // For closure-converted (i.e. local functions) the source element is the |
| 511 // 'call' method of the class that represents the closure. |
| 512 if (target is ir.FunctionExpression) { |
| 513 LocalFunctionElement element = astAdapter.getElement(target); |
| 514 ClosureClassMap classMap = compiler.closureToClassMapper |
| 515 .getClosureToClassMapping(element.resolvedAst); |
| 516 return classMap.callElement; |
| 517 } |
| 518 if (target is ir.FunctionDeclaration) { |
| 519 LocalFunctionElement element = astAdapter.getElement(target); |
| 520 ClosureClassMap classMap = compiler.closureToClassMapper |
| 521 .getClosureToClassMapping(element.resolvedAst); |
| 522 return classMap.callElement; |
| 523 } |
| 524 Element element = astAdapter.getElement(target); |
| 525 return element; |
| 526 } |
| 506 | 527 |
| 507 @override | 528 @override |
| 508 void visitBlock(ir.Block block) { | 529 void visitBlock(ir.Block block) { |
| 509 assert(!isAborted()); | 530 assert(!isAborted()); |
| 510 for (ir.Statement statement in block.statements) { | 531 for (ir.Statement statement in block.statements) { |
| 511 statement.accept(this); | 532 statement.accept(this); |
| 512 if (!isReachable) { | 533 if (!isReachable) { |
| 513 // The block has been aborted by a return or a throw. | 534 // The block has been aborted by a return or a throw. |
| 514 if (stack.isNotEmpty) { | 535 if (stack.isNotEmpty) { |
| 515 compiler.reporter.internalError( | 536 compiler.reporter.internalError( |
| (...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 kernelBuilder.open(exitBlock); | 2522 kernelBuilder.open(exitBlock); |
| 2502 enterBlock.setBlockFlow( | 2523 enterBlock.setBlockFlow( |
| 2503 new HTryBlockInformation( | 2524 new HTryBlockInformation( |
| 2504 kernelBuilder.wrapStatementGraph(bodyGraph), | 2525 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 2505 exception, | 2526 exception, |
| 2506 kernelBuilder.wrapStatementGraph(catchGraph), | 2527 kernelBuilder.wrapStatementGraph(catchGraph), |
| 2507 kernelBuilder.wrapStatementGraph(finallyGraph)), | 2528 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 2508 exitBlock); | 2529 exitBlock); |
| 2509 } | 2530 } |
| 2510 } | 2531 } |
| OLD | NEW |