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 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
8 | 8 |
9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
10 | 10 |
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 } else { | 2565 } else { |
2566 compiler.internalError(input, 'Unexpected check.'); | 2566 compiler.internalError(input, 'Unexpected check.'); |
2567 } | 2567 } |
2568 return test; | 2568 return test; |
2569 } | 2569 } |
2570 | 2570 |
2571 void visitTypeConversion(HTypeConversion node) { | 2571 void visitTypeConversion(HTypeConversion node) { |
2572 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { | 2572 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { |
2573 ClassWorld classWorld = compiler.world; | 2573 ClassWorld classWorld = compiler.world; |
2574 // An int check if the input is not int or null, is not | 2574 // An int check if the input is not int or null, is not |
2575 // sufficient for doing an argument or receiver check. | 2575 // sufficient for doing a argument or receiver check. |
2576 assert(compiler.trustTypeAnnotations || | 2576 assert(!node.checkedType.containsOnlyInt(classWorld) || |
2577 !node.checkedType.containsOnlyInt(classWorld) || | |
2578 node.checkedInput.isIntegerOrNull(compiler)); | 2577 node.checkedInput.isIntegerOrNull(compiler)); |
2579 js.Expression test = generateTest(node.checkedInput, node.checkedType); | 2578 js.Expression test = generateTest(node.checkedInput, node.checkedType); |
2580 js.Block oldContainer = currentContainer; | 2579 js.Block oldContainer = currentContainer; |
2581 js.Statement body = new js.Block.empty(); | 2580 js.Statement body = new js.Block.empty(); |
2582 currentContainer = body; | 2581 currentContainer = body; |
2583 if (node.isArgumentTypeCheck) { | 2582 if (node.isArgumentTypeCheck) { |
2584 generateThrowWithHelper('iae', node.checkedInput); | 2583 generateThrowWithHelper('iae', node.checkedInput); |
2585 } else if (node.isReceiverTypeCheck) { | 2584 } else if (node.isReceiverTypeCheck) { |
2586 use(node.checkedInput); | 2585 use(node.checkedInput); |
2587 String methodName = | 2586 String methodName = |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 js.PropertyAccess accessHelper(String name) { | 2722 js.PropertyAccess accessHelper(String name) { |
2724 Element helper = backend.findHelper(name); | 2723 Element helper = backend.findHelper(name); |
2725 if (helper == null) { | 2724 if (helper == null) { |
2726 // For mocked-up tests. | 2725 // For mocked-up tests. |
2727 return js.js('(void 0).$name'); | 2726 return js.js('(void 0).$name'); |
2728 } | 2727 } |
2729 registry.registerStaticUse(helper); | 2728 registry.registerStaticUse(helper); |
2730 return backend.namer.elementAccess(helper); | 2729 return backend.namer.elementAccess(helper); |
2731 } | 2730 } |
2732 } | 2731 } |
OLD | NEW |