Chromium Code Reviews| Index: dart/frog/leg/lib/js_helper.dart |
| diff --git a/dart/frog/leg/lib/js_helper.dart b/dart/frog/leg/lib/js_helper.dart |
| index f8454bf59030c9cc15a453c38cb8af38add8e1f7..8223235978705412bc65bca432523af4e33db418 100644 |
| --- a/dart/frog/leg/lib/js_helper.dart |
| +++ b/dart/frog/leg/lib/js_helper.dart |
| @@ -82,6 +82,7 @@ mod(var a, var b) { |
| tdiv(var a, var b) { |
| if (checkNumbers(a, b, "num~/ expects a number as second operand.")) { |
| + if (b === 0) throw new IntegerDivisionByZeroException(); |
| return (a / b).truncate(); |
| } |
| return UNINTERCEPTED(a ~/ b); |
| @@ -677,6 +678,7 @@ builtin$isNaN$0(receiver) { |
| builtin$remainder$1(a, b) { |
| checkNull(a); |
| if (checkNumbers(a, b, "num.remainder expects a number as second operand.")) { |
| + if (b === 0) throw new IntegerDivisionByZeroException(); |
| return JS("num", @"$0 % $1", a, b); |
| } else { |
| return UNINTERCEPTED(a.remainder(b)); |
| @@ -758,10 +760,41 @@ builtin$toStringAsFixed$1(receiver, fractionDigits) { |
| if (receiver is !num) { |
| return UNINTERCEPTED(receiver.toStringAsFixed(fractionDigits)); |
| } |
| + checkNum(fractionDigits); |
| return JS("String", @"$0.toFixed($1)", receiver, fractionDigits); |
| } |
| +builtin$toStringAsExponential$1(receiver, fractionDigits) { |
| + checkNull(receiver); |
|
ngeoffray
2012/02/21 12:20:30
No need for these check null.
|
| + if (receiver is !num) { |
| + return UNINTERCEPTED(receiver.toStringAsExponential(fractionDigits)); |
| + } |
| + checkNum(fractionDigits); |
| + |
| + return JS("String", @"$0.toExponential($1)", receiver, fractionDigits); |
| +} |
| + |
| +builtin$toStringAsPrecision$1(receiver, fractionDigits) { |
| + checkNull(receiver); |
| + if (receiver is !num) { |
| + return UNINTERCEPTED(receiver.toStringAsPrecision(fractionDigits)); |
| + } |
| + checkNum(fractionDigits); |
| + |
| + return JS("String", @"$0.toPrecision($1)", receiver, fractionDigits); |
| +} |
| + |
| +builtin$toRadixString$1(receiver, radix) { |
| + checkNull(receiver); |
| + if (receiver is !num) { |
| + return UNINTERCEPTED(receiver.toRadixString(radix)); |
| + } |
| + checkNum(radix); |
| + |
| + return JS("String", @"$0.toString($1)", receiver, radix); |
| +} |
| + |
| builtin$allMatches$1(receiver, str) { |
| checkNull(receiver); |
| if (receiver is !String) return UNINTERCEPTED(receiver.allMatches(str)); |
| @@ -913,3 +946,14 @@ class MathNatives { |
| static double random() => JS("double", "Math.random()"); |
| } |
| + |
| +builtin$hashCode$0(receiver) { |
| + if (receiver is num) return receiver & 0x1FFFFFFF; |
| + if (receiver is String) { |
| + throw new NotImplementedException(); |
| + } |
| + if (isJSArray(receiver)) { |
| + throw new NotImplementedException(); |
| + } |
| + return UNINTERCEPTED(receiver.hashCode()); |
| +} |