Chromium Code Reviews| Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| index 4e1bc4cbe5c79386812570fbbe2618f7ca552b72..fd68d4d73c62baa8afd8fdd35597425cee158585 100644 |
| --- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| @@ -194,7 +194,7 @@ String S(value) { |
| return 'null'; |
| } |
| var res = value.toString(); |
| - if (res is !String) throw new ArgumentError(value); |
| + if (res is !String) throw _ArgumentError(value); |
| return res; |
| } |
| @@ -690,9 +690,11 @@ class Primitives { |
| return _parseIntError(source, handleError); |
| } |
| - if (radix is! int) throw new ArgumentError("Radix is not an integer"); |
| + if (radix is! int) { |
| + throw new ArgumentError.value(radix, 'radix', 'is not an integer'); |
| + } |
| if (radix < 2 || radix > 36) { |
| - throw new RangeError.range(radix, 2, 36, "radix"); |
| + throw new RangeError.range(radix, 2, 36, 'radix'); |
| } |
| if (radix == 10 && decimalMatch != null) { |
| // Cannot fail because we know that the digits are all decimal. |
| @@ -737,7 +739,7 @@ class Primitives { |
| static double _parseDoubleError(String source, |
| double handleError(String source)) { |
| if (handleError == null) { |
| - throw new FormatException("Invalid double", source); |
| + throw new FormatException('Invalid double', source); |
| } |
| return handleError(source); |
| } |
| @@ -872,14 +874,14 @@ class Primitives { |
| static String stringFromCodePoints(codePoints) { |
| List<int> a = <int>[]; |
| for (var i in codePoints) { |
| - if (i is !int) throw new ArgumentError(i); |
| + if (i is !int) throw _ArgumentError(i); |
| if (i <= 0xffff) { |
| a.add(i); |
| } else if (i <= 0x10ffff) { |
| a.add(0xd800 + ((((i - 0x10000) >> 10) & 0x3ff))); |
| a.add(0xdc00 + (i & 0x3ff)); |
| } else { |
| - throw new ArgumentError(i); |
| + throw _ArgumentError(i); |
| } |
| } |
| return _fromCharCodeApply(a); |
| @@ -887,8 +889,8 @@ class Primitives { |
| static String stringFromCharCodes(charCodes) { |
| for (var i in charCodes) { |
| - if (i is !int) throw new ArgumentError(i); |
| - if (i < 0) throw new ArgumentError(i); |
| + if (i is !int) throw _ArgumentError(i); |
| + if (i < 0) throw _ArgumentError(i); |
| if (i > 0xffff) return stringFromCodePoints(charCodes); |
| } |
| return _fromCharCodeApply(charCodes); |
| @@ -1077,22 +1079,22 @@ class Primitives { |
| } |
| static valueFromDateString(str) { |
| - if (str is !String) throw new ArgumentError(str); |
| + if (str is !String) throw _ArgumentError(str); |
| var value = JS('num', r'Date.parse(#)', str); |
| - if (value.isNaN) throw new ArgumentError(str); |
| + if (value.isNaN) throw _ArgumentError(str); |
| return value; |
| } |
| static getProperty(object, key) { |
| if (object == null || object is bool || object is num || object is String) { |
| - throw new ArgumentError(object); |
| + throw _ArgumentError(object); |
| } |
| return JS('var', '#[#]', object, key); |
| } |
| static void setProperty(object, key, value) { |
| if (object == null || object is bool || object is num || object is String) { |
| - throw new ArgumentError(object); |
| + throw _ArgumentError(object); |
| } |
| JS('void', '#[#] = #', object, key, value); |
| } |
| @@ -1384,7 +1386,7 @@ class JsCache { |
| * indexed access. |
| */ |
| iae(argument) { |
| - throw new ArgumentError(argument); |
| + throw _ArgumentError(argument); |
| } |
| /** |
| @@ -1404,36 +1406,34 @@ stringLastIndexOfUnchecked(receiver, element, start) |
| => JS('int', r'#.lastIndexOf(#, #)', receiver, element, start); |
| +/// 'factory' for constructing ArgumentError.value. |
| +@NoInline() |
| +ArgumentError _ArgumentError(object) { |
|
floitsch
2015/05/13 05:11:29
it's a function. -> lower case.
(even if it's to
sra1
2015/05/13 22:17:48
Done.
|
| + return new ArgumentError.value(object); |
| +} |
| + |
| checkNull(object) { |
| - if (object == null) throw new ArgumentError(null); |
| + if (object == null) throw _ArgumentError(object); |
| return object; |
| } |
| checkNum(value) { |
| - if (value is !num) { |
| - throw new ArgumentError(value); |
| - } |
| + if (value is !num) throw _ArgumentError(value); |
| return value; |
| } |
| checkInt(value) { |
| - if (value is !int) { |
| - throw new ArgumentError(value); |
| - } |
| + if (value is !int) throw _ArgumentError(value); |
| return value; |
| } |
| checkBool(value) { |
| - if (value is !bool) { |
| - throw new ArgumentError(value); |
| - } |
| + if (value is !bool) throw _ArgumentError(value); |
| return value; |
| } |
| checkString(value) { |
| - if (value is !String) { |
| - throw new ArgumentError(value); |
| - } |
| + if (value is !String) throw _ArgumentError(value); |
| return value; |
| } |