| 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 3010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3021 } | 3021 } |
| 3022 pushInvokeStatic(null, element, [], HType.UNKNOWN); | 3022 pushInvokeStatic(null, element, [], HType.UNKNOWN); |
| 3023 } | 3023 } |
| 3024 } | 3024 } |
| 3025 | 3025 |
| 3026 void handleForeignJsGetName(Send node) { | 3026 void handleForeignJsGetName(Send node) { |
| 3027 List<Node> arguments = node.arguments.toList(); | 3027 List<Node> arguments = node.arguments.toList(); |
| 3028 Node argument; | 3028 Node argument; |
| 3029 switch (arguments.length) { | 3029 switch (arguments.length) { |
| 3030 case 0: | 3030 case 0: |
| 3031 compiler.reportErrorCode( | 3031 compiler.reportError( |
| 3032 node, MessageKind.GENERIC, | 3032 node, MessageKind.GENERIC, |
| 3033 {'text': 'Error: Expected one argument to JS_GET_NAME.'}); | 3033 {'text': 'Error: Expected one argument to JS_GET_NAME.'}); |
| 3034 return; | 3034 return; |
| 3035 case 1: | 3035 case 1: |
| 3036 argument = arguments[0]; | 3036 argument = arguments[0]; |
| 3037 break; | 3037 break; |
| 3038 default: | 3038 default: |
| 3039 for (int i = 1; i < arguments.length; i++) { | 3039 for (int i = 1; i < arguments.length; i++) { |
| 3040 compiler.reportErrorCode( | 3040 compiler.reportError( |
| 3041 arguments[i], MessageKind.GENERIC, | 3041 arguments[i], MessageKind.GENERIC, |
| 3042 {'text': 'Error: Extra argument to JS_GET_NAME.'}); | 3042 {'text': 'Error: Extra argument to JS_GET_NAME.'}); |
| 3043 } | 3043 } |
| 3044 return; | 3044 return; |
| 3045 } | 3045 } |
| 3046 LiteralString string = argument.asLiteralString(); | 3046 LiteralString string = argument.asLiteralString(); |
| 3047 if (string == null) { | 3047 if (string == null) { |
| 3048 compiler.reportErrorCode( | 3048 compiler.reportError( |
| 3049 argument, MessageKind.GENERIC, | 3049 argument, MessageKind.GENERIC, |
| 3050 {'text': 'Error: Expected a literal string.'}); | 3050 {'text': 'Error: Expected a literal string.'}); |
| 3051 } | 3051 } |
| 3052 stack.add( | 3052 stack.add( |
| 3053 addConstantString( | 3053 addConstantString( |
| 3054 argument, | 3054 argument, |
| 3055 backend.namer.getNameForJsGetName( | 3055 backend.namer.getNameForJsGetName( |
| 3056 argument, string.dartString.slowToString()))); | 3056 argument, string.dartString.slowToString()))); |
| 3057 } | 3057 } |
| 3058 | 3058 |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3761 | 3761 |
| 3762 visitNewExpression(NewExpression node) { | 3762 visitNewExpression(NewExpression node) { |
| 3763 Element element = elements[node.send]; | 3763 Element element = elements[node.send]; |
| 3764 final bool isSymbolConstructor = element == compiler.symbolConstructor; | 3764 final bool isSymbolConstructor = element == compiler.symbolConstructor; |
| 3765 if (!Elements.isErroneousElement(element)) { | 3765 if (!Elements.isErroneousElement(element)) { |
| 3766 FunctionElement function = element; | 3766 FunctionElement function = element; |
| 3767 element = function.redirectionTarget; | 3767 element = function.redirectionTarget; |
| 3768 } | 3768 } |
| 3769 if (Elements.isErroneousElement(element)) { | 3769 if (Elements.isErroneousElement(element)) { |
| 3770 ErroneousElement error = element; | 3770 ErroneousElement error = element; |
| 3771 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { | 3771 if (error.messageKind == MessageKind.CANNOT_FIND_CONSTRUCTOR.error) { |
| 3772 generateThrowNoSuchMethod(node.send, | 3772 generateThrowNoSuchMethod(node.send, |
| 3773 getTargetName(error, 'constructor'), | 3773 getTargetName(error, 'constructor'), |
| 3774 argumentNodes: node.send.arguments); | 3774 argumentNodes: node.send.arguments); |
| 3775 } else { | 3775 } else { |
| 3776 Message message = error.messageKind.message(error.messageArguments); | 3776 Message message = error.messageKind.message(error.messageArguments); |
| 3777 generateRuntimeError(node.send, message.toString()); | 3777 generateRuntimeError(node.send, message.toString()); |
| 3778 } | 3778 } |
| 3779 } else if (node.isConst()) { | 3779 } else if (node.isConst()) { |
| 3780 ConstantHandler handler = compiler.constantHandler; | 3780 ConstantHandler handler = compiler.constantHandler; |
| 3781 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 3781 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4460 for (SwitchCase switchCase in node.cases) { | 4460 for (SwitchCase switchCase in node.cases) { |
| 4461 for (Node labelOrCase in switchCase.labelsAndCases) { | 4461 for (Node labelOrCase in switchCase.labelsAndCases) { |
| 4462 if (labelOrCase is CaseMatch) { | 4462 if (labelOrCase is CaseMatch) { |
| 4463 CaseMatch match = labelOrCase; | 4463 CaseMatch match = labelOrCase; |
| 4464 Constant constant = | 4464 Constant constant = |
| 4465 compiler.constantHandler.compileNodeWithDefinitions( | 4465 compiler.constantHandler.compileNodeWithDefinitions( |
| 4466 match.expression, elements, isConst: true); | 4466 match.expression, elements, isConst: true); |
| 4467 if (firstConstantType == null) { | 4467 if (firstConstantType == null) { |
| 4468 firstConstantType = constant.computeType(compiler); | 4468 firstConstantType = constant.computeType(compiler); |
| 4469 if (nonPrimitiveTypeOverridesEquals(constant)) { | 4469 if (nonPrimitiveTypeOverridesEquals(constant)) { |
| 4470 compiler.reportError(match.expression, | 4470 compiler.reportFatalError( |
| 4471 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS.error()); | 4471 match.expression, |
| 4472 MessageKind.SWITCH_CASE_VALUE_OVERRIDES_EQUALS); |
| 4472 failure = true; | 4473 failure = true; |
| 4473 } | 4474 } |
| 4474 } else { | 4475 } else { |
| 4475 DartType constantType = | 4476 DartType constantType = |
| 4476 constant.computeType(compiler); | 4477 constant.computeType(compiler); |
| 4477 if (constantType != firstConstantType) { | 4478 if (constantType != firstConstantType) { |
| 4478 compiler.reportError(match.expression, | 4479 compiler.reportFatalError( |
| 4479 MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL.error()); | 4480 match.expression, |
| 4481 MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL); |
| 4480 failure = true; | 4482 failure = true; |
| 4481 } | 4483 } |
| 4482 } | 4484 } |
| 4483 constants[labelOrCase] = constant; | 4485 constants[labelOrCase] = constant; |
| 4484 } | 4486 } |
| 4485 } | 4487 } |
| 4486 } | 4488 } |
| 4487 return constants; | 4489 return constants; |
| 4488 } | 4490 } |
| 4489 | 4491 |
| (...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5516 new HSubGraphBlockInformation(elseBranch.graph)); | 5518 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5517 | 5519 |
| 5518 HBasicBlock conditionStartBlock = conditionBranch.block; | 5520 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5519 conditionStartBlock.setBlockFlow(info, joinBlock); | 5521 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5520 SubGraph conditionGraph = conditionBranch.graph; | 5522 SubGraph conditionGraph = conditionBranch.graph; |
| 5521 HIf branch = conditionGraph.end.last; | 5523 HIf branch = conditionGraph.end.last; |
| 5522 assert(branch is HIf); | 5524 assert(branch is HIf); |
| 5523 branch.blockInformation = conditionStartBlock.blockFlow; | 5525 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5524 } | 5526 } |
| 5525 } | 5527 } |
| OLD | NEW |