Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1068243002: Overhaul tree IR visitor and rename IR classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../constants/expressions.dart'; 7 import '../constants/expressions.dart';
8 import '../constants/values.dart' show PrimitiveConstantValue; 8 import '../constants/values.dart' show PrimitiveConstantValue;
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../dart2jslib.dart'; 10 import '../dart2jslib.dart';
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 * such as `foo(){ }`. 629 * such as `foo(){ }`.
630 */ 630 */
631 void _ensureReturn() { 631 void _ensureReturn() {
632 if (!isOpen) return; 632 if (!isOpen) return;
633 ir.Constant constant = buildNullLiteral(); 633 ir.Constant constant = buildNullLiteral();
634 add(new ir.InvokeContinuation(state.returnContinuation, [constant])); 634 add(new ir.InvokeContinuation(state.returnContinuation, [constant]));
635 _current = null; 635 _current = null;
636 } 636 }
637 637
638 ir.SuperInitializer makeSuperInitializer(ConstructorElement target, 638 ir.SuperInitializer makeSuperInitializer(ConstructorElement target,
639 List<ir.RunnableBody> arguments, 639 List<ir.Body> arguments,
640 Selector selector) { 640 Selector selector) {
641 return new ir.SuperInitializer(target, arguments, selector); 641 return new ir.SuperInitializer(target, arguments, selector);
642 } 642 }
643 643
644 ir.FieldInitializer makeFieldInitializer(FieldElement element, 644 ir.FieldInitializer makeFieldInitializer(FieldElement element,
645 ir.RunnableBody body) { 645 ir.Body body) {
646 return new ir.FieldInitializer(element, body); 646 return new ir.FieldInitializer(element, body);
647 } 647 }
648 648
649 /// Create a [ir.FieldDefinition] for the current [Element] using [_root] as 649 /// Create a [ir.FieldDefinition] for the current [Element] using [_root] as
650 /// the body using [initializer] as the initial value. 650 /// the body using [initializer] as the initial value.
651 ir.FieldDefinition makeFieldDefinition(ir.Primitive initializer) { 651 ir.FieldDefinition makeFieldDefinition(ir.Primitive initializer) {
652 if (initializer == null) { 652 if (initializer == null) {
653 return new ir.FieldDefinition.withoutInitializer(state.currentElement); 653 return new ir.FieldDefinition.withoutInitializer(state.currentElement);
654 } else { 654 } else {
655 ir.RunnableBody body = makeRunnableBody(initializer); 655 ir.Body body = makeBody(initializer);
656 return new ir.FieldDefinition(state.currentElement, body); 656 return new ir.FieldDefinition(state.currentElement, body);
657 } 657 }
658 } 658 }
659 659
660 ir.RunnableBody makeRunnableBody([ir.Primitive value]) { 660 ir.Body makeBody([ir.Primitive value]) {
661 if (value == null) { 661 if (value == null) {
662 _ensureReturn(); 662 _ensureReturn();
663 } else { 663 } else {
664 buildReturn(value); 664 buildReturn(value);
665 } 665 }
666 return new ir.RunnableBody(_root, state.returnContinuation); 666 return new ir.Body(_root, state.returnContinuation);
667 } 667 }
668 668
669 /// Create a [ir.FunctionDefinition] for [element] using [_root] as the body. 669 /// Create a [ir.FunctionDefinition] for [element] using [_root] as the body.
670 /// 670 ///
671 /// Parameters must be created before the construction of the body using 671 /// Parameters must be created before the construction of the body using
672 /// [createFunctionParameter]. 672 /// [createFunctionParameter].
673 ir.FunctionDefinition makeFunctionDefinition( 673 ir.FunctionDefinition makeFunctionDefinition(
674 List<ConstantExpression> defaults) { 674 List<ConstantExpression> defaults) {
675 FunctionElement element = state.currentElement; 675 FunctionElement element = state.currentElement;
676 if (element.isAbstract || element.isExternal) { 676 if (element.isAbstract || element.isExternal) {
677 assert(invariant(element, _root == null, 677 assert(invariant(element, _root == null,
678 message: "Non-empty body for abstract method $element: $_root")); 678 message: "Non-empty body for abstract method $element: $_root"));
679 assert(invariant(element, state.localConstants.isEmpty, 679 assert(invariant(element, state.localConstants.isEmpty,
680 message: "Local constants for abstract method $element: " 680 message: "Local constants for abstract method $element: "
681 "${state.localConstants}")); 681 "${state.localConstants}"));
682 return new ir.FunctionDefinition.abstract( 682 return new ir.FunctionDefinition.abstract(
683 element, state.thisParameter, state.functionParameters, defaults); 683 element, state.functionParameters, defaults);
684 } else { 684 } else {
685 ir.RunnableBody body = makeRunnableBody(); 685 ir.Body body = makeBody();
686 return new ir.FunctionDefinition( 686 return new ir.FunctionDefinition(
687 element, state.thisParameter, state.functionParameters, body, 687 element, state.thisParameter, state.functionParameters, body,
688 state.localConstants, defaults); 688 state.localConstants, defaults);
689 } 689 }
690 } 690 }
691 691
692 /// Create a constructor definition without a body, for representing 692 /// Create a constructor definition without a body, for representing
693 /// external constructors declarations. 693 /// external constructors declarations.
694 ir.ConstructorDefinition makeAbstractConstructorDefinition( 694 ir.ConstructorDefinition makeAbstractConstructorDefinition(
695 List<ConstantExpression> defaults) { 695 List<ConstantExpression> defaults) {
696 FunctionElement element = state.currentElement; 696 FunctionElement element = state.currentElement;
697 assert(invariant(element, _root == null, 697 assert(invariant(element, _root == null,
698 message: "Non-empty body for external constructor $element: $_root")); 698 message: "Non-empty body for external constructor $element: $_root"));
699 assert(invariant(element, state.localConstants.isEmpty, 699 assert(invariant(element, state.localConstants.isEmpty,
700 message: "Local constants for external constructor $element: " 700 message: "Local constants for external constructor $element: "
701 "${state.localConstants}")); 701 "${state.localConstants}"));
702 return new ir.ConstructorDefinition.abstract( 702 return new ir.ConstructorDefinition.abstract(
703 element, state.functionParameters, defaults); 703 element, state.functionParameters, defaults);
704 } 704 }
705 705
706 ir.ConstructorDefinition makeConstructorDefinition( 706 ir.ConstructorDefinition makeConstructorDefinition(
707 List<ConstantExpression> defaults, List<ir.Initializer> initializers) { 707 List<ConstantExpression> defaults, List<ir.Initializer> initializers) {
708 FunctionElement element = state.currentElement; 708 FunctionElement element = state.currentElement;
709 ir.RunnableBody body = makeRunnableBody(); 709 ir.Body body = makeBody();
710 return new ir.ConstructorDefinition( 710 return new ir.ConstructorDefinition(
711 element, state.thisParameter, state.functionParameters, body, initialize rs, 711 element, state.thisParameter, state.functionParameters, body, initialize rs,
712 state.localConstants, defaults); 712 state.localConstants, defaults);
713 } 713 }
714 714
715 /// Create a super invocation where the method name and the argument structure 715 /// Create a super invocation where the method name and the argument structure
716 /// are defined by [selector] and the argument values are defined by 716 /// are defined by [selector] and the argument values are defined by
717 /// [arguments]. 717 /// [arguments].
718 ir.Primitive buildSuperInvocation(Element target, 718 ir.Primitive buildSuperInvocation(Element target,
719 Selector selector, 719 Selector selector,
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 } 2585 }
2586 2586
2587 /// Synthetic parameter to a JavaScript factory method that takes the type 2587 /// Synthetic parameter to a JavaScript factory method that takes the type
2588 /// argument given for the type variable [variable]. 2588 /// argument given for the type variable [variable].
2589 class TypeInformationParameter implements Local { 2589 class TypeInformationParameter implements Local {
2590 final TypeVariableElement variable; 2590 final TypeVariableElement variable;
2591 final ExecutableElement executableContext; 2591 final ExecutableElement executableContext;
2592 TypeInformationParameter(this.variable, this.executableContext); 2592 TypeInformationParameter(this.variable, this.executableContext);
2593 String get name => variable.name; 2593 String get name => variable.name;
2594 } 2594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698