Chromium Code Reviews| 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 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 7 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 8 import '../common/tasks.dart' show CompilerTask; | 8 import '../common/tasks.dart' show CompilerTask; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/constant_system.dart'; | 10 import '../constants/constant_system.dart'; |
| (...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2842 // input is !string | 2842 // input is !string |
| 2843 checkString(input, '!==', input.sourceInformation); | 2843 checkString(input, '!==', input.sourceInformation); |
| 2844 return pop(); | 2844 return pop(); |
| 2845 } | 2845 } |
| 2846 reporter.internalError(input, 'Unexpected check: $checkedType.'); | 2846 reporter.internalError(input, 'Unexpected check: $checkedType.'); |
| 2847 return null; | 2847 return null; |
| 2848 } | 2848 } |
| 2849 | 2849 |
| 2850 void visitTypeConversion(HTypeConversion node) { | 2850 void visitTypeConversion(HTypeConversion node) { |
| 2851 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { | 2851 if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) { |
| 2852 // An int check if the input is not int or null, is not | |
| 2853 // sufficient for doing an argument or receiver check. | |
|
sra1
2017/02/01 00:59:15
I think this is incorrect. The check is Math.floor
Siggi Cherem (dart-lang)
2017/02/01 01:31:48
Could we end up hitting the Math.floor case when t
sra1
2017/02/01 02:15:46
It works as intended:
Math.floor(null) --> 0,
| |
| 2854 assert(compiler.options.trustTypeAnnotations || | |
| 2855 !node.checkedType.containsOnlyInt(closedWorld) || | |
| 2856 node.checkedInput.isIntegerOrNull(closedWorld)); | |
| 2857 js.Expression test = generateReceiverOrArgumentTypeTest( | 2852 js.Expression test = generateReceiverOrArgumentTypeTest( |
| 2858 node.checkedInput, node.checkedType); | 2853 node.checkedInput, node.checkedType); |
| 2859 js.Block oldContainer = currentContainer; | 2854 js.Block oldContainer = currentContainer; |
| 2860 js.Statement body = new js.Block.empty(); | 2855 js.Statement body = new js.Block.empty(); |
| 2861 currentContainer = body; | 2856 currentContainer = body; |
| 2862 if (node.isArgumentTypeCheck) { | 2857 if (node.isArgumentTypeCheck) { |
| 2863 generateThrowWithHelper( | 2858 generateThrowWithHelper( |
| 2864 helpers.throwIllegalArgumentException, node.checkedInput, | 2859 helpers.throwIllegalArgumentException, node.checkedInput, |
| 2865 sourceInformation: node.sourceInformation); | 2860 sourceInformation: node.sourceInformation); |
| 2866 } else if (node.isReceiverTypeCheck) { | 2861 } else if (node.isReceiverTypeCheck) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3120 registry.registerStaticUse(new StaticUse.staticInvoke( | 3115 registry.registerStaticUse(new StaticUse.staticInvoke( |
| 3121 helper, new CallStructure.unnamed(argumentCount))); | 3116 helper, new CallStructure.unnamed(argumentCount))); |
| 3122 return backend.emitter.staticFunctionAccess(helper); | 3117 return backend.emitter.staticFunctionAccess(helper); |
| 3123 } | 3118 } |
| 3124 | 3119 |
| 3125 @override | 3120 @override |
| 3126 void visitRef(HRef node) { | 3121 void visitRef(HRef node) { |
| 3127 visit(node.value); | 3122 visit(node.value); |
| 3128 } | 3123 } |
| 3129 } | 3124 } |
| OLD | NEW |