OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._js_helper; | 5 library dart._js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'dart:_foreign_helper' show | 9 import 'dart:_foreign_helper' show |
10 JS, | 10 JS, |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 var date = JS('', r'new Date(#)', value); | 393 var date = JS('', r'new Date(#)', value); |
394 if (isUtc) { | 394 if (isUtc) { |
395 JS('num', r'#.setUTCFullYear(#)', date, years); | 395 JS('num', r'#.setUTCFullYear(#)', date, years); |
396 } else { | 396 } else { |
397 JS('num', r'#.setFullYear(#)', date, years); | 397 JS('num', r'#.setFullYear(#)', date, years); |
398 } | 398 } |
399 return JS('num', r'#.valueOf()', date); | 399 return JS('num', r'#.valueOf()', date); |
400 } | 400 } |
401 | 401 |
402 // Lazily keep a JS Date stored in the JS object. | 402 // Lazily keep a JS Date stored in the JS object. |
403 static lazyAsJsDate(receiver) { | 403 static lazyAsJsDate(DateTime receiver) { |
404 if (JS('bool', r'#.date === (void 0)', receiver)) { | 404 if (JS('bool', r'#.date === (void 0)', receiver)) { |
405 JS('void', r'#.date = new Date(#)', receiver, | 405 JS('void', r'#.date = new Date(#)', receiver, |
406 receiver.millisecondsSinceEpoch); | 406 receiver.millisecondsSinceEpoch); |
407 } | 407 } |
408 return JS('var', r'#.date', receiver); | 408 return JS('var', r'#.date', receiver); |
409 } | 409 } |
410 | 410 |
411 // The getters for date and time parts below add a positive integer to ensure | 411 // The getters for date and time parts below add a positive integer to ensure |
412 // that the result is really an integer, because the JavaScript implementation | 412 // that the result is really an integer, because the JavaScript implementation |
413 // may return -0.0 instead of 0. | 413 // may return -0.0 instead of 0. |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 // we have no way of telling the compiler yet, so it will generate an extra | 864 // we have no way of telling the compiler yet, so it will generate an extra |
865 // layer of indirection that wraps the SyncIterator. | 865 // layer of indirection that wraps the SyncIterator. |
866 _jsIterator() => JS('', '#(...#)', _generator, _args); | 866 _jsIterator() => JS('', '#(...#)', _generator, _args); |
867 | 867 |
868 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 868 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
869 } | 869 } |
870 | 870 |
871 class BooleanConversionAssertionError extends AssertionError { | 871 class BooleanConversionAssertionError extends AssertionError { |
872 toString() => 'Failed assertion: boolean expression must not be null'; | 872 toString() => 'Failed assertion: boolean expression must not be null'; |
873 } | 873 } |
OLD | NEW |