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

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

Issue 23450040: Implement redirecting factories in mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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/lib/lib.status » ('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 override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 3553 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 if (cls.isAbstract(compiler) && constructor.isGenerativeConstructor()) { 3564 if (cls.isAbstract(compiler) && constructor.isGenerativeConstructor()) {
3565 generateAbstractClassInstantiationError(send, cls.name.slowToString()); 3565 generateAbstractClassInstantiationError(send, cls.name.slowToString());
3566 return; 3566 return;
3567 } 3567 }
3568 if (backend.classNeedsRti(cls)) { 3568 if (backend.classNeedsRti(cls)) {
3569 Link<DartType> typeVariable = cls.typeVariables; 3569 Link<DartType> typeVariable = cls.typeVariables;
3570 type.typeArguments.forEach((DartType argument) { 3570 type.typeArguments.forEach((DartType argument) {
3571 inputs.add(analyzeTypeArgument(argument)); 3571 inputs.add(analyzeTypeArgument(argument));
3572 typeVariable = typeVariable.tail; 3572 typeVariable = typeVariable.tail;
3573 }); 3573 });
3574 // Also add null to non-provided type variables to call the 3574 assert(typeVariable.isEmpty);
3575 // constructor with the right number of arguments.
3576 while (!typeVariable.isEmpty) {
3577 inputs.add(graph.addConstantNull(compiler));
3578 typeVariable = typeVariable.tail;
3579 }
3580 } 3575 }
3581 3576
3582 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) { 3577 if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) {
3583 compiler.enqueuer.codegen.registerFactoryWithTypeArguments(elements); 3578 compiler.enqueuer.codegen.registerFactoryWithTypeArguments(elements);
3584 } 3579 }
3585 HType elementType = computeType(constructor); 3580 HType elementType = computeType(constructor);
3586 addInlinedInstantiation(expectedType); 3581 addInlinedInstantiation(expectedType);
3587 pushInvokeStatic(node, constructor, inputs, elementType); 3582 pushInvokeStatic(node, constructor, inputs, elementType);
3588 removeInlinedInstantiation(expectedType); 3583 removeInlinedInstantiation(expectedType);
3589 HInstruction newInstance = stack.last; 3584 HInstruction newInstance = stack.last;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
4180 closeAndGotoExit(new HThrow(exception, isRethrow: true)); 4175 closeAndGotoExit(new HThrow(exception, isRethrow: true));
4181 } 4176 }
4182 4177
4183 visitReturn(Return node) { 4178 visitReturn(Return node) {
4184 if (identical(node.getBeginToken().stringValue, 'native')) { 4179 if (identical(node.getBeginToken().stringValue, 'native')) {
4185 native.handleSsaNative(this, node.expression); 4180 native.handleSsaNative(this, node.expression);
4186 return; 4181 return;
4187 } 4182 }
4188 HInstruction value; 4183 HInstruction value;
4189 if (node.isRedirectingFactoryBody) { 4184 if (node.isRedirectingFactoryBody) {
4190 // TODO(ahe): This is only for reflection, and it is not correct yet. 4185 FunctionElement element = elements[node.expression];
4191 value = graph.addConstantNull(compiler); 4186 FunctionElement function = currentElement;
4187 List<HInstruction> inputs = <HInstruction>[];
4188 FunctionSignature calleeSignature = element.functionSignature;
4189 FunctionSignature callerSignature = function.functionSignature;
4190 callerSignature.forEachRequiredParameter((Element element) {
4191 inputs.add(localsHandler.readLocal(element));
4192 });
4193 List<Element> calleeOptionals =
4194 calleeSignature.orderedOptionalParameters;
4195 List<Element> callerOptionals =
4196 callerSignature.orderedOptionalParameters;
4197 int i = 0;
4198 for (; i < callerOptionals.length; i++) {
4199 inputs.add(localsHandler.readLocal(callerOptionals[i]));
4200 }
4201 for (; i < calleeOptionals.length; i++) {
4202 inputs.add(handleConstantForOptionalParameter(calleeOptionals[i]));
4203 }
4204
4205 if (backend.classNeedsRti(element.getEnclosingClass())) {
4206 ClassElement cls = function.getEnclosingClass();
4207 Link<DartType> typeVariable = cls.typeVariables;
4208 DartType type = elements.getType(node.expression);
4209 type.typeArguments.forEach((DartType argument) {
4210 inputs.add(analyzeTypeArgument(argument));
4211 typeVariable = typeVariable.tail;
4212 });
4213 assert(typeVariable.isEmpty);
4214 }
4215 pushInvokeStatic(node, element, inputs);
4216 value = pop();
4192 } else if (node.expression == null) { 4217 } else if (node.expression == null) {
4193 value = graph.addConstantNull(compiler); 4218 value = graph.addConstantNull(compiler);
4194 } else { 4219 } else {
4195 visit(node.expression); 4220 visit(node.expression);
4196 value = pop(); 4221 value = pop();
4197 value = potentiallyCheckType(value, returnType); 4222 value = potentiallyCheckType(value, returnType);
4198 } 4223 }
4199 4224
4200 handleInTryStatement(); 4225 handleInTryStatement();
4201 4226
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
5513 new HSubGraphBlockInformation(elseBranch.graph)); 5538 new HSubGraphBlockInformation(elseBranch.graph));
5514 5539
5515 HBasicBlock conditionStartBlock = conditionBranch.block; 5540 HBasicBlock conditionStartBlock = conditionBranch.block;
5516 conditionStartBlock.setBlockFlow(info, joinBlock); 5541 conditionStartBlock.setBlockFlow(info, joinBlock);
5517 SubGraph conditionGraph = conditionBranch.graph; 5542 SubGraph conditionGraph = conditionBranch.graph;
5518 HIf branch = conditionGraph.end.last; 5543 HIf branch = conditionGraph.end.last;
5519 assert(branch is HIf); 5544 assert(branch is HIf);
5520 branch.blockInformation = conditionStartBlock.blockFlow; 5545 branch.blockInformation = conditionStartBlock.blockFlow;
5521 } 5546 }
5522 } 5547 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698