Chromium Code Reviews| 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 3351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3362 Selector selector = elements.getSelector(send); | 3362 Selector selector = elements.getSelector(send); |
| 3363 if (constructor.isForwardingConstructor) { | 3363 if (constructor.isForwardingConstructor) { |
| 3364 compiler.unimplemented('forwarded constructor in named mixin application', | 3364 compiler.unimplemented('forwarded constructor in named mixin application', |
| 3365 element: constructor.getEnclosingClass()); | 3365 element: constructor.getEnclosingClass()); |
| 3366 } | 3366 } |
| 3367 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { | 3367 if (compiler.enqueuer.resolution.getCachedElements(constructor) == null) { |
| 3368 compiler.internalError("Unresolved element: $constructor", node: send); | 3368 compiler.internalError("Unresolved element: $constructor", node: send); |
| 3369 } | 3369 } |
| 3370 FunctionElement functionElement = constructor; | 3370 FunctionElement functionElement = constructor; |
| 3371 constructor = functionElement.redirectionTarget; | 3371 constructor = functionElement.redirectionTarget; |
| 3372 | |
| 3372 final bool isSymbolConstructor = | 3373 final bool isSymbolConstructor = |
| 3373 functionElement == compiler.symbolConstructor; | 3374 functionElement == compiler.symbolConstructor; |
| 3374 | 3375 |
| 3375 if (isSymbolConstructor) { | 3376 if (isSymbolConstructor) { |
| 3376 constructor = compiler.symbolValidatedConstructor; | 3377 constructor = compiler.symbolValidatedConstructor; |
| 3377 assert(invariant(send, constructor != null, | 3378 assert(invariant(send, constructor != null, |
| 3378 message: 'Constructor Symbol.validated is missing')); | 3379 message: 'Constructor Symbol.validated is missing')); |
| 3379 selector = compiler.symbolValidatedConstructorSelector; | 3380 selector = compiler.symbolValidatedConstructorSelector; |
| 3380 assert(invariant(send, selector != null, | 3381 assert(invariant(send, selector != null, |
| 3381 message: 'Constructor Symbol.validated is missing')); | 3382 message: 'Constructor Symbol.validated is missing')); |
| 3382 } | 3383 } |
| 3383 | 3384 |
| 3385 bool isRedirected = functionElement.redirectionTarget != functionElement; | |
|
ngeoffray
2013/05/30 08:23:14
Add this logic to the FunctionElement class or Ele
karlklose
2013/05/30 11:44:23
Done.
| |
| 3386 DartType expectedType = type; | |
| 3387 if (isRedirected) { | |
| 3388 FunctionExpression functionNode = functionElement.parseNode(compiler); | |
| 3389 if (functionNode.isRedirectingFactory) { | |
| 3390 // Lookup the type used in the redirection. | |
| 3391 Return redirectionNode = functionNode.body; | |
| 3392 TreeElements treeElements = | |
| 3393 compiler.enqueuer.resolution.getCachedElements( | |
| 3394 functionElement.declaration); | |
| 3395 ClassElement targetClass = functionElement.getEnclosingClass(); | |
| 3396 type = treeElements.getType(redirectionNode) | |
| 3397 .subst(type.typeArguments, targetClass.typeVariables); | |
| 3398 } | |
| 3399 functionElement = functionElement.redirectionTarget; | |
| 3400 } | |
| 3401 | |
| 3402 // TODO(karlklose): move this type registration to the codegen. | |
| 3403 compiler.codegenWorld.instantiatedTypes.add(type); | |
|
ngeoffray
2013/05/30 08:23:14
Why is that needed here now, even in the case it's
karlklose
2013/05/30 11:44:23
This was a leftover from the old state of the buil
| |
| 3404 | |
| 3384 var inputs = <HInstruction>[]; | 3405 var inputs = <HInstruction>[]; |
| 3385 // TODO(5347): Try to avoid the need for calling [implementation] before | 3406 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3386 // calling [addStaticSendArgumentsToList]. | 3407 // calling [addStaticSendArgumentsToList]. |
| 3387 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, | 3408 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, |
| 3388 constructor.implementation, | 3409 constructor.implementation, |
| 3389 inputs); | 3410 inputs); |
| 3390 if (!succeeded) { | 3411 if (!succeeded) { |
| 3391 generateWrongArgumentCountError(send, constructor, send.arguments); | 3412 generateWrongArgumentCountError(send, constructor, send.arguments); |
| 3392 return; | 3413 return; |
| 3393 } | 3414 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 3418 pushInvokeStatic(node, constructor, inputs, elementType); | 3439 pushInvokeStatic(node, constructor, inputs, elementType); |
| 3419 HInstruction newInstance = stack.last; | 3440 HInstruction newInstance = stack.last; |
| 3420 | 3441 |
| 3421 // The List constructor forwards to a Dart static method that does | 3442 // The List constructor forwards to a Dart static method that does |
| 3422 // not know about the type argument. Therefore we special case | 3443 // not know about the type argument. Therefore we special case |
| 3423 // this constructor to have the setRuntimeTypeInfo called where | 3444 // this constructor to have the setRuntimeTypeInfo called where |
| 3424 // the 'new' is done. | 3445 // the 'new' is done. |
| 3425 if (isListConstructor && backend.needsRti(compiler.listClass)) { | 3446 if (isListConstructor && backend.needsRti(compiler.listClass)) { |
| 3426 handleListConstructor(type, send, newInstance); | 3447 handleListConstructor(type, send, newInstance); |
| 3427 } | 3448 } |
| 3449 | |
| 3450 // Finally, if we called a redirecting factory constructor, check the type. | |
| 3451 if (isRedirected) { | |
| 3452 HInstruction checked = potentiallyCheckType(newInstance, expectedType); | |
| 3453 if (checked != newInstance) { | |
| 3454 pop(); | |
| 3455 stack.add(checked); | |
| 3456 } | |
| 3457 } | |
| 3428 } | 3458 } |
| 3429 | 3459 |
| 3430 visitStaticSend(Send node) { | 3460 visitStaticSend(Send node) { |
| 3431 Selector selector = elements.getSelector(node); | 3461 Selector selector = elements.getSelector(node); |
| 3432 Element element = elements[node]; | 3462 Element element = elements[node]; |
| 3433 if (element.isForeign(compiler)) { | 3463 if (element.isForeign(compiler)) { |
| 3434 visitForeignSend(node); | 3464 visitForeignSend(node); |
| 3435 return; | 3465 return; |
| 3436 } | 3466 } |
| 3437 if (element.isErroneous()) { | 3467 if (element.isErroneous()) { |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5365 new HSubGraphBlockInformation(elseBranch.graph)); | 5395 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5366 | 5396 |
| 5367 HBasicBlock conditionStartBlock = conditionBranch.block; | 5397 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5368 conditionStartBlock.setBlockFlow(info, joinBlock); | 5398 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5369 SubGraph conditionGraph = conditionBranch.graph; | 5399 SubGraph conditionGraph = conditionBranch.graph; |
| 5370 HIf branch = conditionGraph.end.last; | 5400 HIf branch = conditionGraph.end.last; |
| 5371 assert(branch is HIf); | 5401 assert(branch is HIf); |
| 5372 branch.blockInformation = conditionStartBlock.blockFlow; | 5402 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5373 } | 5403 } |
| 5374 } | 5404 } |
| OLD | NEW |