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 3362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3373 assert(invariant(send, constructor != null, | 3373 assert(invariant(send, constructor != null, |
| 3374 message: 'Constructor Symbol.validated is missing')); | 3374 message: 'Constructor Symbol.validated is missing')); |
| 3375 selector = compiler.symbolValidatedConstructorSelector; | 3375 selector = compiler.symbolValidatedConstructorSelector; |
| 3376 assert(invariant(send, selector != null, | 3376 assert(invariant(send, selector != null, |
| 3377 message: 'Constructor Symbol.validated is missing')); | 3377 message: 'Constructor Symbol.validated is missing')); |
| 3378 } | 3378 } |
| 3379 | 3379 |
| 3380 bool isRedirected = functionElement.isRedirectingFactory; | 3380 bool isRedirected = functionElement.isRedirectingFactory; |
| 3381 DartType expectedType = type; | 3381 DartType expectedType = type; |
| 3382 if (isRedirected) { | 3382 if (isRedirected) { |
| 3383 FunctionExpression functionNode = functionElement.parseNode(compiler); | 3383 type = functionElement.computeTargetType(compiler, type); |
| 3384 if (functionNode.isRedirectingFactory) { | |
| 3385 // Lookup the type used in the redirection. | |
| 3386 Return redirectionNode = functionNode.body; | |
| 3387 TreeElements treeElements = | |
| 3388 compiler.enqueuer.resolution.getCachedElements( | |
| 3389 functionElement.declaration); | |
| 3390 ClassElement targetClass = functionElement.getEnclosingClass(); | |
| 3391 type = treeElements.getType(redirectionNode.expression) | |
| 3392 .subst(type.typeArguments, targetClass.typeVariables); | |
| 3393 } | |
| 3394 functionElement = functionElement.redirectionTarget; | |
| 3395 } | 3384 } |
| 3396 | 3385 |
| 3397 var inputs = <HInstruction>[]; | 3386 var inputs = <HInstruction>[]; |
| 3398 // TODO(5347): Try to avoid the need for calling [implementation] before | 3387 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3399 // calling [addStaticSendArgumentsToList]. | 3388 // calling [addStaticSendArgumentsToList]. |
| 3400 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, | 3389 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, |
| 3401 constructor.implementation, | 3390 constructor.implementation, |
| 3402 inputs); | 3391 inputs); |
| 3403 if (!succeeded) { | 3392 if (!succeeded) { |
| 3404 generateWrongArgumentCountError(send, constructor, send.arguments); | 3393 generateWrongArgumentCountError(send, constructor, send.arguments); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3639 ErroneousElement error = element; | 3628 ErroneousElement error = element; |
| 3640 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 3629 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
| 3641 generateThrowNoSuchMethod(node.send, | 3630 generateThrowNoSuchMethod(node.send, |
| 3642 getTargetName(error, 'constructor'), | 3631 getTargetName(error, 'constructor'), |
| 3643 argumentNodes: node.send.arguments); | 3632 argumentNodes: node.send.arguments); |
| 3644 } else { | 3633 } else { |
| 3645 Message message = error.messageKind.message(error.messageArguments); | 3634 Message message = error.messageKind.message(error.messageArguments); |
| 3646 generateRuntimeError(node.send, message.toString()); | 3635 generateRuntimeError(node.send, message.toString()); |
| 3647 } | 3636 } |
| 3648 } else if (node.isConst()) { | 3637 } else if (node.isConst()) { |
| 3649 // TODO(karlklose): add type representation | |
| 3650 ConstantHandler handler = compiler.constantHandler; | 3638 ConstantHandler handler = compiler.constantHandler; |
| 3651 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3639 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 3652 stack.add(graph.addConstant(constant, compiler)); | 3640 stack.add(graph.addConstant(constant, compiler)); |
| 3641 if (constant is ConstructedConstant) { | |
| 3642 ConstructedConstant constructed = constant; | |
| 3643 compiler.enqueuer.codegen.registerInstantiatedType(constructed.type, | |
|
ngeoffray
2013/06/17 09:15:03
Isn't this already done by the constant_handler?
| |
| 3644 elements); | |
| 3645 } | |
| 3653 if (isSymbolConstructor) { | 3646 if (isSymbolConstructor) { |
| 3654 ConstructedConstant symbol = constant; | 3647 ConstructedConstant symbol = constant; |
| 3655 StringConstant stringConstant = symbol.fields.single; | 3648 StringConstant stringConstant = symbol.fields.single; |
| 3656 String nameString = stringConstant.toDartString().slowToString(); | 3649 String nameString = stringConstant.toDartString().slowToString(); |
| 3657 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); | 3650 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); |
| 3658 } | 3651 } |
| 3659 } else { | 3652 } else { |
| 3660 DartType type = elements.getType(node); | 3653 DartType type = elements.getType(node); |
| 3661 if (compiler.enableTypeAssertions && type.isMalformed) { | 3654 if (compiler.enableTypeAssertions && type.isMalformed) { |
| 3662 String reasons = Types.fetchReasonsFromMalformedType(type); | 3655 String reasons = Types.fetchReasonsFromMalformedType(type); |
| (...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5380 new HSubGraphBlockInformation(elseBranch.graph)); | 5373 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5381 | 5374 |
| 5382 HBasicBlock conditionStartBlock = conditionBranch.block; | 5375 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5383 conditionStartBlock.setBlockFlow(info, joinBlock); | 5376 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5384 SubGraph conditionGraph = conditionBranch.graph; | 5377 SubGraph conditionGraph = conditionBranch.graph; |
| 5385 HIf branch = conditionGraph.end.last; | 5378 HIf branch = conditionGraph.end.last; |
| 5386 assert(branch is HIf); | 5379 assert(branch is HIf); |
| 5387 branch.blockInformation = conditionStartBlock.blockFlow; | 5380 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5388 } | 5381 } |
| 5389 } | 5382 } |
| OLD | NEW |