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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 263153002: Fix passing of type arguments in redirecting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/language/regress_18535_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) 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 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to implement [TypedElement.type] because our 9 * methods. We need to implement [TypedElement.type] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 4783 matching lines...) Expand 10 before | Expand all | Expand 10 after
4794 closeAndGotoExit(new HThrow(exception, isRethrow: true)); 4794 closeAndGotoExit(new HThrow(exception, isRethrow: true));
4795 } 4795 }
4796 4796
4797 visitReturn(ast.Return node) { 4797 visitReturn(ast.Return node) {
4798 if (identical(node.getBeginToken().stringValue, 'native')) { 4798 if (identical(node.getBeginToken().stringValue, 'native')) {
4799 native.handleSsaNative(this, node.expression); 4799 native.handleSsaNative(this, node.expression);
4800 return; 4800 return;
4801 } 4801 }
4802 HInstruction value; 4802 HInstruction value;
4803 if (node.isRedirectingFactoryBody) { 4803 if (node.isRedirectingFactoryBody) {
4804 FunctionElement element = elements[node.expression].implementation; 4804 FunctionElement targetConstructor =
4805 FunctionElement function = sourceElement; 4805 elements[node.expression].implementation;
4806 FunctionElement redirectingConstructor = sourceElement;
4806 List<HInstruction> inputs = <HInstruction>[]; 4807 List<HInstruction> inputs = <HInstruction>[];
4807 FunctionSignature calleeSignature = element.functionSignature; 4808 FunctionSignature targetSignature = targetConstructor.functionSignature;
4808 FunctionSignature callerSignature = function.functionSignature; 4809 FunctionSignature redirectingSignature =
4809 callerSignature.forEachRequiredParameter((Element element) { 4810 redirectingConstructor.functionSignature;
4811 redirectingSignature.forEachRequiredParameter((Element element) {
4810 inputs.add(localsHandler.readLocal(element)); 4812 inputs.add(localsHandler.readLocal(element));
4811 }); 4813 });
4812 List<Element> calleeOptionals = 4814 List<Element> targetOptionals =
4813 calleeSignature.orderedOptionalParameters; 4815 targetSignature.orderedOptionalParameters;
4814 List<Element> callerOptionals = 4816 List<Element> redirectingOptionals =
4815 callerSignature.orderedOptionalParameters; 4817 redirectingSignature.orderedOptionalParameters;
4816 int i = 0; 4818 int i = 0;
4817 for (; i < callerOptionals.length; i++) { 4819 for (; i < redirectingOptionals.length; i++) {
4818 inputs.add(localsHandler.readLocal(callerOptionals[i])); 4820 inputs.add(localsHandler.readLocal(redirectingOptionals[i]));
4819 } 4821 }
4820 for (; i < calleeOptionals.length; i++) { 4822 for (; i < targetOptionals.length; i++) {
4821 inputs.add(handleConstantForOptionalParameter(calleeOptionals[i])); 4823 inputs.add(handleConstantForOptionalParameter(targetOptionals[i]));
4822 } 4824 }
4823 4825
4824 if (backend.classNeedsRti(element.getEnclosingClass())) { 4826 ClassElement targetClass = targetConstructor.getEnclosingClass();
4825 ClassElement cls = function.getEnclosingClass(); 4827 if (backend.classNeedsRti(targetClass)) {
4826 Link<DartType> typeVariable = cls.typeVariables; 4828 ClassElement cls = redirectingConstructor.getEnclosingClass();
4827 InterfaceType type = elements.getType(node.expression); 4829 InterfaceType targetType =
4828 type.typeArguments.forEach((DartType argument) { 4830 redirectingConstructor.computeTargetType(cls.thisType);
4831 targetType.typeArguments.forEach((DartType argument) {
4829 inputs.add(analyzeTypeArgument(argument)); 4832 inputs.add(analyzeTypeArgument(argument));
4830 typeVariable = typeVariable.tail;
4831 }); 4833 });
4832 assert(typeVariable.isEmpty);
4833 } 4834 }
4834 pushInvokeStatic(node, element, inputs); 4835 pushInvokeStatic(node, targetConstructor, inputs);
4835 value = pop(); 4836 value = pop();
4836 } else if (node.expression == null) { 4837 } else if (node.expression == null) {
4837 value = graph.addConstantNull(compiler); 4838 value = graph.addConstantNull(compiler);
4838 } else { 4839 } else {
4839 visit(node.expression); 4840 visit(node.expression);
4840 value = pop(); 4841 value = pop();
4841 value = potentiallyCheckType(value, returnType); 4842 value = potentiallyCheckType(value, returnType);
4842 } 4843 }
4843 4844
4844 handleInTryStatement(); 4845 handleInTryStatement();
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
6315 DartType unaliased = type.unalias(builder.compiler); 6316 DartType unaliased = type.unalias(builder.compiler);
6316 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6317 if (unaliased is TypedefType) throw 'unable to unalias $type';
6317 unaliased.accept(this, builder); 6318 unaliased.accept(this, builder);
6318 } 6319 }
6319 6320
6320 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6321 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6321 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); 6322 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType');
6322 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6323 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6323 } 6324 }
6324 } 6325 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/regress_18535_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698