OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library tree_ir_builder; | 5 library tree_ir_builder; |
6 | 6 |
7 import '../diagnostics/invariant.dart' show | 7 import '../diagnostics/invariant.dart' show |
8 InternalErrorFunction; | 8 InternalErrorFunction; |
9 import '../diagnostics/spannable.dart' show | 9 import '../diagnostics/spannable.dart' show |
10 CURRENT_ELEMENT_SPANNABLE; | 10 CURRENT_ELEMENT_SPANNABLE; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 NodeCallback visitGetLazyStatic(cps_ir.GetLazyStatic node) { | 432 NodeCallback visitGetLazyStatic(cps_ir.GetLazyStatic node) { |
433 // In the tree IR, GetStatic handles lazy fields because we do not need | 433 // In the tree IR, GetStatic handles lazy fields because we do not need |
434 // as fine-grained control over side effects. | 434 // as fine-grained control over side effects. |
435 GetStatic value = new GetStatic(node.element, node.sourceInformation); | 435 GetStatic value = new GetStatic(node.element, node.sourceInformation); |
436 return makeCallExpression(node, value); | 436 return makeCallExpression(node, value); |
437 } | 437 } |
438 | 438 |
| 439 @override |
| 440 NodeCallback visitYield(cps_ir.Yield node) { |
| 441 return (Statement next) { |
| 442 return new Yield(getVariableUse(node.input), node.hasStar, next); |
| 443 }; |
| 444 } |
| 445 |
| 446 @override |
| 447 NodeCallback visitAwait(cps_ir.Await node) { |
| 448 Expression value = new Await(getVariableUse(node.input)); |
| 449 return makeCallExpression(node, value); |
| 450 } |
| 451 |
439 | 452 |
440 /************************** TAIL EXPRESSIONS **************************/ | 453 /************************** TAIL EXPRESSIONS **************************/ |
441 // | 454 // |
442 // Visit methods for tail expressions must return a statement directly | 455 // Visit methods for tail expressions must return a statement directly |
443 // (not a function like interior and call expressions). | 456 // (not a function like interior and call expressions). |
444 | 457 |
445 Statement visitThrow(cps_ir.Throw node) { | 458 Statement visitThrow(cps_ir.Throw node) { |
446 Expression value = getVariableUse(node.value); | 459 Expression value = getVariableUse(node.value); |
447 return new Throw(value); | 460 return new Throw(value); |
448 } | 461 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 getVariableUse(node.index)); | 676 getVariableUse(node.index)); |
664 } | 677 } |
665 | 678 |
666 Expression visitSetIndex(cps_ir.SetIndex node) { | 679 Expression visitSetIndex(cps_ir.SetIndex node) { |
667 return new SetIndex(getVariableUse(node.object), | 680 return new SetIndex(getVariableUse(node.object), |
668 getVariableUse(node.index), | 681 getVariableUse(node.index), |
669 getVariableUse(node.value)); | 682 getVariableUse(node.value)); |
670 } | 683 } |
671 | 684 |
672 @override | 685 @override |
673 NodeCallback visitAwait(cps_ir.Await node) { | |
674 Expression value = new Await(getVariableUse(node.input)); | |
675 return makeCallExpression(node, value); | |
676 } | |
677 | |
678 @override | |
679 Expression visitRefinement(cps_ir.Refinement node) { | 686 Expression visitRefinement(cps_ir.Refinement node) { |
680 throw 'Unexpected Refinement node in tree builder'; | 687 throw 'Unexpected Refinement node in tree builder'; |
681 } | 688 } |
682 | 689 |
683 /********** UNUSED VISIT METHODS *************/ | 690 /********** UNUSED VISIT METHODS *************/ |
684 | 691 |
685 unexpectedNode(cps_ir.Node node) { | 692 unexpectedNode(cps_ir.Node node) { |
686 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node'); | 693 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node'); |
687 } | 694 } |
688 | 695 |
689 visitFunctionDefinition(cps_ir.FunctionDefinition node) { | 696 visitFunctionDefinition(cps_ir.FunctionDefinition node) { |
690 unexpectedNode(node); | 697 unexpectedNode(node); |
691 } | 698 } |
692 visitParameter(cps_ir.Parameter node) => unexpectedNode(node); | 699 visitParameter(cps_ir.Parameter node) => unexpectedNode(node); |
693 visitContinuation(cps_ir.Continuation node) => unexpectedNode(node); | 700 visitContinuation(cps_ir.Continuation node) => unexpectedNode(node); |
694 visitMutableVariable(cps_ir.MutableVariable node) => unexpectedNode(node); | 701 visitMutableVariable(cps_ir.MutableVariable node) => unexpectedNode(node); |
695 } | 702 } |
696 | 703 |
OLD | NEW |