| 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, |
| 11 JS_STRING_CONCAT; | 11 JS_STRING_CONCAT; |
| 12 | 12 |
| 13 import 'dart:_interceptors'; | 13 import 'dart:_interceptors'; |
| 14 import 'dart:_internal' show | 14 import 'dart:_internal' show |
| 15 EfficientLength, | 15 EfficientLength, |
| 16 MappedIterable, | 16 MappedIterable, |
| 17 IterableElementError; | 17 IterableElementError; |
| 18 | 18 |
| 19 import 'dart:_native_typed_data'; | 19 import 'dart:_native_typed_data'; |
| 20 | 20 |
| 21 part 'annotations.dart'; | 21 part 'annotations.dart'; |
| 22 part 'linked_hash_map.dart'; | 22 part 'linked_hash_map.dart'; |
| 23 part 'native_helper.dart'; | 23 part 'native_helper.dart'; |
| 24 part 'regexp_helper.dart'; | 24 part 'regexp_helper.dart'; |
| 25 part 'string_helper.dart'; | 25 part 'string_helper.dart'; |
| 26 part 'js_rti.dart'; | 26 part 'js_rti.dart'; |
| 27 | 27 |
| 28 final _identityHashCode = JS('', 'Symbol("_identityHashCode")'); |
| 29 |
| 28 class _Patch { | 30 class _Patch { |
| 29 const _Patch(); | 31 const _Patch(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 const _Patch patch = const _Patch(); | 34 const _Patch patch = const _Patch(); |
| 33 | 35 |
| 34 /// Marks the internal map in dart2js, so that internal libraries can is-check | 36 /// Marks the internal map in dart2js, so that internal libraries can is-check |
| 35 // them. | 37 // them. |
| 36 abstract class InternalMap<K, V> implements Map<K, V> {} | 38 abstract class InternalMap<K, V> implements Map<K, V> {} |
| 37 | 39 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 /// Please don't add complicated code to this method, as it will impact | 52 /// Please don't add complicated code to this method, as it will impact |
| 51 /// start-up performance. | 53 /// start-up performance. |
| 52 static void initializeStatics(int id) { | 54 static void initializeStatics(int id) { |
| 53 // Benchmarking shows significant performance improvements if this is a | 55 // Benchmarking shows significant performance improvements if this is a |
| 54 // fixed value. | 56 // fixed value. |
| 55 mirrorFunctionCacheName += '_$id'; | 57 mirrorFunctionCacheName += '_$id'; |
| 56 mirrorInvokeCacheName += '_$id'; | 58 mirrorInvokeCacheName += '_$id'; |
| 57 } | 59 } |
| 58 | 60 |
| 59 static int objectHashCode(object) { | 61 static int objectHashCode(object) { |
| 60 int hash = JS('int|Null', r'#.$identityHash', object); | 62 int hash = JS('int|Null', r'#[#]', object, _identityHashCode); |
| 61 if (hash == null) { | 63 if (hash == null) { |
| 62 hash = JS('int', '(Math.random() * 0x3fffffff) | 0'); | 64 hash = JS('int', '(Math.random() * 0x3fffffff) | 0'); |
| 63 JS('void', r'#.$identityHash = #', object, hash); | 65 JS('void', r'#[#] = #', object, _identityHashCode, hash); |
| 64 } | 66 } |
| 65 return JS('int', '#', hash); | 67 return JS('int', '#', hash); |
| 66 } | 68 } |
| 67 | 69 |
| 68 @NoInline() | 70 @NoInline() |
| 69 static int _parseIntError(String source, int handleError(String source)) { | 71 static int _parseIntError(String source, int handleError(String source)) { |
| 70 if (handleError == null) throw new FormatException(source); | 72 if (handleError == null) throw new FormatException(source); |
| 71 return handleError(source); | 73 return handleError(source); |
| 72 } | 74 } |
| 73 | 75 |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 // we have no way of telling the compiler yet, so it will generate an extra | 907 // we have no way of telling the compiler yet, so it will generate an extra |
| 906 // layer of indirection that wraps the SyncIterator. | 908 // layer of indirection that wraps the SyncIterator. |
| 907 _jsIterator() => JS('', '#(...#)', _generator, _args); | 909 _jsIterator() => JS('', '#(...#)', _generator, _args); |
| 908 | 910 |
| 909 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); | 911 Iterator<E> get iterator => new SyncIterator<E>(_jsIterator()); |
| 910 } | 912 } |
| 911 | 913 |
| 912 class BooleanConversionAssertionError extends AssertionError { | 914 class BooleanConversionAssertionError extends AssertionError { |
| 913 toString() => 'Failed assertion: boolean expression must not be null'; | 915 toString() => 'Failed assertion: boolean expression must not be null'; |
| 914 } | 916 } |
| OLD | NEW |