| 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 _js_helper; | 5 library _js_helper; |
| 6 | 6 |
| 7 import 'dart:_async_await_error_codes' as async_error_codes; | 7 import 'dart:_async_await_error_codes' as async_error_codes; |
| 8 | 8 |
| 9 import 'dart:_js_embedded_names' show | 9 import 'dart:_js_embedded_names' show |
| 10 DEFERRED_LIBRARY_URIS, | 10 DEFERRED_LIBRARY_URIS, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 JS_EMBEDDED_GLOBAL, | 50 JS_EMBEDDED_GLOBAL, |
| 51 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG, | 51 JS_FUNCTION_TYPE_NAMED_PARAMETERS_TAG, |
| 52 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, | 52 JS_FUNCTION_TYPE_OPTIONAL_PARAMETERS_TAG, |
| 53 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, | 53 JS_FUNCTION_TYPE_REQUIRED_PARAMETERS_TAG, |
| 54 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, | 54 JS_FUNCTION_TYPE_RETURN_TYPE_TAG, |
| 55 JS_FUNCTION_TYPE_VOID_RETURN_TAG, | 55 JS_FUNCTION_TYPE_VOID_RETURN_TAG, |
| 56 JS_GET_FLAG, | 56 JS_GET_FLAG, |
| 57 JS_GET_NAME, | 57 JS_GET_NAME, |
| 58 JS_HAS_EQUALS, | 58 JS_HAS_EQUALS, |
| 59 JS_IS_INDEXABLE_FIELD_NAME, | 59 JS_IS_INDEXABLE_FIELD_NAME, |
| 60 JS_NULL_CLASS_NAME, | |
| 61 JS_OBJECT_CLASS_NAME, | |
| 62 JS_OPERATOR_AS_PREFIX, | 60 JS_OPERATOR_AS_PREFIX, |
| 63 JS_SIGNATURE_NAME, | 61 JS_SIGNATURE_NAME, |
| 64 JS_STRING_CONCAT, | 62 JS_STRING_CONCAT, |
| 65 RAW_DART_FUNCTION_REF; | 63 RAW_DART_FUNCTION_REF; |
| 66 | 64 |
| 67 import 'dart:_interceptors'; | 65 import 'dart:_interceptors'; |
| 68 import 'dart:_internal' as _symbol_dev; | 66 import 'dart:_internal' as _symbol_dev; |
| 69 import 'dart:_internal' show MappedIterable; | 67 import 'dart:_internal' show MappedIterable; |
| 70 | 68 |
| 71 import 'dart:_native_typed_data'; | 69 import 'dart:_native_typed_data'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 106 |
| 109 | 107 |
| 110 /// Creates a function type object. | 108 /// Creates a function type object. |
| 111 // TODO(floitsch): move this to foreign_helper.dart or similar. | 109 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 112 @ForceInline() | 110 @ForceInline() |
| 113 createDartFunctionType() { | 111 createDartFunctionType() { |
| 114 return JS_BUILTIN('returns:=Object;effects:none;depends:none', | 112 return JS_BUILTIN('returns:=Object;effects:none;depends:none', |
| 115 JsBuiltin.createFunctionType); | 113 JsBuiltin.createFunctionType); |
| 116 } | 114 } |
| 117 | 115 |
| 118 /// Returns true if the given [type] is _the_ `Function` type. | |
| 119 // TODO(floitsch): move this to foreign_helper.dart or similar. | |
| 120 @ForceInline() | |
| 121 bool isDartFunctionTypeLiteral(Object type) { | |
| 122 return JS_BUILTIN('returns:bool;effects:none;depends:none', | |
| 123 JsBuiltin.isFunctionTypeLiteral, type); | |
| 124 } | |
| 125 | |
| 126 /// Retrieves the class name from type information stored on the constructor of | 116 /// Retrieves the class name from type information stored on the constructor of |
| 127 /// [type]. | 117 /// [type]. |
| 128 // TODO(floitsch): move this to foreign_helper.dart or similar. | 118 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 129 @ForceInline() | 119 @ForceInline() |
| 130 String getDartTypeName(Object type) { | 120 String getDartTypeName(Object type) { |
| 131 return JS_BUILTIN('String', JsBuiltin.typeName, type); | 121 return JS_BUILTIN('String', JsBuiltin.typeName, type); |
| 132 } | 122 } |
| 133 | 123 |
| 134 /// Returns the raw runtime type of the given object [o]. | 124 /// Returns the raw runtime type of the given object [o]. |
| 135 /// | 125 /// |
| 136 /// The argument [o] must be the interceptor for primitive types. If | 126 /// The argument [o] must be the interceptor for primitive types. If |
| 137 /// necessary run it through [getInterceptor] first. | 127 /// necessary run it through [getInterceptor] first. |
| 138 // TODO(floitsch): move this to foreign_helper.dart or similar. | 128 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 139 // TODO(floitsch): we should call getInterceptor ourselves, but currently | 129 // TODO(floitsch): we should call getInterceptor ourselves, but currently |
| 140 // getInterceptor is not GVNed. | 130 // getInterceptor is not GVNed. |
| 141 @ForceInline() | 131 @ForceInline() |
| 142 Object getRawRuntimeType(Object o) { | 132 Object getRawRuntimeType(Object o) { |
| 143 return JS_BUILTIN('', JsBuiltin.rawRuntimeType, o); | 133 return JS_BUILTIN('', JsBuiltin.rawRuntimeType, o); |
| 144 } | 134 } |
| 145 | 135 |
| 146 /// Returns whether the given [type] is a subtype of [other]. | 136 /// Returns whether the given [type] is a subtype of [other]. |
| 147 /// | 137 /// |
| 148 /// The argument [other] is the name of the other type, as computed by | 138 /// The argument [other] is the name of the other type, as computed by |
| 149 /// [runtimeTypeToString]. | 139 /// [runtimeTypeToString]. |
| 140 @ForceInline() |
| 150 bool builtinIsSubtype(type, String other) { | 141 bool builtinIsSubtype(type, String other) { |
| 151 return JS_BUILTIN('returns:bool;effects:none;depends:none', | 142 return JS_BUILTIN('returns:bool;effects:none;depends:none', |
| 152 JsBuiltin.isSubtype, other, type); | 143 JsBuiltin.isSubtype, other, type); |
| 153 } | 144 } |
| 154 | 145 |
| 146 /// Returns true if the given [type] is _the_ `Function` type. |
| 147 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 148 @ForceInline() |
| 149 bool isDartFunctionTypeRti(Object type) { |
| 150 return JS_BUILTIN('returns:bool;effects:none;depends:none', |
| 151 JsBuiltin.isFunctionTypeRti, type); |
| 152 } |
| 153 |
| 154 /// Returns whether the given type is _the_ Dart Object type. |
| 155 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 156 @ForceInline() |
| 157 bool isDartObjectTypeRti(type) { |
| 158 return JS_BUILTIN('returns:bool;effects:none;depends:none', |
| 159 JsBuiltin.isDartObjectTypeRti, type); |
| 160 } |
| 161 |
| 162 /// Returns whether the given type is _the_ null type. |
| 163 // TODO(floitsch): move this to foreign_helper.dart or similar. |
| 164 @ForceInline() |
| 165 bool isNullTypeRti(type) { |
| 166 return JS_BUILTIN('returns:bool;effects:none;depends:none', |
| 167 JsBuiltin.isNullTypeRti, type); |
| 168 } |
| 169 |
| 155 /// Returns the metadata of the given [index]. | 170 /// Returns the metadata of the given [index]. |
| 156 @ForceInline() | 171 @ForceInline() |
| 157 getMetadata(int index) { | 172 getMetadata(int index) { |
| 158 return JS_BUILTIN('returns:var;effects:none;depends:none', | 173 return JS_BUILTIN('returns:var;effects:none;depends:none', |
| 159 JsBuiltin.getMetadata, index); | 174 JsBuiltin.getMetadata, index); |
| 160 } | 175 } |
| 161 | 176 |
| 162 /// Returns the type of the given [index]. | 177 /// Returns the type of the given [index]. |
| 163 @ForceInline() | 178 @ForceInline() |
| 164 getType(int index) { | 179 getType(int index) { |
| (...skipping 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4074 // This is a function that will return a helper function that does the | 4089 // This is a function that will return a helper function that does the |
| 4075 // iteration of the sync*. | 4090 // iteration of the sync*. |
| 4076 // | 4091 // |
| 4077 // Each invocation should give a body with fresh state. | 4092 // Each invocation should give a body with fresh state. |
| 4078 final dynamic /* js function */ _outerHelper; | 4093 final dynamic /* js function */ _outerHelper; |
| 4079 | 4094 |
| 4080 SyncStarIterable(this._outerHelper); | 4095 SyncStarIterable(this._outerHelper); |
| 4081 | 4096 |
| 4082 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); | 4097 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); |
| 4083 } | 4098 } |
| OLD | NEW |