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 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 visitLogicalAndOr(node, op); | 2903 visitLogicalAndOr(node, op); |
2904 } else if ("!" == op.source) { | 2904 } else if ("!" == op.source) { |
2905 visitLogicalNot(node); | 2905 visitLogicalNot(node); |
2906 } else if (node.argumentsNode is Prefix) { | 2906 } else if (node.argumentsNode is Prefix) { |
2907 visitUnary(node, op); | 2907 visitUnary(node, op); |
2908 } else if ("is" == op.source) { | 2908 } else if ("is" == op.source) { |
2909 visitIsSend(node); | 2909 visitIsSend(node); |
2910 } else if ("as" == op.source) { | 2910 } else if ("as" == op.source) { |
2911 visit(node.receiver); | 2911 visit(node.receiver); |
2912 HInstruction expression = pop(); | 2912 HInstruction expression = pop(); |
2913 Node argument = node.arguments.head; | 2913 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); |
2914 TypeAnnotation typeAnnotation = argument.asTypeAnnotation(); | 2914 if (type.kind == TypeKind.MALFORMED_TYPE) { |
2915 DartType type = elements.getType(typeAnnotation); | 2915 ErroneousElement element = type.element; |
2916 HInstruction converted = buildTypeConversion( | 2916 generateTypeError(node, element.message); |
2917 expression, type, HTypeConversion.CAST_TYPE_CHECK); | 2917 } else { |
2918 if (converted != expression) add(converted); | 2918 HInstruction converted = buildTypeConversion( |
2919 stack.add(converted); | 2919 expression, type, HTypeConversion.CAST_TYPE_CHECK); |
| 2920 if (converted != expression) add(converted); |
| 2921 stack.add(converted); |
| 2922 } |
2920 } else { | 2923 } else { |
2921 visit(node.receiver); | 2924 visit(node.receiver); |
2922 visit(node.argumentsNode); | 2925 visit(node.argumentsNode); |
2923 var right = pop(); | 2926 var right = pop(); |
2924 var left = pop(); | 2927 var left = pop(); |
2925 visitBinary(left, op, right, elements.getSelector(node), node); | 2928 visitBinary(left, op, right, elements.getSelector(node), node); |
2926 } | 2929 } |
2927 } | 2930 } |
2928 | 2931 |
2929 void visitIsSend(Send node) { | 2932 void visitIsSend(Send node) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 HInstruction asFieldName = compiler.world.hasAnySubtype(element) | 3017 HInstruction asFieldName = compiler.world.hasAnySubtype(element) |
3015 ? addConstantString(node, backend.namer.substitutionName(element)) | 3018 ? addConstantString(node, backend.namer.substitutionName(element)) |
3016 : graph.addConstantNull(compiler); | 3019 : graph.addConstantNull(compiler); |
3017 List<HInstruction> inputs = <HInstruction>[expression, | 3020 List<HInstruction> inputs = <HInstruction>[expression, |
3018 isFieldName, | 3021 isFieldName, |
3019 representations, | 3022 representations, |
3020 asFieldName]; | 3023 asFieldName]; |
3021 pushInvokeStatic(node, helper, inputs, backend.boolType); | 3024 pushInvokeStatic(node, helper, inputs, backend.boolType); |
3022 HInstruction call = pop(); | 3025 HInstruction call = pop(); |
3023 return new HIs.compound(type, expression, call, backend.boolType); | 3026 return new HIs.compound(type, expression, call, backend.boolType); |
| 3027 } else if (type.kind == TypeKind.MALFORMED_TYPE) { |
| 3028 ErroneousElement element = type.element; |
| 3029 generateTypeError(node, element.message); |
| 3030 HInstruction call = pop(); |
| 3031 return new HIs.compound(type, expression, call, backend.boolType); |
3024 } else { | 3032 } else { |
3025 if (backend.hasDirectCheckFor(type)) { | 3033 if (backend.hasDirectCheckFor(type)) { |
3026 return new HIs.direct(type, expression, backend.boolType); | 3034 return new HIs.direct(type, expression, backend.boolType); |
3027 } | 3035 } |
3028 // TODO(johnniwinther): Avoid interceptor if unneeded. | 3036 // TODO(johnniwinther): Avoid interceptor if unneeded. |
3029 return new HIs.raw( | 3037 return new HIs.raw( |
3030 type, expression, invokeInterceptor(expression), backend.boolType); | 3038 type, expression, invokeInterceptor(expression), backend.boolType); |
3031 } | 3039 } |
3032 } | 3040 } |
3033 | 3041 |
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5745 new HSubGraphBlockInformation(elseBranch.graph)); | 5753 new HSubGraphBlockInformation(elseBranch.graph)); |
5746 | 5754 |
5747 HBasicBlock conditionStartBlock = conditionBranch.block; | 5755 HBasicBlock conditionStartBlock = conditionBranch.block; |
5748 conditionStartBlock.setBlockFlow(info, joinBlock); | 5756 conditionStartBlock.setBlockFlow(info, joinBlock); |
5749 SubGraph conditionGraph = conditionBranch.graph; | 5757 SubGraph conditionGraph = conditionBranch.graph; |
5750 HIf branch = conditionGraph.end.last; | 5758 HIf branch = conditionGraph.end.last; |
5751 assert(branch is HIf); | 5759 assert(branch is HIf); |
5752 branch.blockInformation = conditionStartBlock.blockFlow; | 5760 branch.blockInformation = conditionStartBlock.blockFlow; |
5753 } | 5761 } |
5754 } | 5762 } |
OLD | NEW |