| 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 $throw(String msg) { | 7 $throw(String msg) { |
| 8 var e = JS("Object", @"new Error($0)", msg); | 8 var e = JS("Object", @"new Error($0)", msg); |
| 9 var hasTrace = JS("bool", @"Error.captureStackTrace !== (void 0)"); | 9 var hasTrace = JS("bool", @"Error.captureStackTrace !== (void 0)"); |
| 10 if (hasTrace) { | 10 if (hasTrace) { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if (length == null) return JS("Object", @"new Array()"); | 332 if (length == null) return JS("Object", @"new Array()"); |
| 333 if (!(length is int)) throw "Invalid argument"; | 333 if (!(length is int)) throw "Invalid argument"; |
| 334 if (length < 0) throw "Negative size"; | 334 if (length < 0) throw "Negative size"; |
| 335 return JS("Object", @"new Array($0)", length); | 335 return JS("Object", @"new Array($0)", length); |
| 336 } | 336 } |
| 337 | 337 |
| 338 static num dateNow() => JS("num", @"Date.now()"); | 338 static num dateNow() => JS("num", @"Date.now()"); |
| 339 | 339 |
| 340 static num mathFloor(num value) => JS("num", @"Math.floor($0)", value); | 340 static num mathFloor(num value) => JS("num", @"Math.floor($0)", value); |
| 341 } | 341 } |
| 342 |
| 343 builtin$compareTo$1(a, b) { |
| 344 if (checkNumbers(a, b, 'illegal argument')) { |
| 345 if (a < b) { |
| 346 return -1; |
| 347 } else if (a > b) { |
| 348 return 1; |
| 349 } else if (a == b) { |
| 350 if (a == 0) { |
| 351 bool aIsNegative = a.isNegative(); |
| 352 bool bIsNegative = b.isNegative(); |
| 353 if (aIsNegative == bIsNegative) return 0; |
| 354 if (aIsNegative) return -1; |
| 355 return 1; |
| 356 } |
| 357 return 0; |
| 358 } else if (a.isNaN()) { |
| 359 if (b.isNaN()) { |
| 360 return 0; |
| 361 } |
| 362 return 1; |
| 363 } else { |
| 364 return -1; |
| 365 } |
| 366 } else if (a is String) { |
| 367 throw 'String.compareTo is not implemented'; |
| 368 } else { |
| 369 return UNINTERCEPTED(a.compareTo(b)); |
| 370 } |
| 371 } |
| OLD | NEW |