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 #library('js_helper'); | 5 #library('js_helper'); |
| 6 | 6 |
| 7 #import('coreimpl.dart'); | 7 #import('coreimpl.dart'); |
| 8 | 8 |
| 9 #source('date_helper.dart'); | 9 #source('date_helper.dart'); |
| 10 #source('regexp_helper.dart'); | |
| 10 | 11 |
| 11 /** | 12 /** |
| 12 * Returns true if both arguments are numbers. | 13 * Returns true if both arguments are numbers. |
| 13 * If only the first argument is a number, throws the given message as | 14 * If only the first argument is a number, throws the given message as |
| 14 * exception. | 15 * exception. |
| 15 */ | 16 */ |
| 16 bool checkNumbers(var a, var b, var message) { | 17 bool checkNumbers(var a, var b, var message) { |
| 17 if (a is num) { | 18 if (a is num) { |
| 18 if (b is num) { | 19 if (b is num) { |
| 19 return true; | 20 return true; |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 if (value is !int) throw new IllegalArgumentException(value); | 793 if (value is !int) throw new IllegalArgumentException(value); |
| 793 return value; | 794 return value; |
| 794 } | 795 } |
| 795 | 796 |
| 796 checkBool(value) { | 797 checkBool(value) { |
| 797 checkNull(value); | 798 checkNull(value); |
| 798 if (value is !bool) throw new IllegalArgumentException(value); | 799 if (value is !bool) throw new IllegalArgumentException(value); |
| 799 return value; | 800 return value; |
| 800 } | 801 } |
| 801 | 802 |
| 803 checkString(value) { | |
| 804 checkNull(value); | |
|
kasperl
2012/02/21 07:35:17
Would it be simpler to rewrite some of these to do
| |
| 805 if (value is !String) throw new IllegalArgumentException(value); | |
| 806 return value; | |
| 807 } | |
| 808 | |
| 802 builtin$isNegative$0(receiver) { | 809 builtin$isNegative$0(receiver) { |
| 803 checkNull(receiver); | 810 checkNull(receiver); |
| 804 if (receiver is num) { | 811 if (receiver is num) { |
| 805 return (receiver === 0) ? (1 / receiver) < 0 : receiver < 0; | 812 return (receiver === 0) ? (1 / receiver) < 0 : receiver < 0; |
| 806 } else { | 813 } else { |
| 807 return UNINTERCEPTED(receiver.isNegative()); | 814 return UNINTERCEPTED(receiver.isNegative()); |
| 808 } | 815 } |
| 809 } | 816 } |
| 810 | 817 |
| 811 builtin$isNaN$0(receiver) { | 818 builtin$isNaN$0(receiver) { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 builtin$hashCode$0(receiver) { | 1142 builtin$hashCode$0(receiver) { |
| 1136 if (receiver is num) return receiver & 0x1FFFFFFF; | 1143 if (receiver is num) return receiver & 0x1FFFFFFF; |
| 1137 if (receiver is String) { | 1144 if (receiver is String) { |
| 1138 throw 'String.hashCode is not implemented'; | 1145 throw 'String.hashCode is not implemented'; |
| 1139 } | 1146 } |
| 1140 if (isJSArray(receiver)) { | 1147 if (isJSArray(receiver)) { |
| 1141 throw 'List.hashCode is not implemented'; | 1148 throw 'List.hashCode is not implemented'; |
| 1142 } | 1149 } |
| 1143 return UNINTERCEPTED(receiver.hashCode()); | 1150 return UNINTERCEPTED(receiver.hashCode()); |
| 1144 } | 1151 } |
| OLD | NEW |