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

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: address comments 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 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 push(new js.Call(jsHelper, <js.Expression>[pop()]), node); 2123 push(new js.Call(jsHelper, <js.Expression>[pop()]), node);
2124 } 2124 }
2125 } 2125 }
2126 2126
2127 void visitLiteralList(HLiteralList node) { 2127 void visitLiteralList(HLiteralList node) {
2128 registry.registerInstantiatedClass(compiler.listClass); 2128 registry.registerInstantiatedClass(compiler.listClass);
2129 generateArrayLiteral(node); 2129 generateArrayLiteral(node);
2130 } 2130 }
2131 2131
2132 void generateArrayLiteral(HLiteralList node) { 2132 void generateArrayLiteral(HLiteralList node) {
2133 int len = node.inputs.length; 2133 List<js.Expression> elements = node.inputs.map((HInstruction input) {
2134 List<js.ArrayElement> elements = <js.ArrayElement>[]; 2134 use(input);
2135 for (int i = 0; i < len; i++) { 2135 return pop();
2136 use(node.inputs[i]); 2136 }).toList();
2137 elements.add(new js.ArrayElement(i, pop())); 2137 push(new js.ArrayInitializer(elements), node);
2138 }
2139 push(new js.ArrayInitializer(len, elements), node);
2140 } 2138 }
2141 2139
2142 void visitIndex(HIndex node) { 2140 void visitIndex(HIndex node) {
2143 use(node.receiver); 2141 use(node.receiver);
2144 js.Expression receiver = pop(); 2142 js.Expression receiver = pop();
2145 use(node.index); 2143 use(node.index);
2146 push(new js.PropertyAccess(receiver, pop()), node); 2144 push(new js.PropertyAccess(receiver, pop()), node);
2147 } 2145 }
2148 2146
2149 void visitIndexAssign(HIndexAssign node) { 2147 void visitIndexAssign(HIndexAssign node) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 for (var _ in type.namedParameters) { 2641 for (var _ in type.namedParameters) {
2644 use(node.inputs[inputCount++]); 2642 use(node.inputs[inputCount++]);
2645 js.Expression name = pop(); 2643 js.Expression name = pop();
2646 use(node.inputs[inputCount++]); 2644 use(node.inputs[inputCount++]);
2647 namedParameters.add(new js.Property(name, pop())); 2645 namedParameters.add(new js.Property(name, pop()));
2648 } 2646 }
2649 2647
2650 if (namedParameters.isEmpty) { 2648 if (namedParameters.isEmpty) {
2651 var arguments = [returnType]; 2649 var arguments = [returnType];
2652 if (!parameterTypes.isEmpty || !optionalParameterTypes.isEmpty) { 2650 if (!parameterTypes.isEmpty || !optionalParameterTypes.isEmpty) {
2653 arguments.add(new js.ArrayInitializer.from(parameterTypes)); 2651 arguments.add(new js.ArrayInitializer(parameterTypes));
2654 } 2652 }
2655 if (!optionalParameterTypes.isEmpty) { 2653 if (!optionalParameterTypes.isEmpty) {
2656 arguments.add(new js.ArrayInitializer.from(optionalParameterTypes)); 2654 arguments.add(new js.ArrayInitializer(optionalParameterTypes));
2657 } 2655 }
2658 push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments])); 2656 push(js.js('#(#)', [accessHelper('buildFunctionType'), arguments]));
2659 } else { 2657 } else {
2660 var arguments = [ 2658 var arguments = [
2661 returnType, 2659 returnType,
2662 new js.ArrayInitializer.from(parameterTypes), 2660 new js.ArrayInitializer(parameterTypes),
2663 new js.ObjectInitializer(namedParameters)]; 2661 new js.ObjectInitializer(namedParameters)];
2664 push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments])); 2662 push(js.js('#(#)', [accessHelper('buildNamedFunctionType'), arguments]));
2665 } 2663 }
2666 } 2664 }
2667 2665
2668 void visitReadTypeVariable(HReadTypeVariable node) { 2666 void visitReadTypeVariable(HReadTypeVariable node) {
2669 TypeVariableElement element = node.dartType.element; 2667 TypeVariableElement element = node.dartType.element;
2670 Element helperElement = backend.findHelper('convertRtiToRuntimeType'); 2668 Element helperElement = backend.findHelper('convertRtiToRuntimeType');
2671 registry.registerStaticUse(helperElement); 2669 registry.registerStaticUse(helperElement);
2672 2670
(...skipping 21 matching lines...) Expand all
2694 void visitInterfaceType(HInterfaceType node) { 2692 void visitInterfaceType(HInterfaceType node) {
2695 List<js.Expression> typeArguments = <js.Expression>[]; 2693 List<js.Expression> typeArguments = <js.Expression>[];
2696 for (HInstruction type in node.inputs) { 2694 for (HInstruction type in node.inputs) {
2697 use(type); 2695 use(type);
2698 typeArguments.add(pop()); 2696 typeArguments.add(pop());
2699 } 2697 }
2700 2698
2701 ClassElement cls = node.dartType.element; 2699 ClassElement cls = node.dartType.element;
2702 var arguments = [backend.namer.elementAccess(cls)]; 2700 var arguments = [backend.namer.elementAccess(cls)];
2703 if (!typeArguments.isEmpty) { 2701 if (!typeArguments.isEmpty) {
2704 arguments.add(new js.ArrayInitializer.from(typeArguments)); 2702 arguments.add(new js.ArrayInitializer(typeArguments));
2705 } 2703 }
2706 push(js.js('#(#)', [accessHelper('buildInterfaceType'), arguments])); 2704 push(js.js('#(#)', [accessHelper('buildInterfaceType'), arguments]));
2707 } 2705 }
2708 2706
2709 void visitVoidType(HVoidType node) { 2707 void visitVoidType(HVoidType node) {
2710 push(js.js('#()', accessHelper('getVoidRuntimeType'))); 2708 push(js.js('#()', accessHelper('getVoidRuntimeType')));
2711 } 2709 }
2712 2710
2713 void visitDynamicType(HDynamicType node) { 2711 void visitDynamicType(HDynamicType node) {
2714 push(js.js('#()', accessHelper('getDynamicRuntimeType'))); 2712 push(js.js('#()', accessHelper('getDynamicRuntimeType')));
2715 } 2713 }
2716 2714
2717 js.PropertyAccess accessHelper(String name) { 2715 js.PropertyAccess accessHelper(String name) {
2718 Element helper = backend.findHelper(name); 2716 Element helper = backend.findHelper(name);
2719 if (helper == null) { 2717 if (helper == null) {
2720 // For mocked-up tests. 2718 // For mocked-up tests.
2721 return js.js('(void 0).$name'); 2719 return js.js('(void 0).$name');
2722 } 2720 }
2723 registry.registerStaticUse(helper); 2721 registry.registerStaticUse(helper);
2724 return backend.namer.elementAccess(helper); 2722 return backend.namer.elementAccess(helper);
2725 } 2723 }
2726 } 2724 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart ('k') | pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698