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

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

Issue 11365108: Implement redirecting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 1 month 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 Interceptors { 7 class Interceptors {
8 Compiler compiler; 8 Compiler compiler;
9 Interceptors(Compiler this.compiler); 9 Interceptors(Compiler this.compiler);
10 10
(...skipping 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 return HType.UNKNOWN; 3066 return HType.UNKNOWN;
3067 } 3067 }
3068 } 3068 }
3069 3069
3070 Element constructor = elements[node]; 3070 Element constructor = elements[node];
3071 Selector selector = elements.getSelector(node); 3071 Selector selector = elements.getSelector(node);
3072 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { 3072 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) {
3073 compiler.internalError("Unresolved element: $constructor", node: node); 3073 compiler.internalError("Unresolved element: $constructor", node: node);
3074 } 3074 }
3075 FunctionElement functionElement = constructor; 3075 FunctionElement functionElement = constructor;
3076 constructor = functionElement.defaultImplementation; 3076 constructor = functionElement.redirectionTarget;
3077 // TODO(5346): Try to avoid the need for calling [declaration] before 3077 // TODO(5346): Try to avoid the need for calling [declaration] before
3078 // creating an [HStatic]. 3078 // creating an [HStatic].
3079 HInstruction target = new HStatic(constructor.declaration); 3079 HInstruction target = new HStatic(constructor.declaration);
3080 add(target); 3080 add(target);
3081 var inputs = <HInstruction>[]; 3081 var inputs = <HInstruction>[];
3082 inputs.add(target); 3082 inputs.add(target);
3083 // TODO(5347): Try to avoid the need for calling [implementation] before 3083 // TODO(5347): Try to avoid the need for calling [implementation] before
3084 // calling [addStaticSendArgumentsToList]. 3084 // calling [addStaticSendArgumentsToList].
3085 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, 3085 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
3086 constructor.implementation, 3086 constructor.implementation,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 existingArguments.add(parameter.name.slowToString()); 3300 existingArguments.add(parameter.name.slowToString());
3301 }); 3301 });
3302 generateThrowNoSuchMethod(diagnosticNode, 3302 generateThrowNoSuchMethod(diagnosticNode,
3303 function.name.slowToString(), 3303 function.name.slowToString(),
3304 argumentNodes: argumentNodes, 3304 argumentNodes: argumentNodes,
3305 existingArguments: existingArguments); 3305 existingArguments: existingArguments);
3306 } 3306 }
3307 3307
3308 visitNewExpression(NewExpression node) { 3308 visitNewExpression(NewExpression node) {
3309 Element element = elements[node.send]; 3309 Element element = elements[node.send];
3310 if (!Elements.isErroneousElement(element)) {
3311 element = element.redirectionTarget;
3312 }
3310 if (Elements.isErroneousElement(element)) { 3313 if (Elements.isErroneousElement(element)) {
3311 ErroneousElement error = element; 3314 ErroneousElement error = element;
3312 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 3315 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
3313 generateThrowNoSuchMethod(node.send, 3316 generateThrowNoSuchMethod(node.send,
3314 getTargetName(error, 'constructor'), 3317 getTargetName(error, 'constructor'),
3315 argumentNodes: node.send.arguments); 3318 argumentNodes: node.send.arguments);
3316 } else if (error.messageKind == MessageKind.CANNOT_RESOLVE) { 3319 } else if (error.messageKind == MessageKind.CANNOT_RESOLVE) {
3317 Message message = error.messageKind.message(error.messageArguments); 3320 Message message = error.messageKind.message(error.messageArguments);
3318 generateRuntimeError(node.send, message.toString()); 3321 generateRuntimeError(node.send, message.toString());
3319 } else { 3322 } else {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3516 HBasicBlock newBlock = graph.addNewBlock(); 3519 HBasicBlock newBlock = graph.addNewBlock();
3517 block.addSuccessor(newBlock); 3520 block.addSuccessor(newBlock);
3518 open(newBlock); 3521 open(newBlock);
3519 } 3522 }
3520 3523
3521 visitReturn(Return node) { 3524 visitReturn(Return node) {
3522 if (identical(node.getBeginToken().stringValue, 'native')) { 3525 if (identical(node.getBeginToken().stringValue, 'native')) {
3523 native.handleSsaNative(this, node.expression); 3526 native.handleSsaNative(this, node.expression);
3524 return; 3527 return;
3525 } 3528 }
3526 if (node.isRedirectingFactoryBody) { 3529 assert(invariant(node, !node.isRedirectingFactoryBody));
3527 compiler.internalError("Unimplemented: Redirecting factory constructor",
3528 node: node);
3529 }
3530 HInstruction value; 3530 HInstruction value;
3531 if (node.expression == null) { 3531 if (node.expression == null) {
3532 value = graph.addConstantNull(constantSystem); 3532 value = graph.addConstantNull(constantSystem);
3533 } else { 3533 } else {
3534 visit(node.expression); 3534 visit(node.expression);
3535 value = pop(); 3535 value = pop();
3536 if (value is HForeign) { 3536 if (value is HForeign) {
3537 // TODO(6530, 6534): remove this check. 3537 // TODO(6530, 6534): remove this check.
3538 } else { 3538 } else {
3539 value = potentiallyCheckType(value, returnType); 3539 value = potentiallyCheckType(value, returnType);
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
4771 new HSubGraphBlockInformation(elseBranch.graph)); 4771 new HSubGraphBlockInformation(elseBranch.graph));
4772 4772
4773 HBasicBlock conditionStartBlock = conditionBranch.block; 4773 HBasicBlock conditionStartBlock = conditionBranch.block;
4774 conditionStartBlock.setBlockFlow(info, joinBlock); 4774 conditionStartBlock.setBlockFlow(info, joinBlock);
4775 SubGraph conditionGraph = conditionBranch.graph; 4775 SubGraph conditionGraph = conditionBranch.graph;
4776 HIf branch = conditionGraph.end.last; 4776 HIf branch = conditionGraph.end.last;
4777 assert(branch is HIf); 4777 assert(branch is HIf);
4778 branch.blockInformation = conditionStartBlock.blockFlow; 4778 branch.blockInformation = conditionStartBlock.blockFlow;
4779 } 4779 }
4780 } 4780 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | dart/tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698