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

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

Issue 1067533003: cps-ir: Handle factories and redirecting constructors with JS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fix in test case 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 void buildNodes() { 90 void buildNodes() {
91 measure(() { 91 measure(() {
92 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements; 92 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements;
93 resolved.forEach(buildNode); 93 resolved.forEach(buildNode);
94 }); 94 });
95 } 95 }
96 96
97 bool canBuild(Element element) { 97 bool canBuild(Element element) {
98 // If using JavaScript backend, don't try to bail out early.
99 if (compiler.backend is JavaScriptBackend) return true;
100
98 if (element is TypedefElement) return false; 101 if (element is TypedefElement) return false;
99 if (element is FunctionElement) { 102 if (element is FunctionElement) {
100 // TODO(sigurdm): Support native functions for dart2js. 103 // TODO(sigurdm): Support native functions for dart2js.
101 assert(invariant(element, !element.isNative)); 104 assert(invariant(element, !element.isNative));
102 105
103 if (element is ConstructorElement) { 106 if (element is ConstructorElement) {
104 if (!element.isGenerativeConstructor) { 107 if (!element.isGenerativeConstructor) {
105 // TODO(kmillikin,sigurdm): Support constructors. 108 // TODO(kmillikin,sigurdm): Support constructors.
106 return false; 109 return false;
107 } 110 }
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 _) { 1750 _) {
1748 return translateCompound( 1751 return translateCompound(
1749 getValue: () => irBuilder.buildSuperMethodGet(method), 1752 getValue: () => irBuilder.buildSuperMethodGet(method),
1750 operator: operator, 1753 operator: operator,
1751 rhs: rhs, 1754 rhs: rhs,
1752 setValue: (ir.Primitive result) { 1755 setValue: (ir.Primitive result) {
1753 irBuilder.buildSuperSetterSet(setter, result); 1756 irBuilder.buildSuperSetterSet(setter, result);
1754 }); 1757 });
1755 } 1758 }
1756 1759
1757 @override
1758 ir.Primitive handleConstructorInvoke(
1759 ast.NewExpression node,
1760 ConstructorElement constructor,
1761 DartType type,
1762 ast.NodeList arguments,
1763 Selector selector, _) {
1764 List<ir.Primitive> arguments =
1765 node.send.arguments.mapToList(visit, growable:false);
1766 arguments = normalizeStaticArguments(
1767 selector.callStructure, constructor, arguments);
1768 return irBuilder.buildConstructorInvocation(
1769 constructor, selector, type, arguments);
1770 }
1771
1772 ir.Primitive visitStringJuxtaposition(ast.StringJuxtaposition node) { 1760 ir.Primitive visitStringJuxtaposition(ast.StringJuxtaposition node) {
1773 assert(irBuilder.isOpen); 1761 assert(irBuilder.isOpen);
1774 ir.Primitive first = visit(node.first); 1762 ir.Primitive first = visit(node.first);
1775 ir.Primitive second = visit(node.second); 1763 ir.Primitive second = visit(node.second);
1776 return irBuilder.buildStringConcatenation([first, second]); 1764 return irBuilder.buildStringConcatenation([first, second]);
1777 } 1765 }
1778 1766
1779 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) { 1767 ir.Primitive visitStringInterpolation(ast.StringInterpolation node) {
1780 assert(irBuilder.isOpen); 1768 assert(irBuilder.isOpen);
1781 List<ir.Primitive> arguments = []; 1769 List<ir.Primitive> arguments = [];
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 } 2102 }
2115 2103
2116 @override 2104 @override
2117 ir.Primitive buildReifyTypeVariable(ir.Primitive target, 2105 ir.Primitive buildReifyTypeVariable(ir.Primitive target,
2118 TypeVariableType variable) { 2106 TypeVariableType variable) {
2119 assert(target == irBuilder.state.enclosingMethodThisParameter); 2107 assert(target == irBuilder.state.enclosingMethodThisParameter);
2120 ir.Primitive prim = new ir.ReifyTypeVar(variable.element); 2108 ir.Primitive prim = new ir.ReifyTypeVar(variable.element);
2121 irBuilder.add(new ir.LetPrim(prim)); 2109 irBuilder.add(new ir.LetPrim(prim));
2122 return prim; 2110 return prim;
2123 } 2111 }
2112
2113 @override
2114 ir.Primitive handleConstructorInvoke(
2115 ast.NewExpression node,
2116 ConstructorElement constructor,
2117 DartType type,
2118 ast.NodeList arguments,
2119 Selector selector, _) {
2120 List<ir.Primitive> arguments =
2121 node.send.arguments.mapToList(visit, growable:false);
2122 return irBuilder.buildConstructorInvocation(
2123 constructor,
2124 selector,
2125 type,
2126 arguments);
2127 }
2124 } 2128 }
2125 2129
2126 /// The [IrBuilder]s view on the information about the program that has been 2130 /// The [IrBuilder]s view on the information about the program that has been
2127 /// computed in resolution and and type interence. 2131 /// computed in resolution and and type interence.
2128 class GlobalProgramInformation { 2132 class GlobalProgramInformation {
2129 final Compiler _compiler; 2133 final Compiler _compiler;
2130 JavaScriptBackend get _backend => _compiler.backend; 2134 JavaScriptBackend get _backend => _compiler.backend;
2131 2135
2132 GlobalProgramInformation(this._compiler); 2136 GlobalProgramInformation(this._compiler);
2133 2137
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 @override 2704 @override
2701 ir.Primitive buildReifyTypeVariable(ir.Primitive target, 2705 ir.Primitive buildReifyTypeVariable(ir.Primitive target,
2702 TypeVariableType variable) { 2706 TypeVariableType variable) {
2703 ir.Primitive typeArgument = 2707 ir.Primitive typeArgument =
2704 irBuilder.buildTypeVariableAccess(target, variable); 2708 irBuilder.buildTypeVariableAccess(target, variable);
2705 2709
2706 ir.Primitive type = new ir.ReifyRuntimeType(typeArgument); 2710 ir.Primitive type = new ir.ReifyRuntimeType(typeArgument);
2707 irBuilder.add(new ir.LetPrim(type)); 2711 irBuilder.add(new ir.LetPrim(type));
2708 return type; 2712 return type;
2709 } 2713 }
2714
2715 @override
2716 ir.Primitive handleConstructorInvoke(
2717 ast.NewExpression node,
2718 ConstructorElement constructor,
2719 DartType type,
2720 ast.NodeList arguments,
2721 Selector selector, _) {
2722 List<ir.Primitive> arguments =
2723 node.send.arguments.mapToList(visit, growable:false);
2724 arguments = normalizeStaticArguments(
2725 selector.callStructure, constructor, arguments);
2726 return irBuilder.buildConstructorInvocation(
2727 constructor.effectiveTarget,
2728 selector,
2729 constructor.computeEffectiveTargetType(type),
2730 arguments);
2731 }
2710 } 2732 }
2711 2733
2712 /// Interface for generating [SourceInformation] for the CPS. 2734 /// Interface for generating [SourceInformation] for the CPS.
2713 class SourceInformationBuilder { 2735 class SourceInformationBuilder {
2714 const SourceInformationBuilder(); 2736 const SourceInformationBuilder();
2715 2737
2716 /// Create a [SourceInformationBuilder] for [element]. 2738 /// Create a [SourceInformationBuilder] for [element].
2717 SourceInformationBuilder forContext(AstElement element) => this; 2739 SourceInformationBuilder forContext(AstElement element) => this;
2718 2740
2719 /// Generate [SourceInformation] for the read access in [node]. 2741 /// Generate [SourceInformation] for the read access in [node].
(...skipping 22 matching lines...) Expand all
2742 SourceInformation buildCall(ast.Node node) { 2764 SourceInformation buildCall(ast.Node node) {
2743 return new PositionSourceInformation( 2765 return new PositionSourceInformation(
2744 new TokenSourceLocation(sourceFile, node.getBeginToken(), name)); 2766 new TokenSourceLocation(sourceFile, node.getBeginToken(), name));
2745 } 2767 }
2746 2768
2747 @override 2769 @override
2748 SourceInformationBuilder forContext(AstElement element) { 2770 SourceInformationBuilder forContext(AstElement element) {
2749 return new PositionSourceInformationBuilder(element); 2771 return new PositionSourceInformationBuilder(element);
2750 } 2772 }
2751 } 2773 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698