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('constant_map.dart'); | 9 #source('constant_map.dart'); |
10 #source('native_helper.dart'); | 10 #source('native_helper.dart'); |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 : JS('int', @'#.getDay()', lazyAsJsDate(receiver)); | 560 : JS('int', @'#.getDay()', lazyAsJsDate(receiver)); |
561 } | 561 } |
562 | 562 |
563 static valueFromDateString(str) { | 563 static valueFromDateString(str) { |
564 checkNull(str); | 564 checkNull(str); |
565 if (str is !String) throw new IllegalArgumentException(str); | 565 if (str is !String) throw new IllegalArgumentException(str); |
566 var value = JS('num', @'Date.parse(#)', str); | 566 var value = JS('num', @'Date.parse(#)', str); |
567 if (value.isNaN()) throw new IllegalArgumentException(str); | 567 if (value.isNaN()) throw new IllegalArgumentException(str); |
568 return value; | 568 return value; |
569 } | 569 } |
| 570 |
| 571 static getProperty(object, key) { |
| 572 checkNull(object); |
| 573 if (object is bool || object is num || object is String) { |
| 574 throw new IllegalArgumentException(object); |
| 575 } |
| 576 return JS('var', '#[#]', object, key); |
| 577 } |
| 578 |
| 579 static void setProperty(object, key, value) { |
| 580 checkNull(object); |
| 581 if (object is bool || object is num || object is String) { |
| 582 throw new IllegalArgumentException(object); |
| 583 } |
| 584 JS('void', '#[#] = #', object, key, value); |
| 585 } |
570 } | 586 } |
571 | 587 |
572 /** | 588 /** |
573 * Called by generated code to throw an illegal-argument exception, | 589 * Called by generated code to throw an illegal-argument exception, |
574 * for example, if a non-integer index is given to an optimized | 590 * for example, if a non-integer index is given to an optimized |
575 * indexed access. | 591 * indexed access. |
576 */ | 592 */ |
577 iae(argument) { | 593 iae(argument) { |
578 throw new IllegalArgumentException(argument); | 594 throw new IllegalArgumentException(argument); |
579 } | 595 } |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 if (JS('bool', '!!#[#]', value, property)) return value; | 1081 if (JS('bool', '!!#[#]', value, property)) return value; |
1066 propertyTypeError(value, property); | 1082 propertyTypeError(value, property); |
1067 } | 1083 } |
1068 | 1084 |
1069 listSuperNativeTypeCheck(value, property) { | 1085 listSuperNativeTypeCheck(value, property) { |
1070 if (value === null) return value; | 1086 if (value === null) return value; |
1071 if (value is List) return value; | 1087 if (value is List) return value; |
1072 if (JS('bool', '#[#]()', value, property)) return value; | 1088 if (JS('bool', '#[#]()', value, property)) return value; |
1073 propertyTypeError(value, property); | 1089 propertyTypeError(value, property); |
1074 } | 1090 } |
OLD | NEW |