| 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 3392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3403 assert(invariant(send, constructor != null, | 3403 assert(invariant(send, constructor != null, |
| 3404 message: 'Constructor Symbol.validated is missing')); | 3404 message: 'Constructor Symbol.validated is missing')); |
| 3405 selector = compiler.symbolValidatedConstructorSelector; | 3405 selector = compiler.symbolValidatedConstructorSelector; |
| 3406 assert(invariant(send, selector != null, | 3406 assert(invariant(send, selector != null, |
| 3407 message: 'Constructor Symbol.validated is missing')); | 3407 message: 'Constructor Symbol.validated is missing')); |
| 3408 } | 3408 } |
| 3409 | 3409 |
| 3410 bool isRedirected = functionElement.isRedirectingFactory; | 3410 bool isRedirected = functionElement.isRedirectingFactory; |
| 3411 DartType expectedType = type; | 3411 DartType expectedType = type; |
| 3412 if (isRedirected) { | 3412 if (isRedirected) { |
| 3413 FunctionExpression functionNode = functionElement.parseNode(compiler); | 3413 type = functionElement.computeTargetType(compiler, type); |
| 3414 if (functionNode.isRedirectingFactory) { | |
| 3415 // Lookup the type used in the redirection. | |
| 3416 Return redirectionNode = functionNode.body; | |
| 3417 TreeElements treeElements = | |
| 3418 compiler.enqueuer.resolution.getCachedElements( | |
| 3419 functionElement.declaration); | |
| 3420 ClassElement targetClass = functionElement.getEnclosingClass(); | |
| 3421 type = treeElements.getType(redirectionNode.expression) | |
| 3422 .subst(type.typeArguments, targetClass.typeVariables); | |
| 3423 } | |
| 3424 functionElement = functionElement.redirectionTarget; | |
| 3425 } | 3414 } |
| 3426 | 3415 |
| 3427 var inputs = <HInstruction>[]; | 3416 var inputs = <HInstruction>[]; |
| 3428 // TODO(5347): Try to avoid the need for calling [implementation] before | 3417 // TODO(5347): Try to avoid the need for calling [implementation] before |
| 3429 // calling [addStaticSendArgumentsToList]. | 3418 // calling [addStaticSendArgumentsToList]. |
| 3430 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, | 3419 bool succeeded = addStaticSendArgumentsToList(selector, send.arguments, |
| 3431 constructor.implementation, | 3420 constructor.implementation, |
| 3432 inputs); | 3421 inputs); |
| 3433 if (!succeeded) { | 3422 if (!succeeded) { |
| 3434 generateWrongArgumentCountError(send, constructor, send.arguments); | 3423 generateWrongArgumentCountError(send, constructor, send.arguments); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3669 ErroneousElement error = element; | 3658 ErroneousElement error = element; |
| 3670 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 3659 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
| 3671 generateThrowNoSuchMethod(node.send, | 3660 generateThrowNoSuchMethod(node.send, |
| 3672 getTargetName(error, 'constructor'), | 3661 getTargetName(error, 'constructor'), |
| 3673 argumentNodes: node.send.arguments); | 3662 argumentNodes: node.send.arguments); |
| 3674 } else { | 3663 } else { |
| 3675 Message message = error.messageKind.message(error.messageArguments); | 3664 Message message = error.messageKind.message(error.messageArguments); |
| 3676 generateRuntimeError(node.send, message.toString()); | 3665 generateRuntimeError(node.send, message.toString()); |
| 3677 } | 3666 } |
| 3678 } else if (node.isConst()) { | 3667 } else if (node.isConst()) { |
| 3679 // TODO(karlklose): add type representation | |
| 3680 ConstantHandler handler = compiler.constantHandler; | 3668 ConstantHandler handler = compiler.constantHandler; |
| 3681 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3669 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 3682 stack.add(graph.addConstant(constant, compiler)); | 3670 stack.add(graph.addConstant(constant, compiler)); |
| 3683 if (isSymbolConstructor) { | 3671 if (isSymbolConstructor) { |
| 3684 ConstructedConstant symbol = constant; | 3672 ConstructedConstant symbol = constant; |
| 3685 StringConstant stringConstant = symbol.fields.single; | 3673 StringConstant stringConstant = symbol.fields.single; |
| 3686 String nameString = stringConstant.toDartString().slowToString(); | 3674 String nameString = stringConstant.toDartString().slowToString(); |
| 3687 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); | 3675 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); |
| 3688 } | 3676 } |
| 3689 } else { | 3677 } else { |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5413 new HSubGraphBlockInformation(elseBranch.graph)); | 5401 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5414 | 5402 |
| 5415 HBasicBlock conditionStartBlock = conditionBranch.block; | 5403 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5416 conditionStartBlock.setBlockFlow(info, joinBlock); | 5404 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5417 SubGraph conditionGraph = conditionBranch.graph; | 5405 SubGraph conditionGraph = conditionBranch.graph; |
| 5418 HIf branch = conditionGraph.end.last; | 5406 HIf branch = conditionGraph.end.last; |
| 5419 assert(branch is HIf); | 5407 assert(branch is HIf); |
| 5420 branch.blockInformation = conditionStartBlock.blockFlow; | 5408 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5421 } | 5409 } |
| 5422 } | 5410 } |
| OLD | NEW |