OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // TODO(sigmund): rename and move to common/elements.dart | 5 // TODO(sigmund): rename and move to common/elements.dart |
6 library dart2js.type_system; | 6 library dart2js.type_system; |
7 | 7 |
8 import 'common/names.dart' show Uris; | 8 import 'common/names.dart' show Identifiers, Uris; |
| 9 import 'js_backend/constant_system_javascript.dart'; |
9 import 'elements/types.dart'; | 10 import 'elements/types.dart'; |
| 11 import 'elements/elements.dart' show PublicName; |
10 import 'elements/entities.dart'; | 12 import 'elements/entities.dart'; |
| 13 import 'js_backend/backend.dart' show JavaScriptBackend; |
| 14 import 'universe/call_structure.dart' show CallStructure; |
| 15 import 'universe/selector.dart' show Selector; |
11 import 'universe/call_structure.dart'; | 16 import 'universe/call_structure.dart'; |
12 | 17 |
13 /// The common elements and types in Dart. | 18 /// The common elements and types in Dart. |
14 abstract class CommonElements { | 19 class CommonElements { |
| 20 final ElementEnvironment _env; |
| 21 |
| 22 CommonElements(this._env); |
| 23 |
15 /// The `Object` class defined in 'dart:core'. | 24 /// The `Object` class defined in 'dart:core'. |
16 ClassEntity get objectClass; | 25 ClassEntity _objectClass; |
| 26 ClassEntity get objectClass => |
| 27 _objectClass ??= _findClass(coreLibrary, 'Object'); |
17 | 28 |
18 /// The `bool` class defined in 'dart:core'. | 29 /// The `bool` class defined in 'dart:core'. |
19 ClassEntity get boolClass; | 30 ClassEntity _boolClass; |
| 31 ClassEntity get boolClass => _boolClass ??= _findClass(coreLibrary, 'bool'); |
20 | 32 |
21 /// The `num` class defined in 'dart:core'. | 33 /// The `num` class defined in 'dart:core'. |
22 ClassEntity get numClass; | 34 ClassEntity _numClass; |
| 35 ClassEntity get numClass => _numClass ??= _findClass(coreLibrary, 'num'); |
23 | 36 |
24 /// The `int` class defined in 'dart:core'. | 37 /// The `int` class defined in 'dart:core'. |
25 ClassEntity get intClass; | 38 ClassEntity _intClass; |
| 39 ClassEntity get intClass => _intClass ??= _findClass(coreLibrary, 'int'); |
26 | 40 |
27 /// The `double` class defined in 'dart:core'. | 41 /// The `double` class defined in 'dart:core'. |
28 ClassEntity get doubleClass; | 42 ClassEntity _doubleClass; |
| 43 ClassEntity get doubleClass => |
| 44 _doubleClass ??= _findClass(coreLibrary, 'double'); |
| 45 |
| 46 /// The `String` class defined in 'dart:core'. |
| 47 ClassEntity _stringClass; |
| 48 ClassEntity get stringClass => |
| 49 _stringClass ??= _findClass(coreLibrary, 'String'); |
| 50 |
| 51 /// The `Function` class defined in 'dart:core'. |
| 52 ClassEntity _functionClass; |
| 53 ClassEntity get functionClass => |
| 54 _functionClass ??= _findClass(coreLibrary, 'Function'); |
29 | 55 |
30 /// The `Resource` class defined in 'dart:core'. | 56 /// The `Resource` class defined in 'dart:core'. |
31 ClassEntity get resourceClass; | 57 ClassEntity _resourceClass; |
32 | 58 ClassEntity get resourceClass => |
33 /// The `String` class defined in 'dart:core'. | 59 _resourceClass ??= _findClass(coreLibrary, 'Resource'); |
34 ClassEntity get stringClass; | |
35 | 60 |
36 /// The `Symbol` class defined in 'dart:core'. | 61 /// The `Symbol` class defined in 'dart:core'. |
37 ClassEntity get symbolClass; | 62 ClassEntity _symbolClass; |
38 | 63 ClassEntity get symbolClass => |
39 /// The `Function` class defined in 'dart:core'. | 64 _symbolClass ??= _findClass(coreLibrary, 'Symbol'); |
40 ClassEntity get functionClass; | |
41 | 65 |
42 /// The `Null` class defined in 'dart:core'. | 66 /// The `Null` class defined in 'dart:core'. |
43 ClassEntity get nullClass; | 67 ClassEntity _nullClass; |
| 68 ClassEntity get nullClass => _nullClass ??= _findClass(coreLibrary, 'Null'); |
44 | 69 |
45 /// The `Type` class defined in 'dart:core'. | 70 /// The `Type` class defined in 'dart:core'. |
46 ClassEntity get typeClass; | 71 ClassEntity _typeClass; |
| 72 ClassEntity get typeClass => _typeClass ??= _findClass(coreLibrary, 'Type'); |
47 | 73 |
48 /// The `StackTrace` class defined in 'dart:core'; | 74 /// The `StackTrace` class defined in 'dart:core'; |
49 ClassEntity get stackTraceClass; | 75 ClassEntity _stackTraceClass; |
| 76 ClassEntity get stackTraceClass => |
| 77 _stackTraceClass ??= _findClass(coreLibrary, 'StackTrace'); |
50 | 78 |
51 /// The `List` class defined in 'dart:core'; | 79 /// The `List` class defined in 'dart:core'; |
52 ClassEntity get listClass; | 80 ClassEntity _listClass; |
| 81 ClassEntity get listClass => _listClass ??= _findClass(coreLibrary, 'List'); |
53 | 82 |
54 /// The `Map` class defined in 'dart:core'; | 83 /// The `Map` class defined in 'dart:core'; |
55 ClassEntity get mapClass; | 84 ClassEntity _mapClass; |
| 85 ClassEntity get mapClass => _mapClass ??= _findClass(coreLibrary, 'Map'); |
56 | 86 |
57 /// The `Iterable` class defined in 'dart:core'; | 87 /// The `Iterable` class defined in 'dart:core'; |
58 ClassEntity get iterableClass; | 88 ClassEntity _iterableClass; |
| 89 ClassEntity get iterableClass => |
| 90 _iterableClass ??= _findClass(coreLibrary, 'Iterable'); |
59 | 91 |
60 /// The `Future` class defined in 'async';. | 92 /// The `Future` class defined in 'async';. |
61 ClassEntity get futureClass; | 93 ClassEntity _futureClass; |
| 94 ClassEntity get futureClass => |
| 95 _futureClass ??= _findClass(asyncLibrary, 'Future'); |
62 | 96 |
63 /// The `Stream` class defined in 'async'; | 97 /// The `Stream` class defined in 'async'; |
64 ClassEntity get streamClass; | 98 ClassEntity _streamClass; |
| 99 ClassEntity get streamClass => |
| 100 _streamClass ??= _findClass(asyncLibrary, 'Stream'); |
65 | 101 |
66 /// The dart:core library. | 102 /// The dart:core library. |
67 LibraryEntity get coreLibrary; | 103 LibraryEntity _coreLibrary; |
| 104 LibraryEntity get coreLibrary => |
| 105 _coreLibrary ??= _env.lookupLibrary(Uris.dart_core, required: true); |
68 | 106 |
69 /// The dart:async library. | 107 /// The dart:async library. |
70 LibraryEntity get asyncLibrary; | 108 LibraryEntity _asyncLibrary; |
| 109 LibraryEntity get asyncLibrary => |
| 110 _asyncLibrary ??= _env.lookupLibrary(Uris.dart_async); |
71 | 111 |
72 /// The dart:mirrors library. Null if the program doesn't access dart:mirrors. | 112 /// The dart:mirrors library. Null if the program doesn't access dart:mirrors. |
73 LibraryEntity get mirrorsLibrary; | 113 LibraryEntity _mirrorsLibrary; |
| 114 LibraryEntity get mirrorsLibrary => |
| 115 _mirrorsLibrary ??= _env.lookupLibrary(Uris.dart_mirrors); |
74 | 116 |
75 /// The dart:typed_data library. | 117 /// The dart:typed_data library. |
76 LibraryEntity get typedDataLibrary; | 118 LibraryEntity _typedDataLibrary; |
| 119 LibraryEntity get typedDataLibrary => |
| 120 _typedDataLibrary ??= _env.lookupLibrary(Uris.dart__native_typed_data); |
| 121 |
| 122 LibraryEntity _jsHelperLibrary; |
| 123 LibraryEntity get jsHelperLibrary => |
| 124 _jsHelperLibrary ??= _env.lookupLibrary(Uris.dart__js_helper); |
| 125 |
| 126 LibraryEntity _interceptorsLibrary; |
| 127 LibraryEntity get interceptorsLibrary => |
| 128 _interceptorsLibrary ??= _env.lookupLibrary(Uris.dart__interceptors); |
| 129 |
| 130 LibraryEntity _foreignLibrary; |
| 131 LibraryEntity get foreignLibrary => |
| 132 _foreignLibrary ??= _env.lookupLibrary(Uris.dart__foreign_helper); |
| 133 |
| 134 LibraryEntity _isolateHelperLibrary; |
| 135 LibraryEntity get isolateHelperLibrary => |
| 136 _isolateHelperLibrary ??= _env.lookupLibrary(Uris.dart__isolate_helper); |
| 137 |
| 138 /// Reference to the internal library to lookup functions to always inline. |
| 139 LibraryEntity _internalLibrary; |
| 140 LibraryEntity get internalLibrary => |
| 141 _internalLibrary ??= _env.lookupLibrary(Uris.dart__internal); |
77 | 142 |
78 /// The `NativeTypedData` class from dart:typed_data. | 143 /// The `NativeTypedData` class from dart:typed_data. |
79 ClassEntity get typedDataClass; | 144 ClassEntity _typedDataClass; |
| 145 ClassEntity get typedDataClass => |
| 146 _typedDataClass ??= _findClass(typedDataLibrary, 'NativeTypedData'); |
80 | 147 |
81 /// Constructor of the `Symbol` class. This getter will ensure that `Symbol` | 148 /// Constructor of the `Symbol` class. This getter will ensure that `Symbol` |
82 /// is resolved and lookup the constructor on demand. | 149 /// is resolved and lookup the constructor on demand. |
83 ConstructorEntity get symbolConstructor; | 150 ConstructorEntity _symbolConstructor; |
| 151 ConstructorEntity get symbolConstructor => |
| 152 // TODO(johnniwinther): Kernel does not include redirecting factories |
| 153 // so this cannot be found in kernel. Find a consistent way to handle |
| 154 // this and similar cases. |
| 155 _symbolConstructor ??= _findConstructor(symbolClass, '', required: false); |
84 | 156 |
85 /// Whether [element] is the same as [symbolConstructor]. Used to check | 157 /// Whether [element] is the same as [symbolConstructor]. Used to check |
86 /// for the constructor without computing it until it is likely to be seen. | 158 /// for the constructor without computing it until it is likely to be seen. |
87 // TODO(johnniwinther): Change type of [e] to [MemberEntity]. | 159 // TODO(johnniwinther): Change type of [e] to [MemberEntity]. |
88 bool isSymbolConstructor(Entity e); | 160 bool isSymbolConstructor(Entity e) => e == symbolConstructor; |
89 | 161 |
90 /// The `MirrorSystem` class in dart:mirrors. | 162 /// The `MirrorSystem` class in dart:mirrors. |
91 ClassEntity get mirrorSystemClass; | 163 ClassEntity _mirrorSystemClass; |
| 164 ClassEntity get mirrorSystemClass => _mirrorSystemClass ??= |
| 165 _findClass(mirrorsLibrary, 'MirrorSystem', required: false); |
92 | 166 |
93 /// Whether [element] is `MirrorClass.getName`. Used to check for the use of | 167 /// Whether [element] is `MirrorClass.getName`. Used to check for the use of |
94 /// that static method without forcing the resolution of the `MirrorSystem` | 168 /// that static method without forcing the resolution of the `MirrorSystem` |
95 /// class until it is necessary. | 169 /// class until it is necessary. |
96 bool isMirrorSystemGetNameFunction(MemberEntity element); | 170 FunctionEntity _mirrorSystemGetNameFunction; |
| 171 bool isMirrorSystemGetNameFunction(MemberEntity element) { |
| 172 if (_mirrorSystemGetNameFunction == null) { |
| 173 if (!element.isFunction || mirrorsLibrary == null) return false; |
| 174 ClassEntity cls = mirrorSystemClass; |
| 175 if (element.enclosingClass != cls) return false; |
| 176 if (cls != null) { |
| 177 _mirrorSystemGetNameFunction = |
| 178 _findClassMember(cls, 'getName', required: false); |
| 179 } |
| 180 } |
| 181 return element == _mirrorSystemGetNameFunction; |
| 182 } |
97 | 183 |
98 /// The `MirrorsUsed` annotation in dart:mirrors. | 184 /// The `MirrorsUsed` annotation in dart:mirrors. |
99 ClassEntity get mirrorsUsedClass; | 185 ClassEntity _mirrorsUsedClass; |
| 186 ClassEntity get mirrorsUsedClass => _mirrorsUsedClass ??= |
| 187 _findClass(mirrorsLibrary, 'MirrorsUsed', required: false); |
100 | 188 |
101 /// Whether [element] is the constructor of the `MirrorsUsed` class. Used to | 189 /// Whether [element] is the constructor of the `MirrorsUsed` class. Used to |
102 /// check for the constructor without forcing the resolution of the | 190 /// check for the constructor without forcing the resolution of the |
103 /// `MirrorsUsed` class until it is necessary. | 191 /// `MirrorsUsed` class until it is necessary. |
104 bool isMirrorsUsedConstructor(ConstructorEntity element); | 192 bool isMirrorsUsedConstructor(ConstructorEntity element) => |
| 193 mirrorsLibrary != null && mirrorsUsedClass == element.enclosingClass; |
105 | 194 |
106 /// The `DeferredLibrary` annotation in dart:async that was used before the | 195 /// The `DeferredLibrary` annotation in dart:async that was used before the |
107 /// deferred import syntax was introduced. | 196 /// deferred import syntax was introduced. |
108 // TODO(sigmund): drop support for this old syntax? | 197 // TODO(sigmund): drop support for this old syntax? |
109 ClassEntity get deferredLibraryClass; | 198 ClassEntity _deferredLibraryClass; |
| 199 ClassEntity get deferredLibraryClass => |
| 200 _deferredLibraryClass ??= _findClass(asyncLibrary, "DeferredLibrary"); |
110 | 201 |
111 /// The function `identical` in dart:core. | 202 /// The function `identical` in dart:core. |
112 FunctionEntity get identicalFunction; | 203 FunctionEntity _identicalFunction; |
| 204 FunctionEntity get identicalFunction => |
| 205 _identicalFunction ??= _findLibraryMember(coreLibrary, 'identical'); |
113 | 206 |
114 /// The method `Function.apply`. | 207 /// The method `Function.apply`. |
115 FunctionEntity get functionApplyMethod; | 208 FunctionEntity _functionApplyMethod; |
| 209 FunctionEntity get functionApplyMethod => |
| 210 _functionApplyMethod ??= _findClassMember(functionClass, 'apply'); |
116 | 211 |
117 /// Whether [element] is the same as [functionApplyMethod]. This will not | 212 /// Whether [element] is the same as [functionApplyMethod]. This will not |
118 /// resolve the apply method if it hasn't been seen yet during compilation. | 213 /// resolve the apply method if it hasn't been seen yet during compilation. |
119 bool isFunctionApplyMethod(MemberEntity element); | 214 bool isFunctionApplyMethod(MemberEntity element) => |
| 215 element.name == 'apply' && element.enclosingClass == functionClass; |
120 | 216 |
121 /// Returns `true` if [element] is the unnamed constructor of `List`. This | 217 /// Returns `true` if [element] is the unnamed constructor of `List`. This |
122 /// will not resolve the constructor if it hasn't been seen yet during | 218 /// will not resolve the constructor if it hasn't been seen yet during |
123 /// compilation. | 219 /// compilation. |
124 bool isUnnamedListConstructor(ConstructorEntity element); | 220 bool isUnnamedListConstructor(ConstructorEntity element) => |
| 221 element.name == '' && element.enclosingClass == listClass; |
125 | 222 |
126 /// Returns `true` if [element] is the 'filled' constructor of `List`. This | 223 /// Returns `true` if [element] is the 'filled' constructor of `List`. This |
127 /// will not resolve the constructor if it hasn't been seen yet during | 224 /// will not resolve the constructor if it hasn't been seen yet during |
128 /// compilation. | 225 /// compilation. |
129 bool isFilledListConstructor(ConstructorEntity element); | 226 bool isFilledListConstructor(ConstructorEntity element) => |
| 227 element.name == 'filled' && element.enclosingClass == listClass; |
130 | 228 |
131 /// The `dynamic` type. | 229 /// The `dynamic` type. |
132 DynamicType get dynamicType; | 230 DynamicType get dynamicType => _env.dynamicType; |
133 | 231 |
134 /// The `Object` type defined in 'dart:core'. | 232 /// The `Object` type defined in 'dart:core'. |
135 InterfaceType get objectType; | 233 InterfaceType get objectType => _getRawType(objectClass); |
136 | 234 |
137 /// The `bool` type defined in 'dart:core'. | 235 /// The `bool` type defined in 'dart:core'. |
138 InterfaceType get boolType; | 236 InterfaceType get boolType => _getRawType(boolClass); |
139 | 237 |
140 /// The `num` type defined in 'dart:core'. | 238 /// The `num` type defined in 'dart:core'. |
141 InterfaceType get numType; | 239 InterfaceType get numType => _getRawType(numClass); |
142 | 240 |
143 /// The `int` type defined in 'dart:core'. | 241 /// The `int` type defined in 'dart:core'. |
144 InterfaceType get intType; | 242 InterfaceType get intType => _getRawType(intClass); |
145 | 243 |
146 /// The `double` type defined in 'dart:core'. | 244 /// The `double` type defined in 'dart:core'. |
147 InterfaceType get doubleType; | 245 InterfaceType get doubleType => _getRawType(doubleClass); |
148 | 246 |
149 /// The `Resource` type defined in 'dart:core'. | 247 /// The `Resource` type defined in 'dart:core'. |
150 InterfaceType get resourceType; | 248 InterfaceType get resourceType => _getRawType(resourceClass); |
151 | 249 |
152 /// The `String` type defined in 'dart:core'. | 250 /// The `String` type defined in 'dart:core'. |
153 InterfaceType get stringType; | 251 InterfaceType get stringType => _getRawType(stringClass); |
154 | 252 |
155 /// The `Symbol` type defined in 'dart:core'. | 253 /// The `Symbol` type defined in 'dart:core'. |
156 InterfaceType get symbolType; | 254 InterfaceType get symbolType => _getRawType(symbolClass); |
157 | 255 |
158 /// The `Function` type defined in 'dart:core'. | 256 /// The `Function` type defined in 'dart:core'. |
159 InterfaceType get functionType; | 257 InterfaceType get functionType => _getRawType(functionClass); |
160 | 258 |
161 /// The `Null` type defined in 'dart:core'. | 259 /// The `Null` type defined in 'dart:core'. |
162 InterfaceType get nullType; | 260 InterfaceType get nullType => _getRawType(nullClass); |
163 | 261 |
164 /// The `Type` type defined in 'dart:core'. | 262 /// The `Type` type defined in 'dart:core'. |
165 InterfaceType get typeType; | 263 InterfaceType get typeType => _getRawType(typeClass); |
166 | 264 |
167 /// The `StackTrace` type defined in 'dart:core'; | 265 /// The `StackTrace` type defined in 'dart:core'; |
168 InterfaceType get stackTraceType; | 266 InterfaceType get stackTraceType => _getRawType(stackTraceClass); |
169 | 267 |
170 /// Returns an instance of the `List` type defined in 'dart:core' with | 268 /// Returns an instance of the `List` type defined in 'dart:core' with |
171 /// [elementType] as its type argument. | 269 /// [elementType] as its type argument. |
172 /// | 270 /// |
173 /// If no type argument is provided, the canonical raw type is returned. | 271 /// If no type argument is provided, the canonical raw type is returned. |
174 InterfaceType listType([DartType elementType]); | 272 InterfaceType listType([DartType elementType]) { |
| 273 if (elementType == null) { |
| 274 return _getRawType(listClass); |
| 275 } |
| 276 return _createInterfaceType(listClass, [elementType]); |
| 277 } |
175 | 278 |
176 /// Returns an instance of the `Map` type defined in 'dart:core' with | 279 /// Returns an instance of the `Map` type defined in 'dart:core' with |
177 /// [keyType] and [valueType] as its type arguments. | 280 /// [keyType] and [valueType] as its type arguments. |
178 /// | 281 /// |
179 /// If no type arguments are provided, the canonical raw type is returned. | 282 /// If no type arguments are provided, the canonical raw type is returned. |
180 InterfaceType mapType([DartType keyType, DartType valueType]); | 283 InterfaceType mapType([DartType keyType, DartType valueType]) { |
| 284 if (keyType == null && valueType == null) { |
| 285 return _getRawType(mapClass); |
| 286 } else if (keyType == null) { |
| 287 keyType = dynamicType; |
| 288 } else if (valueType == null) { |
| 289 valueType = dynamicType; |
| 290 } |
| 291 return _createInterfaceType(mapClass, [keyType, valueType]); |
| 292 } |
181 | 293 |
182 /// Returns an instance of the `Iterable` type defined in 'dart:core' with | 294 /// Returns an instance of the `Iterable` type defined in 'dart:core' with |
183 /// [elementType] as its type argument. | 295 /// [elementType] as its type argument. |
184 /// | 296 /// |
185 /// If no type argument is provided, the canonical raw type is returned. | 297 /// If no type argument is provided, the canonical raw type is returned. |
186 InterfaceType iterableType([DartType elementType]); | 298 InterfaceType iterableType([DartType elementType]) { |
| 299 if (elementType == null) { |
| 300 return _getRawType(iterableClass); |
| 301 } |
| 302 return _createInterfaceType(iterableClass, [elementType]); |
| 303 } |
187 | 304 |
188 /// Returns an instance of the `Future` type defined in 'dart:async' with | 305 /// Returns an instance of the `Future` type defined in 'dart:async' with |
189 /// [elementType] as its type argument. | 306 /// [elementType] as its type argument. |
190 /// | 307 /// |
191 /// If no type argument is provided, the canonical raw type is returned. | 308 /// If no type argument is provided, the canonical raw type is returned. |
192 InterfaceType futureType([DartType elementType]); | 309 InterfaceType futureType([DartType elementType]) { |
| 310 if (elementType == null) { |
| 311 return _getRawType(futureClass); |
| 312 } |
| 313 return _createInterfaceType(futureClass, [elementType]); |
| 314 } |
193 | 315 |
194 /// Returns an instance of the `Stream` type defined in 'dart:async' with | 316 /// Returns an instance of the `Stream` type defined in 'dart:async' with |
195 /// [elementType] as its type argument. | 317 /// [elementType] as its type argument. |
196 /// | 318 /// |
197 /// If no type argument is provided, the canonical raw type is returned. | 319 /// If no type argument is provided, the canonical raw type is returned. |
198 InterfaceType streamType([DartType elementType]); | 320 InterfaceType streamType([DartType elementType]) { |
| 321 if (elementType == null) { |
| 322 return _getRawType(streamClass); |
| 323 } |
| 324 return _createInterfaceType(streamClass, [elementType]); |
| 325 } |
199 | 326 |
200 /// Returns `true` if [element] is a superclass of `String` or `num`. | 327 /// Returns `true` if [element] is a superclass of `String` or `num`. |
201 bool isNumberOrStringSupertype(ClassEntity element); | 328 // TODO(johnniwinther): Change types to `ClassEntity` when these are not |
| 329 // called with unrelated elements. |
| 330 bool isNumberOrStringSupertype(/*Class*/ Entity element) { |
| 331 return element == _findClass(coreLibrary, 'Comparable', required: false); |
| 332 } |
202 | 333 |
203 /// Returns `true` if [element] is a superclass of `String`. | 334 /// Returns `true` if [element] is a superclass of `String`. |
204 bool isStringOnlySupertype(ClassEntity element); | 335 // TODO(johnniwinther): Change types to `ClassEntity` when these are not |
| 336 // called with unrelated elements. |
| 337 bool isStringOnlySupertype(/*Class*/ Entity element) { |
| 338 return element == _findClass(coreLibrary, 'Pattern', required: false); |
| 339 } |
205 | 340 |
206 /// Returns `true` if [element] is a superclass of `List`. | 341 /// Returns `true` if [element] is a superclass of `List`. |
207 bool isListSupertype(ClassEntity element); | 342 bool isListSupertype(ClassEntity element) => element == iterableClass; |
| 343 |
| 344 ClassEntity _findClass(LibraryEntity library, String name, |
| 345 {bool required: true}) { |
| 346 if (library == null) return null; |
| 347 return _env.lookupClass(library, name, required: required); |
| 348 } |
| 349 |
| 350 MemberEntity _findLibraryMember(LibraryEntity library, String name, |
| 351 {bool setter: false, bool required: true}) { |
| 352 if (library == null) return null; |
| 353 return _env.lookupLibraryMember(library, name, |
| 354 setter: setter, required: required); |
| 355 } |
| 356 |
| 357 MemberEntity _findClassMember(ClassEntity cls, String name, |
| 358 {bool setter: false, bool required: true}) { |
| 359 return _env.lookupClassMember(cls, name, |
| 360 setter: setter, required: required); |
| 361 } |
| 362 |
| 363 ConstructorEntity _findConstructor(ClassEntity cls, String name, |
| 364 {bool required: true}) { |
| 365 return _env.lookupConstructor(cls, name, required: required); |
| 366 } |
| 367 |
| 368 /// Return the raw type of [cls]. |
| 369 InterfaceType _getRawType(ClassEntity cls) { |
| 370 return _env.getRawType(cls); |
| 371 } |
| 372 |
| 373 /// Create the instantiation of [cls] with the given [typeArguments]. |
| 374 InterfaceType _createInterfaceType( |
| 375 ClassEntity cls, List<DartType> typeArguments) { |
| 376 return _env.createInterfaceType(cls, typeArguments); |
| 377 } |
| 378 |
| 379 // From dart:core |
| 380 FunctionEntity get malformedTypeError => |
| 381 _cachedCoreHelper('_malformedTypeError'); |
| 382 FunctionEntity get genericNoSuchMethod => |
| 383 _cachedCoreHelper('_genericNoSuchMethod'); |
| 384 FunctionEntity get unresolvedConstructorError => |
| 385 _cachedCoreHelper('_unresolvedConstructorError'); |
| 386 FunctionEntity get unresolvedStaticGetterError => |
| 387 _cachedCoreHelper('_unresolvedStaticGetterError'); |
| 388 FunctionEntity get unresolvedStaticSetterError => |
| 389 _cachedCoreHelper('_unresolvedStaticSetterError'); |
| 390 FunctionEntity get unresolvedStaticMethodError => |
| 391 _cachedCoreHelper('_unresolvedStaticMethodError'); |
| 392 FunctionEntity get unresolvedTopLevelGetterError => |
| 393 _cachedCoreHelper('_unresolvedTopLevelGetterError'); |
| 394 FunctionEntity get unresolvedTopLevelSetterError => |
| 395 _cachedCoreHelper('_unresolvedTopLevelSetterError'); |
| 396 FunctionEntity get unresolvedTopLevelMethodError => |
| 397 _cachedCoreHelper('_unresolvedTopLevelMethodError'); |
| 398 |
| 399 Map<String, FunctionEntity> _cachedCoreHelpers = <String, FunctionEntity>{}; |
| 400 FunctionEntity _cachedCoreHelper(String name) => _cachedCoreHelpers[name] ??= |
| 401 _env.lookupLibraryMember(coreLibrary, name, required: true); |
| 402 |
| 403 FunctionEntity _objectEquals; |
| 404 FunctionEntity get objectEquals => |
| 405 _objectEquals ??= _findClassMember(objectClass, '=='); |
| 406 |
| 407 ClassEntity _mapLiteralClass; |
| 408 ClassEntity get mapLiteralClass { |
| 409 if (_mapLiteralClass == null) { |
| 410 _mapLiteralClass = _env.lookupClass(coreLibrary, 'LinkedHashMap'); |
| 411 if (_mapLiteralClass == null) { |
| 412 _mapLiteralClass = _findClass( |
| 413 _env.lookupLibrary(Uris.dart_collection), 'LinkedHashMap'); |
| 414 } |
| 415 } |
| 416 return _mapLiteralClass; |
| 417 } |
| 418 |
| 419 ConstructorEntity _mapLiteralConstructor; |
| 420 ConstructorEntity _mapLiteralConstructorEmpty; |
| 421 FunctionEntity _mapLiteralUntypedMaker; |
| 422 FunctionEntity _mapLiteralUntypedEmptyMaker; |
| 423 void _ensureMapLiteralHelpers() { |
| 424 if (_mapLiteralConstructor != null) return; |
| 425 |
| 426 _mapLiteralConstructor = |
| 427 _env.lookupConstructor(mapLiteralClass, '_literal'); |
| 428 _mapLiteralConstructorEmpty = |
| 429 _env.lookupConstructor(mapLiteralClass, '_empty'); |
| 430 _mapLiteralUntypedMaker = |
| 431 _env.lookupClassMember(mapLiteralClass, '_makeLiteral'); |
| 432 _mapLiteralUntypedEmptyMaker = |
| 433 _env.lookupClassMember(mapLiteralClass, '_makeEmpty'); |
| 434 } |
| 435 |
| 436 ConstructorEntity get mapLiteralConstructor { |
| 437 _ensureMapLiteralHelpers(); |
| 438 return _mapLiteralConstructor; |
| 439 } |
| 440 |
| 441 ConstructorEntity get mapLiteralConstructorEmpty { |
| 442 _ensureMapLiteralHelpers(); |
| 443 return _mapLiteralConstructorEmpty; |
| 444 } |
| 445 |
| 446 FunctionEntity get mapLiteralUntypedMaker { |
| 447 _ensureMapLiteralHelpers(); |
| 448 return _mapLiteralUntypedMaker; |
| 449 } |
| 450 |
| 451 FunctionEntity get mapLiteralUntypedEmptyMaker { |
| 452 _ensureMapLiteralHelpers(); |
| 453 return _mapLiteralUntypedEmptyMaker; |
| 454 } |
| 455 |
| 456 FunctionEntity _objectNoSuchMethod; |
| 457 FunctionEntity get objectNoSuchMethod { |
| 458 return _objectNoSuchMethod ??= |
| 459 _env.lookupClassMember(objectClass, Identifiers.noSuchMethod_); |
| 460 } |
| 461 |
| 462 bool isDefaultNoSuchMethodImplementation(FunctionEntity element) { |
| 463 ClassEntity classElement = element.enclosingClass; |
| 464 return classElement == objectClass || |
| 465 classElement == jsInterceptorClass || |
| 466 classElement == jsNullClass; |
| 467 } |
| 468 |
| 469 // From dart:async |
| 470 ClassEntity _findAsyncHelperClass(String name) => |
| 471 _findClass(asyncLibrary, name); |
| 472 |
| 473 FunctionEntity _findAsyncHelperFunction(String name) => |
| 474 _findLibraryMember(asyncLibrary, name); |
| 475 |
| 476 FunctionEntity get asyncHelper => _findAsyncHelperFunction("_asyncHelper"); |
| 477 |
| 478 FunctionEntity get wrapBody => |
| 479 _findAsyncHelperFunction("_wrapJsFunctionForAsync"); |
| 480 |
| 481 FunctionEntity get yieldStar => _env.lookupClassMember( |
| 482 _findAsyncHelperClass("_IterationMarker"), "yieldStar"); |
| 483 |
| 484 FunctionEntity get yieldSingle => _env.lookupClassMember( |
| 485 _findAsyncHelperClass("_IterationMarker"), "yieldSingle"); |
| 486 |
| 487 FunctionEntity get syncStarUncaughtError => _env.lookupClassMember( |
| 488 _findAsyncHelperClass("_IterationMarker"), "uncaughtError"); |
| 489 |
| 490 FunctionEntity get asyncStarHelper => |
| 491 _findAsyncHelperFunction("_asyncStarHelper"); |
| 492 |
| 493 FunctionEntity get streamOfController => |
| 494 _findAsyncHelperFunction("_streamOfController"); |
| 495 |
| 496 FunctionEntity get endOfIteration => _env.lookupClassMember( |
| 497 _findAsyncHelperClass("_IterationMarker"), "endOfIteration"); |
| 498 |
| 499 ClassEntity get syncStarIterable => |
| 500 _findAsyncHelperClass("_SyncStarIterable"); |
| 501 |
| 502 ClassEntity get futureImplementation => _findAsyncHelperClass('_Future'); |
| 503 |
| 504 ClassEntity get controllerStream => |
| 505 _findAsyncHelperClass("_ControllerStream"); |
| 506 |
| 507 ConstructorEntity get syncStarIterableConstructor => |
| 508 _env.lookupConstructor(syncStarIterable, ""); |
| 509 |
| 510 ConstructorEntity get syncCompleterConstructor => |
| 511 _env.lookupConstructor(_findAsyncHelperClass("Completer"), "sync"); |
| 512 |
| 513 ClassEntity get asyncStarController => |
| 514 _findAsyncHelperClass("_AsyncStarStreamController"); |
| 515 |
| 516 ConstructorEntity get asyncStarControllerConstructor => |
| 517 _env.lookupConstructor(asyncStarController, "", required: true); |
| 518 |
| 519 ConstructorEntity get streamIteratorConstructor => |
| 520 _env.lookupConstructor(_findAsyncHelperClass("StreamIterator"), ""); |
| 521 |
| 522 // From dart:mirrors |
| 523 FunctionEntity _findMirrorsFunction(String name) { |
| 524 LibraryEntity library = _env.lookupLibrary(Uris.dart__js_mirrors); |
| 525 if (library == null) return null; |
| 526 return _env.lookupLibraryMember(library, name, required: true); |
| 527 } |
| 528 |
| 529 /// Holds the method "disableTreeShaking" in js_mirrors when |
| 530 /// dart:mirrors has been loaded. |
| 531 FunctionEntity _disableTreeShakingMarker; |
| 532 FunctionEntity get disableTreeShakingMarker => |
| 533 _disableTreeShakingMarker ??= _findMirrorsFunction('disableTreeShaking'); |
| 534 |
| 535 /// Holds the method "preserveNames" in js_mirrors when |
| 536 /// dart:mirrors has been loaded. |
| 537 FunctionEntity _preserveNamesMarker; |
| 538 FunctionEntity get preserveNamesMarker { |
| 539 if (_preserveNamesMarker == null) { |
| 540 LibraryEntity library = _env.lookupLibrary(Uris.dart__js_names); |
| 541 if (library != null) { |
| 542 _preserveNamesMarker = _findLibraryMember(library, 'preserveNames'); |
| 543 } |
| 544 } |
| 545 return _preserveNamesMarker; |
| 546 } |
| 547 |
| 548 /// Holds the method "preserveMetadata" in js_mirrors when |
| 549 /// dart:mirrors has been loaded. |
| 550 FunctionEntity _preserveMetadataMarker; |
| 551 FunctionEntity get preserveMetadataMarker => |
| 552 _preserveMetadataMarker ??= _findMirrorsFunction('preserveMetadata'); |
| 553 |
| 554 /// Holds the method "preserveUris" in js_mirrors when |
| 555 /// dart:mirrors has been loaded. |
| 556 FunctionEntity _preserveUrisMarker; |
| 557 FunctionEntity get preserveUrisMarker => |
| 558 _preserveUrisMarker ??= _findMirrorsFunction('preserveUris'); |
| 559 |
| 560 /// Holds the method "preserveLibraryNames" in js_mirrors when |
| 561 /// dart:mirrors has been loaded. |
| 562 FunctionEntity _preserveLibraryNamesMarker; |
| 563 FunctionEntity get preserveLibraryNamesMarker => |
| 564 _preserveLibraryNamesMarker ??= |
| 565 _findMirrorsFunction('preserveLibraryNames'); |
| 566 |
| 567 // From dart:_interceptors |
| 568 ClassEntity _findInterceptorsClass(String name) => |
| 569 _findClass(interceptorsLibrary, name); |
| 570 |
| 571 FunctionEntity _findInterceptorsFunction(String name) => |
| 572 _findLibraryMember(interceptorsLibrary, name); |
| 573 |
| 574 ClassEntity _jsInterceptorClass; |
| 575 ClassEntity get jsInterceptorClass => |
| 576 _jsInterceptorClass ??= _findInterceptorsClass('Interceptor'); |
| 577 |
| 578 ClassEntity _jsStringClass; |
| 579 ClassEntity get jsStringClass => |
| 580 _jsStringClass ??= _findInterceptorsClass('JSString'); |
| 581 |
| 582 ClassEntity _jsArrayClass; |
| 583 ClassEntity get jsArrayClass => |
| 584 _jsArrayClass ??= _findInterceptorsClass('JSArray'); |
| 585 |
| 586 ClassEntity _jsNumberClass; |
| 587 ClassEntity get jsNumberClass => |
| 588 _jsNumberClass ??= _findInterceptorsClass('JSNumber'); |
| 589 |
| 590 ClassEntity _jsIntClass; |
| 591 ClassEntity get jsIntClass => _jsIntClass ??= _findInterceptorsClass('JSInt'); |
| 592 |
| 593 ClassEntity _jsDoubleClass; |
| 594 ClassEntity get jsDoubleClass => |
| 595 _jsDoubleClass ??= _findInterceptorsClass('JSDouble'); |
| 596 |
| 597 ClassEntity _jsNullClass; |
| 598 ClassEntity get jsNullClass => |
| 599 _jsNullClass ??= _findInterceptorsClass('JSNull'); |
| 600 |
| 601 ClassEntity _jsBoolClass; |
| 602 ClassEntity get jsBoolClass => |
| 603 _jsBoolClass ??= _findInterceptorsClass('JSBool'); |
| 604 |
| 605 ClassEntity _jsPlainJavaScriptObjectClass; |
| 606 ClassEntity get jsPlainJavaScriptObjectClass => |
| 607 _jsPlainJavaScriptObjectClass ??= |
| 608 _findInterceptorsClass('PlainJavaScriptObject'); |
| 609 |
| 610 ClassEntity _jsUnknownJavaScriptObjectClass; |
| 611 ClassEntity get jsUnknownJavaScriptObjectClass => |
| 612 _jsUnknownJavaScriptObjectClass ??= |
| 613 _findInterceptorsClass('UnknownJavaScriptObject'); |
| 614 |
| 615 ClassEntity _jsJavaScriptFunctionClass; |
| 616 ClassEntity get jsJavaScriptFunctionClass => _jsJavaScriptFunctionClass ??= |
| 617 _findInterceptorsClass('JavaScriptFunction'); |
| 618 |
| 619 ClassEntity _jsJavaScriptObjectClass; |
| 620 ClassEntity get jsJavaScriptObjectClass => |
| 621 _jsJavaScriptObjectClass ??= _findInterceptorsClass('JavaScriptObject'); |
| 622 |
| 623 ClassEntity _jsIndexableClass; |
| 624 ClassEntity get jsIndexableClass => |
| 625 _jsIndexableClass ??= _findInterceptorsClass('JSIndexable'); |
| 626 |
| 627 ClassEntity _jsMutableIndexableClass; |
| 628 ClassEntity get jsMutableIndexableClass => |
| 629 _jsMutableIndexableClass ??= _findInterceptorsClass('JSMutableIndexable'); |
| 630 |
| 631 ClassEntity _jsMutableArrayClass; |
| 632 ClassEntity get jsMutableArrayClass => |
| 633 _jsMutableArrayClass ??= _findInterceptorsClass('JSMutableArray'); |
| 634 |
| 635 ClassEntity _jsFixedArrayClass; |
| 636 ClassEntity get jsFixedArrayClass => |
| 637 _jsFixedArrayClass ??= _findInterceptorsClass('JSFixedArray'); |
| 638 |
| 639 ClassEntity _jsExtendableArrayClass; |
| 640 ClassEntity get jsExtendableArrayClass => |
| 641 _jsExtendableArrayClass ??= _findInterceptorsClass('JSExtendableArray'); |
| 642 |
| 643 ClassEntity _jsUnmodifiableArrayClass; |
| 644 ClassEntity get jsUnmodifiableArrayClass => _jsUnmodifiableArrayClass ??= |
| 645 _findInterceptorsClass('JSUnmodifiableArray'); |
| 646 |
| 647 ClassEntity _jsPositiveIntClass; |
| 648 ClassEntity get jsPositiveIntClass => |
| 649 _jsPositiveIntClass ??= _findInterceptorsClass('JSPositiveInt'); |
| 650 |
| 651 ClassEntity _jsUInt32Class; |
| 652 ClassEntity get jsUInt32Class => |
| 653 _jsUInt32Class ??= _findInterceptorsClass('JSUInt32'); |
| 654 |
| 655 ClassEntity _jsUInt31Class; |
| 656 ClassEntity get jsUInt31Class => |
| 657 _jsUInt31Class ??= _findInterceptorsClass('JSUInt31'); |
| 658 |
| 659 FunctionEntity _findIndexForNativeSubclassType; |
| 660 FunctionEntity get findIndexForNativeSubclassType => |
| 661 _findIndexForNativeSubclassType ??= _findLibraryMember( |
| 662 interceptorsLibrary, 'findIndexForNativeSubclassType'); |
| 663 |
| 664 FunctionEntity _getInterceptorMethod; |
| 665 FunctionEntity get getInterceptorMethod => |
| 666 _getInterceptorMethod ??= _findInterceptorsFunction('getInterceptor'); |
| 667 |
| 668 FunctionEntity _getNativeInterceptorMethod; |
| 669 FunctionEntity get getNativeInterceptorMethod => |
| 670 _getNativeInterceptorMethod ??= |
| 671 _findInterceptorsFunction('getNativeInterceptor'); |
| 672 |
| 673 MemberEntity _jsIndexableLength; |
| 674 MemberEntity get jsIndexableLength => |
| 675 _jsIndexableLength ??= _findClassMember(jsIndexableClass, 'length'); |
| 676 |
| 677 ConstructorEntity _jsArrayTypedConstructor; |
| 678 ConstructorEntity get jsArrayTypedConstructor => |
| 679 _jsArrayTypedConstructor ??= _findConstructor(jsArrayClass, 'typed'); |
| 680 |
| 681 FunctionEntity _jsArrayRemoveLast; |
| 682 FunctionEntity get jsArrayRemoveLast => |
| 683 _jsArrayRemoveLast ??= _findClassMember(jsArrayClass, 'removeLast'); |
| 684 |
| 685 FunctionEntity _jsArrayAdd; |
| 686 FunctionEntity get jsArrayAdd => |
| 687 _jsArrayAdd ??= _findClassMember(jsArrayClass, 'add'); |
| 688 |
| 689 FunctionEntity _jsStringSplit; |
| 690 FunctionEntity get jsStringSplit => |
| 691 _jsStringSplit ??= _findClassMember(jsStringClass, 'split'); |
| 692 |
| 693 FunctionEntity _jsStringToString; |
| 694 FunctionEntity get jsStringToString => |
| 695 _jsStringToString ??= _findClassMember(jsStringClass, 'toString'); |
| 696 |
| 697 FunctionEntity _jsStringOperatorAdd; |
| 698 FunctionEntity get jsStringOperatorAdd => |
| 699 _jsStringOperatorAdd ??= _findClassMember(jsStringClass, '+'); |
| 700 |
| 701 // From package:js |
| 702 ClassEntity _jsAnnotationClass; |
| 703 ClassEntity get jsAnnotationClass { |
| 704 if (_jsAnnotationClass == null) { |
| 705 LibraryEntity library = _env.lookupLibrary(Uris.package_js); |
| 706 if (library == null) return null; |
| 707 _jsAnnotationClass = _findClass(library, 'JS'); |
| 708 } |
| 709 return _jsAnnotationClass; |
| 710 } |
| 711 |
| 712 ClassEntity _jsAnonymousClass; |
| 713 ClassEntity get jsAnonymousClass { |
| 714 if (_jsAnonymousClass == null) { |
| 715 LibraryEntity library = _env.lookupLibrary(Uris.package_js); |
| 716 if (library == null) return null; |
| 717 _jsAnonymousClass = _findClass(library, '_Anonymous'); |
| 718 } |
| 719 return _jsAnonymousClass; |
| 720 } |
| 721 |
| 722 // From dart:_js_helper |
| 723 // TODO(johnniwinther): Avoid the need for this (from [CheckedModeHelper]). |
| 724 FunctionEntity findHelperFunction(String name) => _findHelperFunction(name); |
| 725 |
| 726 FunctionEntity _findHelperFunction(String name) => |
| 727 _findLibraryMember(jsHelperLibrary, name); |
| 728 |
| 729 ClassEntity _findHelperClass(String name) => |
| 730 _findClass(jsHelperLibrary, name); |
| 731 |
| 732 ClassEntity _closureClass; |
| 733 ClassEntity get closureClass => _closureClass ??= _findHelperClass('Closure'); |
| 734 |
| 735 ClassEntity _boundClosureClass; |
| 736 ClassEntity get boundClosureClass => |
| 737 _boundClosureClass ??= _findHelperClass('BoundClosure'); |
| 738 |
| 739 ClassEntity _typeLiteralClass; |
| 740 ClassEntity get typeLiteralClass => |
| 741 _typeLiteralClass ??= _findHelperClass('TypeImpl'); |
| 742 |
| 743 ClassEntity _constMapLiteralClass; |
| 744 ClassEntity get constMapLiteralClass => |
| 745 _constMapLiteralClass ??= _findHelperClass('ConstantMap'); |
| 746 |
| 747 ClassEntity _typeVariableClass; |
| 748 ClassEntity get typeVariableClass => |
| 749 _typeVariableClass ??= _findHelperClass('TypeVariable'); |
| 750 |
| 751 ClassEntity _noSideEffectsClass; |
| 752 ClassEntity get noSideEffectsClass => |
| 753 _noSideEffectsClass ??= _findHelperClass('NoSideEffects'); |
| 754 |
| 755 ClassEntity _noThrowsClass; |
| 756 ClassEntity get noThrowsClass => |
| 757 _noThrowsClass ??= _findHelperClass('NoThrows'); |
| 758 |
| 759 ClassEntity _noInlineClass; |
| 760 ClassEntity get noInlineClass => |
| 761 _noInlineClass ??= _findHelperClass('NoInline'); |
| 762 |
| 763 ClassEntity _forceInlineClass; |
| 764 ClassEntity get forceInlineClass => |
| 765 _forceInlineClass ??= _findHelperClass('ForceInline'); |
| 766 |
| 767 ClassEntity _irRepresentationClass; |
| 768 ClassEntity get irRepresentationClass => |
| 769 _irRepresentationClass ??= _findHelperClass('IrRepresentation'); |
| 770 |
| 771 ClassEntity _jsInvocationMirrorClass; |
| 772 ClassEntity get jsInvocationMirrorClass => |
| 773 _jsInvocationMirrorClass ??= _findHelperClass('JSInvocationMirror'); |
| 774 |
| 775 /// Interface used to determine if an object has the JavaScript |
| 776 /// indexing behavior. The interface is only visible to specific libraries. |
| 777 ClassEntity _jsIndexingBehaviorInterface; |
| 778 ClassEntity get jsIndexingBehaviorInterface => |
| 779 _jsIndexingBehaviorInterface ??= |
| 780 _findHelperClass('JavaScriptIndexingBehavior'); |
| 781 |
| 782 ClassEntity get VoidRuntimeType => _findHelperClass('VoidRuntimeType'); |
| 783 |
| 784 ClassEntity get stackTraceHelperClass => _findHelperClass('_StackTrace'); |
| 785 |
| 786 ClassEntity get constantMapClass => |
| 787 _findHelperClass(JavaScriptMapConstant.DART_CLASS); |
| 788 ClassEntity get constantStringMapClass => |
| 789 _findHelperClass(JavaScriptMapConstant.DART_STRING_CLASS); |
| 790 ClassEntity get constantProtoMapClass => |
| 791 _findHelperClass(JavaScriptMapConstant.DART_PROTO_CLASS); |
| 792 ClassEntity get generalConstantMapClass => |
| 793 _findHelperClass(JavaScriptMapConstant.DART_GENERAL_CLASS); |
| 794 |
| 795 ClassEntity get annotationCreatesClass => _findHelperClass('Creates'); |
| 796 |
| 797 ClassEntity get annotationReturnsClass => _findHelperClass('Returns'); |
| 798 |
| 799 ClassEntity get annotationJSNameClass => _findHelperClass('JSName'); |
| 800 |
| 801 /// The class for patch annotations defined in dart:_js_helper. |
| 802 ClassEntity _patchAnnotationClass; |
| 803 ClassEntity get patchAnnotationClass => |
| 804 _patchAnnotationClass ??= _findHelperClass('_Patch'); |
| 805 |
| 806 /// The class for native annotations defined in dart:_js_helper. |
| 807 ClassEntity _nativeAnnotationClass; |
| 808 ClassEntity get nativeAnnotationClass => |
| 809 _nativeAnnotationClass ??= _findHelperClass('Native'); |
| 810 |
| 811 ConstructorEntity _typeVariableConstructor; |
| 812 ConstructorEntity get typeVariableConstructor => _typeVariableConstructor ??= |
| 813 _env.lookupConstructor(typeVariableClass, ''); |
| 814 |
| 815 FunctionEntity _invokeOnMethod; |
| 816 FunctionEntity get invokeOnMethod => _invokeOnMethod ??= |
| 817 _env.lookupClassMember(jsInvocationMirrorClass, '_getCachedInvocation'); |
| 818 |
| 819 FunctionEntity _assertTest; |
| 820 FunctionEntity get assertTest => |
| 821 _assertTest ??= _findHelperFunction('assertTest'); |
| 822 |
| 823 FunctionEntity _assertThrow; |
| 824 FunctionEntity get assertThrow => |
| 825 _assertThrow ??= _findHelperFunction('assertThrow'); |
| 826 |
| 827 FunctionEntity _assertHelper; |
| 828 FunctionEntity get assertHelper => |
| 829 _assertHelper ??= _findHelperFunction('assertHelper'); |
| 830 |
| 831 FunctionEntity _assertUnreachableMethod; |
| 832 FunctionEntity get assertUnreachableMethod => |
| 833 _assertUnreachableMethod ??= _findHelperFunction('assertUnreachable'); |
| 834 |
| 835 /// Holds the method "getIsolateAffinityTag" when dart:_js_helper has been |
| 836 /// loaded. |
| 837 FunctionEntity _getIsolateAffinityTagMarker; |
| 838 FunctionEntity get getIsolateAffinityTagMarker => |
| 839 _getIsolateAffinityTagMarker ??= |
| 840 _findHelperFunction('getIsolateAffinityTag'); |
| 841 |
| 842 /// Holds the method "requiresPreamble" in _js_helper. |
| 843 FunctionEntity _requiresPreambleMarker; |
| 844 FunctionEntity get requiresPreambleMarker => |
| 845 _requiresPreambleMarker ??= _findHelperFunction('requiresPreamble'); |
| 846 |
| 847 FunctionEntity get badMain => _findHelperFunction('badMain'); |
| 848 |
| 849 FunctionEntity get missingMain => _findHelperFunction('missingMain'); |
| 850 |
| 851 FunctionEntity get mainHasTooManyParameters => |
| 852 _findHelperFunction('mainHasTooManyParameters'); |
| 853 |
| 854 FunctionEntity get loadLibraryWrapper => |
| 855 _findHelperFunction("_loadLibraryWrapper"); |
| 856 |
| 857 FunctionEntity get boolConversionCheck => |
| 858 _findHelperFunction('boolConversionCheck'); |
| 859 |
| 860 FunctionEntity get _consoleTraceHelper => |
| 861 _findHelperFunction('consoleTraceHelper'); |
| 862 |
| 863 FunctionEntity get _postTraceHelper => _findHelperFunction('postTraceHelper'); |
| 864 |
| 865 FunctionEntity _traceHelper; |
| 866 FunctionEntity get traceHelper { |
| 867 return _traceHelper ??= JavaScriptBackend.TRACE_METHOD == 'console' |
| 868 ? _consoleTraceHelper |
| 869 : _postTraceHelper; |
| 870 } |
| 871 |
| 872 FunctionEntity get closureFromTearOff => |
| 873 _findHelperFunction('closureFromTearOff'); |
| 874 |
| 875 FunctionEntity get isJsIndexable => _findHelperFunction('isJsIndexable'); |
| 876 |
| 877 FunctionEntity get throwIllegalArgumentException => |
| 878 _findHelperFunction('iae'); |
| 879 |
| 880 FunctionEntity get throwIndexOutOfRangeException => |
| 881 _findHelperFunction('ioore'); |
| 882 |
| 883 FunctionEntity get exceptionUnwrapper => |
| 884 _findHelperFunction('unwrapException'); |
| 885 |
| 886 FunctionEntity get throwRuntimeError => |
| 887 _findHelperFunction('throwRuntimeError'); |
| 888 |
| 889 FunctionEntity get throwTypeError => _findHelperFunction('throwTypeError'); |
| 890 |
| 891 FunctionEntity get throwAbstractClassInstantiationError => |
| 892 _findHelperFunction('throwAbstractClassInstantiationError'); |
| 893 |
| 894 FunctionEntity _cachedCheckConcurrentModificationError; |
| 895 FunctionEntity get checkConcurrentModificationError => |
| 896 _cachedCheckConcurrentModificationError ??= |
| 897 _findHelperFunction('checkConcurrentModificationError'); |
| 898 |
| 899 FunctionEntity get throwConcurrentModificationError => |
| 900 _findHelperFunction('throwConcurrentModificationError'); |
| 901 |
| 902 FunctionEntity _checkInt; |
| 903 FunctionEntity get checkInt => _checkInt ??= _findHelperFunction('checkInt'); |
| 904 |
| 905 FunctionEntity _checkNum; |
| 906 FunctionEntity get checkNum => _checkNum ??= _findHelperFunction('checkNum'); |
| 907 |
| 908 FunctionEntity _checkString; |
| 909 FunctionEntity get checkString => |
| 910 _checkString ??= _findHelperFunction('checkString'); |
| 911 |
| 912 FunctionEntity get stringInterpolationHelper => _findHelperFunction('S'); |
| 913 |
| 914 FunctionEntity get wrapExceptionHelper => |
| 915 _findHelperFunction('wrapException'); |
| 916 |
| 917 FunctionEntity get throwExpressionHelper => |
| 918 _findHelperFunction('throwExpression'); |
| 919 |
| 920 FunctionEntity get closureConverter => |
| 921 _findHelperFunction('convertDartClosureToJS'); |
| 922 |
| 923 FunctionEntity get traceFromException => |
| 924 _findHelperFunction('getTraceFromException'); |
| 925 |
| 926 FunctionEntity get setRuntimeTypeInfo => |
| 927 _findHelperFunction('setRuntimeTypeInfo'); |
| 928 |
| 929 FunctionEntity get getRuntimeTypeInfo => |
| 930 _findHelperFunction('getRuntimeTypeInfo'); |
| 931 |
| 932 FunctionEntity get getTypeArgumentByIndex => |
| 933 _findHelperFunction('getTypeArgumentByIndex'); |
| 934 |
| 935 FunctionEntity get computeSignature => |
| 936 _findHelperFunction('computeSignature'); |
| 937 |
| 938 FunctionEntity get getRuntimeTypeArguments => |
| 939 _findHelperFunction('getRuntimeTypeArguments'); |
| 940 |
| 941 FunctionEntity get getRuntimeTypeArgument => |
| 942 _findHelperFunction('getRuntimeTypeArgument'); |
| 943 |
| 944 FunctionEntity get runtimeTypeToString => |
| 945 _findHelperFunction('runtimeTypeToString'); |
| 946 |
| 947 FunctionEntity get assertIsSubtype => _findHelperFunction('assertIsSubtype'); |
| 948 |
| 949 FunctionEntity get checkSubtype => _findHelperFunction('checkSubtype'); |
| 950 |
| 951 FunctionEntity get assertSubtype => _findHelperFunction('assertSubtype'); |
| 952 |
| 953 FunctionEntity get subtypeCast => _findHelperFunction('subtypeCast'); |
| 954 |
| 955 FunctionEntity get functionTypeTest => |
| 956 _findHelperFunction('functionTypeTest'); |
| 957 |
| 958 FunctionEntity get checkSubtypeOfRuntimeType => |
| 959 _findHelperFunction('checkSubtypeOfRuntimeType'); |
| 960 |
| 961 FunctionEntity get assertSubtypeOfRuntimeType => |
| 962 _findHelperFunction('assertSubtypeOfRuntimeType'); |
| 963 |
| 964 FunctionEntity get subtypeOfRuntimeTypeCast => |
| 965 _findHelperFunction('subtypeOfRuntimeTypeCast'); |
| 966 |
| 967 FunctionEntity get checkDeferredIsLoaded => |
| 968 _findHelperFunction('checkDeferredIsLoaded'); |
| 969 |
| 970 FunctionEntity get throwNoSuchMethod => |
| 971 _findHelperFunction('throwNoSuchMethod'); |
| 972 |
| 973 FunctionEntity get createRuntimeType => |
| 974 _findHelperFunction('createRuntimeType'); |
| 975 |
| 976 FunctionEntity get fallThroughError => |
| 977 _findHelperFunction("getFallThroughError"); |
| 978 |
| 979 FunctionEntity get createInvocationMirror => |
| 980 _findHelperFunction('createInvocationMirror'); |
| 981 |
| 982 FunctionEntity get cyclicThrowHelper => |
| 983 _findHelperFunction("throwCyclicInit"); |
| 984 |
| 985 FunctionEntity get defineProperty => _findHelperFunction('defineProperty'); |
| 986 |
| 987 FunctionEntity get convertRtiToRuntimeType => |
| 988 _findHelperFunction('convertRtiToRuntimeType'); |
| 989 |
| 990 FunctionEntity get toStringForNativeObject => |
| 991 _findHelperFunction('toStringForNativeObject'); |
| 992 |
| 993 FunctionEntity get hashCodeForNativeObject => |
| 994 _findHelperFunction('hashCodeForNativeObject'); |
| 995 |
| 996 // From dart:_internal |
| 997 |
| 998 ClassEntity _symbolImplementationClass; |
| 999 ClassEntity get symbolImplementationClass => |
| 1000 _symbolImplementationClass ??= _findClass(internalLibrary, 'Symbol'); |
| 1001 |
| 1002 final Selector symbolValidatedConstructorSelector = |
| 1003 new Selector.call(const PublicName('validated'), CallStructure.ONE_ARG); |
| 1004 |
| 1005 ConstructorEntity get symbolValidatedConstructor => |
| 1006 _symbolValidatedConstructor ??= _findConstructor( |
| 1007 symbolImplementationClass, symbolValidatedConstructorSelector.name); |
| 1008 |
| 1009 /// Returns the field that holds the internal name in the implementation class |
| 1010 /// for `Symbol`. |
| 1011 FieldEntity _symbolImplementationField; |
| 1012 FieldEntity get symbolImplementationField => _symbolImplementationField ??= |
| 1013 _env.lookupClassMember(symbolImplementationClass, '_name', |
| 1014 required: true); |
| 1015 |
| 1016 ConstructorEntity _symbolValidatedConstructor; |
| 1017 bool isSymbolValidatedConstructor(ConstructorEntity element) { |
| 1018 if (_symbolValidatedConstructor != null) { |
| 1019 return element == _symbolValidatedConstructor; |
| 1020 } |
| 1021 return false; |
| 1022 } |
| 1023 |
| 1024 // From dart:_native_typed_data |
| 1025 |
| 1026 ClassEntity _typedArrayClass; |
| 1027 ClassEntity get typedArrayClass => _typedArrayClass ??= _findClass( |
| 1028 _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
| 1029 'NativeTypedArray'); |
| 1030 |
| 1031 ClassEntity _typedArrayOfIntClass; |
| 1032 ClassEntity get typedArrayOfIntClass => _typedArrayOfIntClass ??= _findClass( |
| 1033 _env.lookupLibrary(Uris.dart__native_typed_data, required: true), |
| 1034 'NativeTypedArrayOfInt'); |
| 1035 |
| 1036 // From dart:_js_embedded_names |
| 1037 |
| 1038 /// Holds the class for the [JsGetName] enum. |
| 1039 ClassEntity _jsGetNameEnum; |
| 1040 ClassEntity get jsGetNameEnum => _jsGetNameEnum ??= _findClass( |
| 1041 _env.lookupLibrary(Uris.dart__js_embedded_names, required: true), |
| 1042 'JsGetName'); |
| 1043 |
| 1044 /// Holds the class for the [JsBuiltins] enum. |
| 1045 ClassEntity _jsBuiltinEnum; |
| 1046 ClassEntity get jsBuiltinEnum => _jsBuiltinEnum ??= _findClass( |
| 1047 _env.lookupLibrary(Uris.dart__js_embedded_names, required: true), |
| 1048 'JsBuiltin'); |
| 1049 |
| 1050 // From dart:_isolate_helper |
| 1051 |
| 1052 FunctionEntity get startRootIsolate => |
| 1053 _findLibraryMember(isolateHelperLibrary, 'startRootIsolate'); |
| 1054 |
| 1055 FunctionEntity get currentIsolate => |
| 1056 _findLibraryMember(isolateHelperLibrary, '_currentIsolate'); |
| 1057 |
| 1058 FunctionEntity get callInIsolate => |
| 1059 _findLibraryMember(isolateHelperLibrary, '_callInIsolate'); |
208 } | 1060 } |
209 | 1061 |
210 /// Interface for accessing libraries, classes and members. | 1062 /// Interface for accessing libraries, classes and members. |
211 /// | 1063 /// |
212 /// The _env makes private and injected members directly available and | 1064 /// The _env makes private and injected members directly available and |
213 /// should therefore not be used to determine scopes. | 1065 /// should therefore not be used to determine scopes. |
214 // TODO(johnniwinther): Split this into an element environment and a type query | 1066 // TODO(johnniwinther): Split this into an element environment and a type query |
215 // interface, the first should only be used during resolution and the latter in | 1067 // interface, the first should only be used during resolution and the latter in |
216 // both resolution and codegen. | 1068 // both resolution and codegen. |
217 abstract class ElementEnvironment { | 1069 abstract class ElementEnvironment { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 DartType getUnaliasedType(DartType type); | 1163 DartType getUnaliasedType(DartType type); |
312 | 1164 |
313 /// Returns the [CallStructure] corresponding to calling [entity] with all | 1165 /// Returns the [CallStructure] corresponding to calling [entity] with all |
314 /// arguments, both required and optional. | 1166 /// arguments, both required and optional. |
315 CallStructure getCallStructure(FunctionEntity entity); | 1167 CallStructure getCallStructure(FunctionEntity entity); |
316 | 1168 |
317 /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected | 1169 /// Returns `true` if [member] a the synthetic getter `loadLibrary` injected |
318 /// on deferred libraries. | 1170 /// on deferred libraries. |
319 bool isDeferredLoadLibraryGetter(MemberEntity member); | 1171 bool isDeferredLoadLibraryGetter(MemberEntity member); |
320 } | 1172 } |
321 | |
322 class CommonElementsImpl implements CommonElements { | |
323 final ElementEnvironment _env; | |
324 | |
325 CommonElementsImpl(this._env); | |
326 | |
327 ClassEntity findClass(LibraryEntity library, String name, | |
328 {bool required: true}) { | |
329 if (library == null) return null; | |
330 return _env.lookupClass(library, name, required: required); | |
331 } | |
332 | |
333 MemberEntity findLibraryMember(LibraryEntity library, String name, | |
334 {bool setter: false, bool required: true}) { | |
335 if (library == null) return null; | |
336 return _env.lookupLibraryMember(library, name, | |
337 setter: setter, required: required); | |
338 } | |
339 | |
340 MemberEntity findClassMember(ClassEntity cls, String name, | |
341 {bool setter: false, bool required: true}) { | |
342 return _env.lookupClassMember(cls, name, | |
343 setter: setter, required: required); | |
344 } | |
345 | |
346 ConstructorEntity findConstructor(ClassEntity cls, String name, | |
347 {bool required: true}) { | |
348 return _env.lookupConstructor(cls, name, required: required); | |
349 } | |
350 | |
351 DartType get dynamicType => _env.dynamicType; | |
352 | |
353 /// Return the raw type of [cls]. | |
354 InterfaceType getRawType(ClassEntity cls) { | |
355 return _env.getRawType(cls); | |
356 } | |
357 | |
358 /// Create the instantiation of [cls] with the given [typeArguments]. | |
359 InterfaceType createInterfaceType( | |
360 ClassEntity cls, List<DartType> typeArguments) { | |
361 return _env.createInterfaceType(cls, typeArguments); | |
362 } | |
363 | |
364 LibraryEntity _coreLibrary; | |
365 LibraryEntity get coreLibrary => | |
366 _coreLibrary ??= _env.lookupLibrary(Uris.dart_core, required: true); | |
367 | |
368 LibraryEntity _typedDataLibrary; | |
369 LibraryEntity get typedDataLibrary => | |
370 _typedDataLibrary ??= _env.lookupLibrary(Uris.dart__native_typed_data); | |
371 | |
372 LibraryEntity _mirrorsLibrary; | |
373 LibraryEntity get mirrorsLibrary => | |
374 _mirrorsLibrary ??= _env.lookupLibrary(Uris.dart_mirrors); | |
375 | |
376 LibraryEntity _asyncLibrary; | |
377 LibraryEntity get asyncLibrary => | |
378 _asyncLibrary ??= _env.lookupLibrary(Uris.dart_async); | |
379 | |
380 // From dart:core | |
381 | |
382 ClassEntity _objectClass; | |
383 ClassEntity get objectClass => | |
384 _objectClass ??= findClass(coreLibrary, 'Object'); | |
385 | |
386 ClassEntity _boolClass; | |
387 ClassEntity get boolClass => _boolClass ??= findClass(coreLibrary, 'bool'); | |
388 | |
389 ClassEntity _numClass; | |
390 ClassEntity get numClass => _numClass ??= findClass(coreLibrary, 'num'); | |
391 | |
392 ClassEntity _intClass; | |
393 ClassEntity get intClass => _intClass ??= findClass(coreLibrary, 'int'); | |
394 | |
395 ClassEntity _doubleClass; | |
396 ClassEntity get doubleClass => | |
397 _doubleClass ??= findClass(coreLibrary, 'double'); | |
398 | |
399 ClassEntity _stringClass; | |
400 ClassEntity get stringClass => | |
401 _stringClass ??= findClass(coreLibrary, 'String'); | |
402 | |
403 ClassEntity _functionClass; | |
404 ClassEntity get functionClass => | |
405 _functionClass ??= findClass(coreLibrary, 'Function'); | |
406 | |
407 FunctionEntity _functionApplyMethod; | |
408 FunctionEntity get functionApplyMethod => | |
409 _functionApplyMethod ??= findClassMember(functionClass, 'apply'); | |
410 | |
411 bool isFunctionApplyMethod(MemberEntity element) => | |
412 element.name == 'apply' && element.enclosingClass == functionClass; | |
413 | |
414 ClassEntity _nullClass; | |
415 ClassEntity get nullClass => _nullClass ??= findClass(coreLibrary, 'Null'); | |
416 | |
417 ClassEntity _listClass; | |
418 ClassEntity get listClass => _listClass ??= findClass(coreLibrary, 'List'); | |
419 | |
420 ClassEntity _typeClass; | |
421 ClassEntity get typeClass => _typeClass ??= findClass(coreLibrary, 'Type'); | |
422 | |
423 ClassEntity _mapClass; | |
424 ClassEntity get mapClass => _mapClass ??= findClass(coreLibrary, 'Map'); | |
425 | |
426 ClassEntity _symbolClass; | |
427 ClassEntity get symbolClass => | |
428 _symbolClass ??= findClass(coreLibrary, 'Symbol'); | |
429 | |
430 ConstructorEntity _symbolConstructor; | |
431 ConstructorEntity get symbolConstructor => | |
432 // TODO(johnniwinther): Kernel does not include redirecting factories | |
433 // so this cannot be found in kernel. Find a consistent way to handle | |
434 // this and similar cases. | |
435 _symbolConstructor ??= findConstructor(symbolClass, '', required: false); | |
436 | |
437 bool isSymbolConstructor(Entity e) => e == symbolConstructor; | |
438 | |
439 ClassEntity _stackTraceClass; | |
440 ClassEntity get stackTraceClass => | |
441 _stackTraceClass ??= findClass(coreLibrary, 'StackTrace'); | |
442 | |
443 ClassEntity _iterableClass; | |
444 ClassEntity get iterableClass => | |
445 _iterableClass ??= findClass(coreLibrary, 'Iterable'); | |
446 | |
447 ClassEntity _resourceClass; | |
448 ClassEntity get resourceClass => | |
449 _resourceClass ??= findClass(coreLibrary, 'Resource'); | |
450 | |
451 FunctionEntity _identicalFunction; | |
452 FunctionEntity get identicalFunction => | |
453 _identicalFunction ??= findLibraryMember(coreLibrary, 'identical'); | |
454 | |
455 // From dart:async | |
456 | |
457 ClassEntity _futureClass; | |
458 ClassEntity get futureClass => | |
459 _futureClass ??= findClass(asyncLibrary, 'Future'); | |
460 | |
461 ClassEntity _streamClass; | |
462 ClassEntity get streamClass => | |
463 _streamClass ??= findClass(asyncLibrary, 'Stream'); | |
464 | |
465 ClassEntity _deferredLibraryClass; | |
466 ClassEntity get deferredLibraryClass => | |
467 _deferredLibraryClass ??= findClass(asyncLibrary, "DeferredLibrary"); | |
468 | |
469 // From dart:mirrors | |
470 | |
471 ClassEntity _mirrorSystemClass; | |
472 ClassEntity get mirrorSystemClass => _mirrorSystemClass ??= | |
473 findClass(mirrorsLibrary, 'MirrorSystem', required: false); | |
474 | |
475 FunctionEntity _mirrorSystemGetNameFunction; | |
476 bool isMirrorSystemGetNameFunction(MemberEntity element) { | |
477 if (_mirrorSystemGetNameFunction == null) { | |
478 if (!element.isFunction || mirrorsLibrary == null) return false; | |
479 ClassEntity cls = mirrorSystemClass; | |
480 if (element.enclosingClass != cls) return false; | |
481 if (cls != null) { | |
482 _mirrorSystemGetNameFunction = | |
483 findClassMember(cls, 'getName', required: false); | |
484 } | |
485 } | |
486 return element == _mirrorSystemGetNameFunction; | |
487 } | |
488 | |
489 ClassEntity _mirrorsUsedClass; | |
490 ClassEntity get mirrorsUsedClass => _mirrorsUsedClass ??= | |
491 findClass(mirrorsLibrary, 'MirrorsUsed', required: false); | |
492 | |
493 bool isMirrorsUsedConstructor(ConstructorEntity element) => | |
494 mirrorsLibrary != null && mirrorsUsedClass == element.enclosingClass; | |
495 | |
496 // From dart:typed_data | |
497 | |
498 ClassEntity _typedDataClass; | |
499 ClassEntity get typedDataClass => | |
500 _typedDataClass ??= findClass(typedDataLibrary, 'NativeTypedData'); | |
501 | |
502 bool isUnnamedListConstructor(ConstructorEntity element) => | |
503 element.name == '' && element.enclosingClass == listClass; | |
504 | |
505 bool isFilledListConstructor(ConstructorEntity element) => | |
506 element.name == 'filled' && element.enclosingClass == listClass; | |
507 | |
508 // TODO(johnniwinther): Change types to `ClassEntity` when these are not | |
509 // called with unrelated elements. | |
510 bool isNumberOrStringSupertype(/*Class*/ Entity element) { | |
511 return element == findClass(coreLibrary, 'Comparable', required: false); | |
512 } | |
513 | |
514 bool isStringOnlySupertype(/*Class*/ Entity element) { | |
515 return element == findClass(coreLibrary, 'Pattern', required: false); | |
516 } | |
517 | |
518 bool isListSupertype(/*Class*/ Entity element) => element == iterableClass; | |
519 | |
520 @override | |
521 InterfaceType get objectType => getRawType(objectClass); | |
522 | |
523 @override | |
524 InterfaceType get boolType => getRawType(boolClass); | |
525 | |
526 @override | |
527 InterfaceType get doubleType => getRawType(doubleClass); | |
528 | |
529 @override | |
530 InterfaceType get functionType => getRawType(functionClass); | |
531 | |
532 @override | |
533 InterfaceType get intType => getRawType(intClass); | |
534 | |
535 @override | |
536 InterfaceType get resourceType => getRawType(resourceClass); | |
537 | |
538 @override | |
539 InterfaceType listType([DartType elementType]) { | |
540 if (elementType == null) { | |
541 return getRawType(listClass); | |
542 } | |
543 return createInterfaceType(listClass, [elementType]); | |
544 } | |
545 | |
546 @override | |
547 InterfaceType mapType([DartType keyType, DartType valueType]) { | |
548 if (keyType == null && valueType == null) { | |
549 return getRawType(mapClass); | |
550 } else if (keyType == null) { | |
551 keyType = dynamicType; | |
552 } else if (valueType == null) { | |
553 valueType = dynamicType; | |
554 } | |
555 return createInterfaceType(mapClass, [keyType, valueType]); | |
556 } | |
557 | |
558 @override | |
559 InterfaceType get nullType => getRawType(nullClass); | |
560 | |
561 @override | |
562 InterfaceType get numType => getRawType(numClass); | |
563 | |
564 @override | |
565 InterfaceType get stringType => getRawType(stringClass); | |
566 | |
567 @override | |
568 InterfaceType get symbolType => getRawType(symbolClass); | |
569 | |
570 @override | |
571 InterfaceType get typeType => getRawType(typeClass); | |
572 | |
573 @override | |
574 InterfaceType get stackTraceType => getRawType(stackTraceClass); | |
575 | |
576 @override | |
577 InterfaceType iterableType([DartType elementType]) { | |
578 if (elementType == null) { | |
579 return getRawType(iterableClass); | |
580 } | |
581 return createInterfaceType(iterableClass, [elementType]); | |
582 } | |
583 | |
584 @override | |
585 InterfaceType futureType([DartType elementType]) { | |
586 if (elementType == null) { | |
587 return getRawType(futureClass); | |
588 } | |
589 return createInterfaceType(futureClass, [elementType]); | |
590 } | |
591 | |
592 @override | |
593 InterfaceType streamType([DartType elementType]) { | |
594 if (elementType == null) { | |
595 return getRawType(streamClass); | |
596 } | |
597 return createInterfaceType(streamClass, [elementType]); | |
598 } | |
599 } | |
OLD | NEW |