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

Side by Side Diff: pkg/compiler/lib/src/ssa/codegen.dart

Issue 750323003: Remove js.ArrayElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 push(new js.Call(jsHelper, <js.Expression>[pop()]), node); 2122 push(new js.Call(jsHelper, <js.Expression>[pop()]), node);
2123 } 2123 }
2124 } 2124 }
2125 2125
2126 void visitLiteralList(HLiteralList node) { 2126 void visitLiteralList(HLiteralList node) {
2127 registry.registerInstantiatedClass(compiler.listClass); 2127 registry.registerInstantiatedClass(compiler.listClass);
2128 generateArrayLiteral(node); 2128 generateArrayLiteral(node);
2129 } 2129 }
2130 2130
2131 void generateArrayLiteral(HLiteralList node) { 2131 void generateArrayLiteral(HLiteralList node) {
2132 int len = node.inputs.length; 2132 List<js.Expression> elements = node.inputs.map((HInstruction input) {
2133 List<js.ArrayElement> elements = <js.ArrayElement>[]; 2133 use(input);
2134 for (int i = 0; i < len; i++) { 2134 return pop();
2135 use(node.inputs[i]); 2135 }).toList();
2136 elements.add(new js.ArrayElement(i, pop())); 2136 push(new js.ArrayInitializer(elements), node);
2137 }
2138 push(new js.ArrayInitializer(len, elements), node);
2139 } 2137 }
2140 2138
2141 void visitIndex(HIndex node) { 2139 void visitIndex(HIndex node) {
2142 use(node.receiver); 2140 use(node.receiver);
2143 js.Expression receiver = pop(); 2141 js.Expression receiver = pop();
2144 use(node.index); 2142 use(node.index);
2145 push(new js.PropertyAccess(receiver, pop()), node); 2143 push(new js.PropertyAccess(receiver, pop()), node);
2146 } 2144 }
2147 2145
2148 void visitIndexAssign(HIndexAssign node) { 2146 void visitIndexAssign(HIndexAssign node) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 for (var _ in type.namedParameters) { 2640 for (var _ in type.namedParameters) {
2643 use(node.inputs[inputCount++]); 2641 use(node.inputs[inputCount++]);
2644 js.Expression name = pop(); 2642 js.Expression name = pop();
2645 use(node.inputs[inputCount++]); 2643 use(node.inputs[inputCount++]);
2646 namedParameters.add(new js.Property(name, pop())); 2644 namedParameters.add(new js.Property(name, pop()));
2647 } 2645 }
2648 2646
2649 if (namedParameters.isEmpty) { 2647 if (namedParameters.isEmpty) {
2650 var arguments = [returnType]; 2648 var arguments = [returnType];
2651 if (!parameterTypes.isEmpty || !optionalParameterTypes.isEmpty) { 2649 if (!parameterTypes.isEmpty || !optionalParameterTypes.isEmpty) {
2652 arguments.add(new js.ArrayInitializer.from(parameterTypes)); 2650 arguments.add(new js.ArrayInitializer(parameterTypes));
2653 } 2651 }
2654 if (!optionalParameterTypes.isEmpty) { 2652 if (!optionalParameterTypes.isEmpty) {
2655 arguments.add(new js.ArrayInitializer.from(optionalParameterTypes)); 2653 arguments.add(new js.ArrayInitializer(optionalParameterTypes));
2656 } 2654 }
2657 push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments])); 2655 push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments]));
2658 } else { 2656 } else {
2659 var arguments = [ 2657 var arguments = [
2660 returnType, 2658 returnType,
2661 new js.ArrayInitializer.from(parameterTypes), 2659 new js.ArrayInitializer(parameterTypes),
2662 new js.ObjectInitializer(namedParameters)]; 2660 new js.ObjectInitializer(namedParameters)];
2663 push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments])); 2661 push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments]));
2664 } 2662 }
2665 } 2663 }
2666 2664
2667 void visitReadTypeVariable(HReadTypeVariable node) { 2665 void visitReadTypeVariable(HReadTypeVariable node) {
2668 TypeVariableElement element = node.dartType.element; 2666 TypeVariableElement element = node.dartType.element;
2669 Element helperElement = backend.findHelper('convertRtiToRuntimeType'); 2667 Element helperElement = backend.findHelper('convertRtiToRuntimeType');
2670 registry.registerStaticUse(helperElement); 2668 registry.registerStaticUse(helperElement);
2671 2669
(...skipping 21 matching lines...) Expand all
2693 void visitInterfaceType(HInterfaceType node) { 2691 void visitInterfaceType(HInterfaceType node) {
2694 List<js.Expression> typeArguments = <js.Expression>[]; 2692 List<js.Expression> typeArguments = <js.Expression>[];
2695 for (HInstruction type in node.inputs) { 2693 for (HInstruction type in node.inputs) {
2696 use(type); 2694 use(type);
2697 typeArguments.add(pop()); 2695 typeArguments.add(pop());
2698 } 2696 }
2699 2697
2700 ClassElement cls = node.dartType.element; 2698 ClassElement cls = node.dartType.element;
2701 var arguments = [backend.namer.elementAccess(cls)]; 2699 var arguments = [backend.namer.elementAccess(cls)];
2702 if (!typeArguments.isEmpty) { 2700 if (!typeArguments.isEmpty) {
2703 arguments.add(new js.ArrayInitializer.from(typeArguments)); 2701 arguments.add(new js.ArrayInitializer(typeArguments));
2704 } 2702 }
2705 push(js.js('#(#)', [accessHelper('buildInterfaceType'), arguments])); 2703 push(js.js('#(#)', [accessHelper('buildInterfaceType'), arguments]));
2706 } 2704 }
2707 2705
2708 void visitVoidType(HVoidType node) { 2706 void visitVoidType(HVoidType node) {
2709 push(js.js('#()', accessHelper('getVoidRuntimeType'))); 2707 push(js.js('#()', accessHelper('getVoidRuntimeType')));
2710 } 2708 }
2711 2709
2712 void visitDynamicType(HDynamicType node) { 2710 void visitDynamicType(HDynamicType node) {
2713 push(js.js('#()', accessHelper('getDynamicRuntimeType'))); 2711 push(js.js('#()', accessHelper('getDynamicRuntimeType')));
2714 } 2712 }
2715 2713
2716 js.PropertyAccess accessHelper(String name) { 2714 js.PropertyAccess accessHelper(String name) {
2717 Element helper = backend.findHelper(name); 2715 Element helper = backend.findHelper(name);
2718 if (helper == null) { 2716 if (helper == null) {
2719 // For mocked-up tests. 2717 // For mocked-up tests.
2720 return js.js('(void 0).$name'); 2718 return js.js('(void 0).$name');
2721 } 2719 }
2722 registry.registerStaticUse(helper); 2720 registry.registerStaticUse(helper);
2723 return backend.namer.elementAccess(helper); 2721 return backend.namer.elementAccess(helper);
2724 } 2722 }
2725 } 2723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698