| OLD | NEW |
| 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 3360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3371 Selector selector = elements.getSelector(send); | 3371 Selector selector = elements.getSelector(send); |
| 3372 if (constructor.isForwardingConstructor) { | 3372 if (constructor.isForwardingConstructor) { |
| 3373 compiler.unimplemented('forwarded constructor in named mixin application', | 3373 compiler.unimplemented('forwarded constructor in named mixin application', |
| 3374 element: constructor.getEnclosingClass()); | 3374 element: constructor.getEnclosingClass()); |
| 3375 } | 3375 } |
| 3376 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { | 3376 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { |
| 3377 compiler.internalError("Unresolved element: $constructor", node: send); | 3377 compiler.internalError("Unresolved element: $constructor", node: send); |
| 3378 } | 3378 } |
| 3379 FunctionElement functionElement = constructor; | 3379 FunctionElement functionElement = constructor; |
| 3380 constructor = functionElement.redirectionTarget; | 3380 constructor = functionElement.redirectionTarget; |
| 3381 |
| 3381 final bool isSymbolConstructor = | 3382 final bool isSymbolConstructor = |
| 3382 functionElement == compiler.symbolConstructor; | 3383 functionElement == compiler.symbolConstructor; |
| 3383 | 3384 |
| 3384 if (isSymbolConstructor) { | 3385 if (isSymbolConstructor) { |
| 3385 constructor = compiler.symbolValidatedConstructor; | 3386 constructor = compiler.symbolValidatedConstructor; |
| 3386 assert(invariant(send, constructor != null, | 3387 assert(invariant(send, constructor != null, |
| 3387 message: 'Constructor Symbol.validated is missing')); | 3388 message: 'Constructor Symbol.validated is missing')); |
| 3388 selector = compiler.symbolValidatedConstructorSelector; | 3389 selector = compiler.symbolValidatedConstructorSelector; |
| 3389 assert(invariant(send, selector != null, | 3390 assert(invariant(send, selector != null, |
| 3390 message: 'Constructor Symbol.validated is missing')); | 3391 message: 'Constructor Symbol.validated is missing')); |
| 3391 } | 3392 } |
| 3392 | 3393 |
| 3394 bool isRedirected = functionElement.isRedirectingFactory; |
| 3395 DartType expectedType = type; |
| 3396 if (isRedirected) { |
| 3397 FunctionExpression functionNode = functionElement.parseNode(compiler); |
| 3398 if (functionNode.isRedirectingFactory) { |
| 3399 // Lookup the type used in the redirection. |
| 3400 Return redirectionNode = functionNode.body; |
| 3401 TreeElements treeElements = |
| 3402 compiler.enqueuer.resolution.getCachedElements( |
| 3403 functionElement.declaration); |
| 3404 ClassElement targetClass = functionElement.getEnclosingClass(); |
| 3405 type = treeElements.getType(redirectionNode) |
| 3406 .subst(type.typeArguments, targetClass.typeVariables); |
| 3407 } |
| 3408 functionElement = functionElement.redirectionTarget; |
| 3409 } |
| 3410 |
| 3393 var inputs = <HInstruction>[]; | 3411 var inputs = <HInstruction>[]; |
| 3394 // TODO(5347): Try to avoid the need for calling [implementation] before | 3412 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3395 // calling [addStaticSendArgumentsToList]. | 3413 // calling [addStaticSendArgumentsToList]. |
| 3396 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, | 3414 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, |
| 3397 constructor.implementation, | 3415 constructor.implementation, |
| 3398 inputs); | 3416 inputs); |
| 3399 if (!succeeded) { | 3417 if (!succeeded) { |
| 3400 generateWrongArgumentCountError(send, constructor, send.arguments); | 3418 generateWrongArgumentCountError(send, constructor, send.arguments); |
| 3401 return; | 3419 return; |
| 3402 } | 3420 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3427 pushInvokeStatic(node, constructor, inputs, elementType); | 3445 pushInvokeStatic(node, constructor, inputs, elementType); |
| 3428 HInstruction newInstance = stack.last; | 3446 HInstruction newInstance = stack.last; |
| 3429 | 3447 |
| 3430 // The List constructor forwards to a Dart static method that does | 3448 // The List constructor forwards to a Dart static method that does |
| 3431 // not know about the type argument. Therefore we special case | 3449 // not know about the type argument. Therefore we special case |
| 3432 // this constructor to have the setRuntimeTypeInfo called where | 3450 // this constructor to have the setRuntimeTypeInfo called where |
| 3433 // the 'new' is done. | 3451 // the 'new' is done. |
| 3434 if (isListConstructor && backend.needsRti(compiler.listClass)) { | 3452 if (isListConstructor && backend.needsRti(compiler.listClass)) { |
| 3435 handleListConstructor(type, send, newInstance); | 3453 handleListConstructor(type, send, newInstance); |
| 3436 } | 3454 } |
| 3455 |
| 3456 // Finally, if we called a redirecting factory constructor, check the type. |
| 3457 if (isRedirected) { |
| 3458 HInstruction checked = potentiallyCheckType(newInstance, expectedType); |
| 3459 if (checked != newInstance) { |
| 3460 pop(); |
| 3461 stack.add(checked); |
| 3462 } |
| 3463 } |
| 3437 } | 3464 } |
| 3438 | 3465 |
| 3439 visitStaticSend(Send node) { | 3466 visitStaticSend(Send node) { |
| 3440 Selector selector = elements.getSelector(node); | 3467 Selector selector = elements.getSelector(node); |
| 3441 Element element = elements[node]; | 3468 Element element = elements[node]; |
| 3442 if (element.isForeign(compiler)) { | 3469 if (element.isForeign(compiler)) { |
| 3443 visitForeignSend(node); | 3470 visitForeignSend(node); |
| 3444 return; | 3471 return; |
| 3445 } | 3472 } |
| 3446 if (element.isErroneous()) { | 3473 if (element.isErroneous()) { |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5374 new HSubGraphBlockInformation(elseBranch.graph)); | 5401 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5375 | 5402 |
| 5376 HBasicBlock conditionStartBlock = conditionBranch.block; | 5403 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5377 conditionStartBlock.setBlockFlow(info, joinBlock); | 5404 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5378 SubGraph conditionGraph = conditionBranch.graph; | 5405 SubGraph conditionGraph = conditionBranch.graph; |
| 5379 HIf branch = conditionGraph.end.last; | 5406 HIf branch = conditionGraph.end.last; |
| 5380 assert(branch is HIf); | 5407 assert(branch is HIf); |
| 5381 branch.blockInformation = conditionStartBlock.blockFlow; | 5408 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5382 } | 5409 } |
| 5383 } | 5410 } |
| OLD | NEW |