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 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3643 void generateMalformedSubtypeError(Node node, HInstruction value, | 3643 void generateMalformedSubtypeError(Node node, HInstruction value, |
3644 DartType type, String reasons) { | 3644 DartType type, String reasons) { |
3645 HInstruction typeString = addConstantString(node, type.toString()); | 3645 HInstruction typeString = addConstantString(node, type.toString()); |
3646 HInstruction reasonsString = addConstantString(node, reasons); | 3646 HInstruction reasonsString = addConstantString(node, reasons); |
3647 Element helper = backend.getThrowMalformedSubtypeError(); | 3647 Element helper = backend.getThrowMalformedSubtypeError(); |
3648 pushInvokeHelper3(helper, value, typeString, reasonsString, HType.UNKNOWN); | 3648 pushInvokeHelper3(helper, value, typeString, reasonsString, HType.UNKNOWN); |
3649 } | 3649 } |
3650 | 3650 |
3651 visitNewExpression(NewExpression node) { | 3651 visitNewExpression(NewExpression node) { |
3652 Element element = elements[node.send]; | 3652 Element element = elements[node.send]; |
3653 final bool isSymbolConstructor = element == compiler.symbolConstructor; | |
ngeoffray
2013/05/08 12:34:06
Remove final.
ahe
2013/05/08 21:47:53
Why?
ngeoffray
2013/05/13 10:31:40
Consistency? We never use "final" for local variab
| |
3653 if (!Elements.isErroneousElement(element)) { | 3654 if (!Elements.isErroneousElement(element)) { |
3654 FunctionElement function = element; | 3655 FunctionElement function = element; |
3655 element = function.redirectionTarget; | 3656 element = function.redirectionTarget; |
3656 } | 3657 } |
3657 if (Elements.isErroneousElement(element)) { | 3658 if (Elements.isErroneousElement(element)) { |
3658 ErroneousElement error = element; | 3659 ErroneousElement error = element; |
3659 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 3660 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { |
3660 generateThrowNoSuchMethod(node.send, | 3661 generateThrowNoSuchMethod(node.send, |
3661 getTargetName(error, 'constructor'), | 3662 getTargetName(error, 'constructor'), |
3662 argumentNodes: node.send.arguments); | 3663 argumentNodes: node.send.arguments); |
3663 } else { | 3664 } else { |
3664 Message message = error.messageKind.message(error.messageArguments); | 3665 Message message = error.messageKind.message(error.messageArguments); |
3665 generateRuntimeError(node.send, message.toString()); | 3666 generateRuntimeError(node.send, message.toString()); |
3666 } | 3667 } |
3667 } else if (node.isConst()) { | 3668 } else if (node.isConst()) { |
3668 // TODO(karlklose): add type representation | 3669 // TODO(karlklose): add type representation |
3669 ConstantHandler handler = compiler.constantHandler; | 3670 ConstantHandler handler = compiler.constantHandler; |
3670 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3671 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
3671 stack.add(graph.addConstant(constant)); | 3672 stack.add(graph.addConstant(constant)); |
3673 if (isSymbolConstructor) { | |
3674 ConstructedConstant symbol = constant; | |
3675 StringConstant stringConstant = symbol.fields.single; | |
3676 String nameString = stringConstant.toDartString().slowToString(); | |
3677 compiler.enqueuer.codegen.registerConstSymbol(nameString, elements); | |
3678 } | |
3672 } else { | 3679 } else { |
3673 DartType type = elements.getType(node); | 3680 DartType type = elements.getType(node); |
3674 if (compiler.enableTypeAssertions && type.isMalformed) { | 3681 if (compiler.enableTypeAssertions && type.isMalformed) { |
3675 String reasons = Types.fetchReasonsFromMalformedType(type); | 3682 String reasons = Types.fetchReasonsFromMalformedType(type); |
3676 // TODO(johnniwinther): Change to resemble type errors from bounds check | 3683 // TODO(johnniwinther): Change to resemble type errors from bounds check |
3677 // on type arguments. | 3684 // on type arguments. |
3678 generateRuntimeError(node, '$type is malformed: $reasons'); | 3685 generateRuntimeError(node, '$type is malformed: $reasons'); |
3679 } else { | 3686 } else { |
3680 // TODO(karlklose): move this type registration to the codegen. | 3687 // TODO(karlklose): move this type registration to the codegen. |
3681 compiler.codegenWorld.instantiatedTypes.add(type); | 3688 compiler.codegenWorld.instantiatedTypes.add(type); |
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5278 new HSubGraphBlockInformation(elseBranch.graph)); | 5285 new HSubGraphBlockInformation(elseBranch.graph)); |
5279 | 5286 |
5280 HBasicBlock conditionStartBlock = conditionBranch.block; | 5287 HBasicBlock conditionStartBlock = conditionBranch.block; |
5281 conditionStartBlock.setBlockFlow(info, joinBlock); | 5288 conditionStartBlock.setBlockFlow(info, joinBlock); |
5282 SubGraph conditionGraph = conditionBranch.graph; | 5289 SubGraph conditionGraph = conditionBranch.graph; |
5283 HIf branch = conditionGraph.end.last; | 5290 HIf branch = conditionGraph.end.last; |
5284 assert(branch is HIf); | 5291 assert(branch is HIf); |
5285 branch.blockInformation = conditionStartBlock.blockFlow; | 5292 branch.blockInformation = conditionStartBlock.blockFlow; |
5286 } | 5293 } |
5287 } | 5294 } |
OLD | NEW |