OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 dart2js.js_model.elements; | 5 library dart2js.js_model.elements; |
6 | 6 |
7 import '../common_elements.dart'; | 7 import '../common_elements.dart'; |
8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../constants/values.dart'; |
9 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
10 import '../elements/entities.dart'; | 11 import '../elements/entities.dart'; |
| 12 import '../elements/names.dart'; |
11 import '../elements/types.dart'; | 13 import '../elements/types.dart'; |
12 import '../js_backend/backend_usage.dart'; | 14 import '../js_backend/backend_usage.dart'; |
13 import '../js_backend/interceptor_data.dart'; | 15 import '../js_backend/interceptor_data.dart'; |
14 import '../js_backend/native_data.dart'; | 16 import '../js_backend/native_data.dart'; |
15 import '../native/behavior.dart'; | 17 import '../native/behavior.dart'; |
16 import '../ordered_typeset.dart'; | 18 import '../ordered_typeset.dart'; |
17 import '../universe/class_set.dart'; | 19 import '../universe/class_set.dart'; |
18 import '../universe/function_set.dart'; | 20 import '../universe/function_set.dart'; |
19 import '../universe/selector.dart'; | 21 import '../universe/selector.dart'; |
20 import '../universe/world_builder.dart'; | 22 import '../universe/world_builder.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
32 LibraryEntity toBackendLibrary(LibraryEntity library) => library; | 34 LibraryEntity toBackendLibrary(LibraryEntity library) => library; |
33 LibraryEntity toFrontendLibrary(LibraryEntity library) => library; | 35 LibraryEntity toFrontendLibrary(LibraryEntity library) => library; |
34 | 36 |
35 ClassEntity toBackendClass(ClassEntity cls) => cls; | 37 ClassEntity toBackendClass(ClassEntity cls) => cls; |
36 ClassEntity toFrontendClass(ClassEntity cls) => cls; | 38 ClassEntity toFrontendClass(ClassEntity cls) => cls; |
37 | 39 |
38 MemberEntity toBackendMember(MemberEntity member) => member; | 40 MemberEntity toBackendMember(MemberEntity member) => member; |
39 MemberEntity toFrontendMember(MemberEntity member) => member; | 41 MemberEntity toFrontendMember(MemberEntity member) => member; |
40 | 42 |
41 DartType toBackendType(DartType type) => type; | 43 DartType toBackendType(DartType type) => type; |
42 DartType fromFrontendType(DartType type) => type; | 44 DartType toFrontendType(DartType type) => type; |
| 45 } |
| 46 |
| 47 class JsToFrontendMapImpl implements JsToFrontendMap { |
| 48 final Map<LibraryEntity, LibraryEntity> _toBackendLibrary = |
| 49 <LibraryEntity, LibraryEntity>{}; |
| 50 final List<LibraryEntity> _frontendLibraryList = <LibraryEntity>[]; |
| 51 |
| 52 LibraryEntity toBackendLibrary(LibraryEntity library) { |
| 53 return _toBackendLibrary.putIfAbsent(library, () { |
| 54 JLibrary newLibrary = new JLibrary( |
| 55 _toBackendLibrary.length, library.name, library.canonicalUri); |
| 56 _frontendLibraryList.add(library); |
| 57 return newLibrary; |
| 58 }); |
| 59 } |
| 60 |
| 61 LibraryEntity toFrontendLibrary(JLibrary library) => |
| 62 _frontendLibraryList[library.libraryIndex]; |
| 63 |
| 64 final Map<ClassEntity, ClassEntity> _toBackendClass = |
| 65 <ClassEntity, ClassEntity>{}; |
| 66 final List<ClassEntity> _frontendClassList = <ClassEntity>[]; |
| 67 |
| 68 ClassEntity toBackendClass(ClassEntity cls) { |
| 69 return _toBackendClass.putIfAbsent(cls, () { |
| 70 LibraryEntity library = toBackendLibrary(cls.library); |
| 71 JClass newClass = new JClass(library, _toBackendClass.length, cls.name, |
| 72 isAbstract: cls.isAbstract); |
| 73 _frontendClassList.add(cls); |
| 74 return newClass; |
| 75 }); |
| 76 } |
| 77 |
| 78 ClassEntity toFrontendClass(JClass cls) => _frontendClassList[cls.classIndex]; |
| 79 |
| 80 final Map<MemberEntity, MemberEntity> _toBackendMember = |
| 81 <MemberEntity, MemberEntity>{}; |
| 82 final List<MemberEntity> _frontendMemberList = <MemberEntity>[]; |
| 83 |
| 84 MemberEntity toBackendMember(MemberEntity member) { |
| 85 return _toBackendMember.putIfAbsent(member, () { |
| 86 LibraryEntity library = toBackendLibrary(member.library); |
| 87 ClassEntity cls; |
| 88 if (member.enclosingClass != null) { |
| 89 cls = toBackendClass(member.enclosingClass); |
| 90 } |
| 91 |
| 92 JMember newMember; |
| 93 Name memberName = new Name(member.memberName.text, library, |
| 94 isSetter: member.memberName.isSetter); |
| 95 if (member.isField) { |
| 96 FieldEntity field = member; |
| 97 newMember = new JField( |
| 98 _toBackendMember.length, library, cls, memberName, |
| 99 isStatic: field.isStatic, |
| 100 isAssignable: field.isAssignable, |
| 101 isConst: field.isConst); |
| 102 } else if (member.isConstructor) { |
| 103 ConstructorEntity constructor = member; |
| 104 if (constructor.isFactoryConstructor) { |
| 105 // TODO(johnniwinther): This should be a JFunction. |
| 106 newMember = new JFactoryConstructor(_toBackendMember.length, cls, |
| 107 memberName, constructor.parameterStructure, |
| 108 isExternal: constructor.isExternal, |
| 109 isConst: constructor.isConst, |
| 110 isFromEnvironmentConstructor: |
| 111 constructor.isFromEnvironmentConstructor); |
| 112 } else { |
| 113 newMember = new JGenerativeConstructor(_toBackendMember.length, cls, |
| 114 memberName, constructor.parameterStructure, |
| 115 isExternal: constructor.isExternal, isConst: constructor.isConst); |
| 116 } |
| 117 } else if (member.isGetter) { |
| 118 FunctionEntity getter = member; |
| 119 newMember = new JGetter(_toBackendMember.length, library, cls, |
| 120 memberName, getter.asyncMarker, |
| 121 isStatic: getter.isStatic, |
| 122 isExternal: getter.isExternal, |
| 123 isAbstract: getter.isAbstract); |
| 124 } else if (member.isSetter) { |
| 125 FunctionEntity setter = member; |
| 126 newMember = new JSetter( |
| 127 _toBackendMember.length, library, cls, memberName, |
| 128 isStatic: setter.isStatic, |
| 129 isExternal: setter.isExternal, |
| 130 isAbstract: setter.isAbstract); |
| 131 } else { |
| 132 FunctionEntity function = member; |
| 133 newMember = new JMethod(_toBackendMember.length, library, cls, |
| 134 memberName, function.parameterStructure, function.asyncMarker, |
| 135 isStatic: function.isStatic, |
| 136 isExternal: function.isExternal, |
| 137 isAbstract: function.isAbstract); |
| 138 } |
| 139 _frontendMemberList.add(member); |
| 140 return newMember; |
| 141 }); |
| 142 } |
| 143 |
| 144 MemberEntity toFrontendMember(JMember member) => |
| 145 _frontendMemberList[member.memberIndex]; |
| 146 |
| 147 DartType toBackendType(DartType type) => |
| 148 const TypeConverter().visit(type, _toBackendEntity); |
| 149 DartType toFrontendType(DartType type) => |
| 150 const TypeConverter().visit(type, _toFrontendEntity); |
| 151 |
| 152 Entity _toBackendEntity(Entity entity) { |
| 153 if (entity is ClassEntity) return toBackendClass(entity); |
| 154 assert(entity is TypeVariableEntity); |
| 155 return _toBackendTypeVariable(entity); |
| 156 } |
| 157 |
| 158 final Map<TypeVariableEntity, TypeVariableEntity> _toBackendTypeVariableMap = |
| 159 <TypeVariableEntity, TypeVariableEntity>{}; |
| 160 |
| 161 final Map<TypeVariableEntity, TypeVariableEntity> _toFrontendTypeVariableMap = |
| 162 <TypeVariableEntity, TypeVariableEntity>{}; |
| 163 |
| 164 TypeVariableEntity _toBackendTypeVariable(TypeVariableEntity typeVariable) { |
| 165 return _toBackendTypeVariableMap.putIfAbsent(typeVariable, () { |
| 166 Entity typeDeclaration; |
| 167 if (typeVariable.typeDeclaration is ClassEntity) { |
| 168 typeDeclaration = toBackendClass(typeVariable.typeDeclaration); |
| 169 } else { |
| 170 typeDeclaration = toBackendMember(typeVariable.typeDeclaration); |
| 171 } |
| 172 TypeVariableEntity newTypeVariable = new JTypeVariable( |
| 173 typeDeclaration, typeVariable.name, typeVariable.index); |
| 174 _toFrontendTypeVariableMap[newTypeVariable] = typeVariable; |
| 175 return newTypeVariable; |
| 176 }); |
| 177 } |
| 178 |
| 179 Entity _toFrontendEntity(Entity entity) { |
| 180 if (entity is ClassEntity) return toFrontendClass(entity); |
| 181 assert(entity is TypeVariableEntity); |
| 182 TypeVariableEntity typeVariable = _toFrontendTypeVariableMap[entity]; |
| 183 assert(typeVariable != null, "No front end type variable for $entity"); |
| 184 return typeVariable; |
| 185 } |
| 186 } |
| 187 |
| 188 typedef Entity EntityConverter(Entity cls); |
| 189 |
| 190 class TypeConverter implements DartTypeVisitor<DartType, EntityConverter> { |
| 191 const TypeConverter(); |
| 192 |
| 193 @override |
| 194 DartType visit(DartType type, EntityConverter converter) { |
| 195 return type.accept(this, converter); |
| 196 } |
| 197 |
| 198 List<DartType> visitList(List<DartType> types, EntityConverter converter) { |
| 199 List<DartType> list = <DartType>[]; |
| 200 for (DartType type in types) { |
| 201 list.add(visit(type, converter)); |
| 202 } |
| 203 return list; |
| 204 } |
| 205 |
| 206 @override |
| 207 DartType visitDynamicType(DynamicType type, EntityConverter converter) { |
| 208 return const DynamicType(); |
| 209 } |
| 210 |
| 211 @override |
| 212 DartType visitInterfaceType(InterfaceType type, EntityConverter converter) { |
| 213 return new InterfaceType( |
| 214 converter(type.element), visitList(type.typeArguments, converter)); |
| 215 } |
| 216 |
| 217 @override |
| 218 DartType visitFunctionType(FunctionType type, EntityConverter converter) { |
| 219 return new FunctionType( |
| 220 visit(type.returnType, converter), |
| 221 visitList(type.parameterTypes, converter), |
| 222 visitList(type.optionalParameterTypes, converter), |
| 223 type.namedParameters, |
| 224 visitList(type.namedParameterTypes, converter)); |
| 225 } |
| 226 |
| 227 @override |
| 228 DartType visitTypeVariableType( |
| 229 TypeVariableType type, EntityConverter converter) { |
| 230 return new TypeVariableType(converter(type.element)); |
| 231 } |
| 232 |
| 233 @override |
| 234 DartType visitVoidType(VoidType type, EntityConverter converter) { |
| 235 return const VoidType(); |
| 236 } |
| 237 } |
| 238 |
| 239 class JLibrary implements LibraryEntity { |
| 240 /// Library index used for fast lookup in [JsToFrontendMapImpl]. |
| 241 final int libraryIndex; |
| 242 final String name; |
| 243 final Uri canonicalUri; |
| 244 |
| 245 JLibrary(this.libraryIndex, this.name, this.canonicalUri); |
| 246 |
| 247 String toString() => 'library($name)'; |
| 248 } |
| 249 |
| 250 class JClass implements ClassEntity { |
| 251 final JLibrary library; |
| 252 |
| 253 /// Class index used for fast lookup in [JsToFrontendMapImpl]. |
| 254 final int classIndex; |
| 255 |
| 256 final String name; |
| 257 final bool isAbstract; |
| 258 |
| 259 JClass(this.library, this.classIndex, this.name, {this.isAbstract}); |
| 260 |
| 261 @override |
| 262 bool get isClosure => false; |
| 263 |
| 264 String toString() => 'class($name)'; |
| 265 } |
| 266 |
| 267 abstract class JMember implements MemberEntity { |
| 268 /// Member index used for fast lookup in [JsToFrontendMapImpl]. |
| 269 final int memberIndex; |
| 270 final JLibrary library; |
| 271 final JClass enclosingClass; |
| 272 final Name _name; |
| 273 final bool _isStatic; |
| 274 |
| 275 JMember(this.memberIndex, this.library, this.enclosingClass, this._name, |
| 276 {bool isStatic: false}) |
| 277 : _isStatic = isStatic; |
| 278 |
| 279 String get name => _name.text; |
| 280 |
| 281 Name get memberName => _name; |
| 282 |
| 283 @override |
| 284 bool get isAssignable => false; |
| 285 |
| 286 @override |
| 287 bool get isConst => false; |
| 288 |
| 289 @override |
| 290 bool get isAbstract => false; |
| 291 |
| 292 @override |
| 293 bool get isSetter => false; |
| 294 |
| 295 @override |
| 296 bool get isGetter => false; |
| 297 |
| 298 @override |
| 299 bool get isFunction => false; |
| 300 |
| 301 @override |
| 302 bool get isField => false; |
| 303 |
| 304 @override |
| 305 bool get isConstructor => false; |
| 306 |
| 307 @override |
| 308 bool get isInstanceMember => enclosingClass != null && !_isStatic; |
| 309 |
| 310 @override |
| 311 bool get isStatic => enclosingClass != null && _isStatic; |
| 312 |
| 313 @override |
| 314 bool get isTopLevel => enclosingClass == null; |
| 315 |
| 316 String get _kind; |
| 317 |
| 318 String toString() => |
| 319 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; |
| 320 } |
| 321 |
| 322 abstract class JFunction extends JMember implements FunctionEntity { |
| 323 final ParameterStructure parameterStructure; |
| 324 final bool isExternal; |
| 325 final AsyncMarker asyncMarker; |
| 326 |
| 327 JFunction(int memberIndex, JLibrary library, JClass enclosingClass, Name name, |
| 328 this.parameterStructure, this.asyncMarker, |
| 329 {bool isStatic: false, this.isExternal: false}) |
| 330 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); |
| 331 } |
| 332 |
| 333 abstract class JConstructor extends JFunction implements ConstructorEntity { |
| 334 final bool isConst; |
| 335 |
| 336 JConstructor(int memberIndex, JClass enclosingClass, Name name, |
| 337 ParameterStructure parameterStructure, {bool isExternal, this.isConst}) |
| 338 : super(memberIndex, enclosingClass.library, enclosingClass, name, |
| 339 parameterStructure, AsyncMarker.SYNC, |
| 340 isExternal: isExternal); |
| 341 |
| 342 @override |
| 343 bool get isConstructor => true; |
| 344 |
| 345 @override |
| 346 bool get isInstanceMember => false; |
| 347 |
| 348 @override |
| 349 bool get isStatic => false; |
| 350 |
| 351 @override |
| 352 bool get isTopLevel => false; |
| 353 |
| 354 @override |
| 355 bool get isFromEnvironmentConstructor => false; |
| 356 |
| 357 String get _kind => 'constructor'; |
| 358 } |
| 359 |
| 360 class JGenerativeConstructor extends JConstructor { |
| 361 JGenerativeConstructor(int constructorIndex, JClass enclosingClass, Name name, |
| 362 ParameterStructure parameterStructure, {bool isExternal, bool isConst}) |
| 363 : super(constructorIndex, enclosingClass, name, parameterStructure, |
| 364 isExternal: isExternal, isConst: isConst); |
| 365 |
| 366 @override |
| 367 bool get isFactoryConstructor => false; |
| 368 |
| 369 @override |
| 370 bool get isGenerativeConstructor => true; |
| 371 } |
| 372 |
| 373 class JFactoryConstructor extends JConstructor { |
| 374 @override |
| 375 final bool isFromEnvironmentConstructor; |
| 376 |
| 377 JFactoryConstructor(int memberIndex, JClass enclosingClass, Name name, |
| 378 ParameterStructure parameterStructure, |
| 379 {bool isExternal, bool isConst, this.isFromEnvironmentConstructor}) |
| 380 : super(memberIndex, enclosingClass, name, parameterStructure, |
| 381 isExternal: isExternal, isConst: isConst); |
| 382 |
| 383 @override |
| 384 bool get isFactoryConstructor => true; |
| 385 |
| 386 @override |
| 387 bool get isGenerativeConstructor => false; |
| 388 } |
| 389 |
| 390 class JMethod extends JFunction { |
| 391 final bool isAbstract; |
| 392 |
| 393 JMethod(int memberIndex, JLibrary library, JClass enclosingClass, Name name, |
| 394 ParameterStructure parameterStructure, AsyncMarker asyncMarker, |
| 395 {bool isStatic, bool isExternal, this.isAbstract}) |
| 396 : super(memberIndex, library, enclosingClass, name, parameterStructure, |
| 397 asyncMarker, |
| 398 isStatic: isStatic, isExternal: isExternal); |
| 399 |
| 400 @override |
| 401 bool get isFunction => true; |
| 402 |
| 403 String get _kind => 'method'; |
| 404 } |
| 405 |
| 406 class JGetter extends JFunction { |
| 407 final bool isAbstract; |
| 408 |
| 409 JGetter(int memberIndex, JLibrary library, JClass enclosingClass, Name name, |
| 410 AsyncMarker asyncMarker, |
| 411 {bool isStatic, bool isExternal, this.isAbstract}) |
| 412 : super(memberIndex, library, enclosingClass, name, |
| 413 const ParameterStructure.getter(), asyncMarker, |
| 414 isStatic: isStatic, isExternal: isExternal); |
| 415 |
| 416 @override |
| 417 bool get isGetter => true; |
| 418 |
| 419 String get _kind => 'getter'; |
| 420 } |
| 421 |
| 422 class JSetter extends JFunction { |
| 423 final bool isAbstract; |
| 424 |
| 425 JSetter(int memberIndex, JLibrary library, JClass enclosingClass, Name name, |
| 426 {bool isStatic, bool isExternal, this.isAbstract}) |
| 427 : super(memberIndex, library, enclosingClass, name, |
| 428 const ParameterStructure.setter(), AsyncMarker.SYNC, |
| 429 isStatic: isStatic, isExternal: isExternal); |
| 430 |
| 431 @override |
| 432 bool get isAssignable => true; |
| 433 |
| 434 @override |
| 435 bool get isSetter => true; |
| 436 |
| 437 String get _kind => 'setter'; |
| 438 } |
| 439 |
| 440 class JField extends JMember implements FieldEntity { |
| 441 final bool isAssignable; |
| 442 final bool isConst; |
| 443 |
| 444 JField(int memberIndex, JLibrary library, JClass enclosingClass, Name name, |
| 445 {bool isStatic, this.isAssignable, this.isConst}) |
| 446 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); |
| 447 |
| 448 @override |
| 449 bool get isField => true; |
| 450 |
| 451 String get _kind => 'field'; |
| 452 } |
| 453 |
| 454 class JTypeVariable implements TypeVariableEntity { |
| 455 final Entity typeDeclaration; |
| 456 final String name; |
| 457 final int index; |
| 458 |
| 459 JTypeVariable(this.typeDeclaration, this.name, this.index); |
| 460 |
| 461 String toString() => 'type_variable(${typeDeclaration.name}.$name)'; |
43 } | 462 } |
44 | 463 |
45 class JsClosedWorld extends ClosedWorldBase { | 464 class JsClosedWorld extends ClosedWorldBase { |
46 JsClosedWorld( | 465 JsClosedWorld( |
47 {ElementEnvironment elementEnvironment, | 466 {ElementEnvironment elementEnvironment, |
48 CommonElements commonElements, | 467 CommonElements commonElements, |
49 ConstantSystem constantSystem, | 468 ConstantSystem constantSystem, |
50 NativeData nativeData, | 469 NativeData nativeData, |
51 InterceptorData interceptorData, | 470 InterceptorData interceptorData, |
52 BackendUsage backendUsage, | 471 BackendUsage backendUsage, |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 @override | 710 @override |
292 bool get isIsolateInUse => _backendUsage.isIsolateInUse; | 711 bool get isIsolateInUse => _backendUsage.isIsolateInUse; |
293 | 712 |
294 @override | 713 @override |
295 bool get isFunctionApplyUsed => _backendUsage.isFunctionApplyUsed; | 714 bool get isFunctionApplyUsed => _backendUsage.isFunctionApplyUsed; |
296 | 715 |
297 @override | 716 @override |
298 bool get isNoSuchMethodUsed => _backendUsage.isNoSuchMethodUsed; | 717 bool get isNoSuchMethodUsed => _backendUsage.isNoSuchMethodUsed; |
299 } | 718 } |
300 | 719 |
| 720 class JsElementEnvironment implements ElementEnvironment { |
| 721 final JsToFrontendMap _map; |
| 722 final ElementEnvironment _elementEnvironment; |
| 723 |
| 724 JsElementEnvironment(this._map, this._elementEnvironment); |
| 725 |
| 726 @override |
| 727 Iterable<ConstantValue> getMemberMetadata(MemberEntity member) { |
| 728 throw new UnimplementedError('JsElementEnvironment.getMemberMetadata'); |
| 729 } |
| 730 |
| 731 @override |
| 732 bool isDeferredLoadLibraryGetter(MemberEntity member) { |
| 733 throw new UnimplementedError( |
| 734 'JsElementEnvironment.isDeferredLoadLibraryGetter'); |
| 735 } |
| 736 |
| 737 @override |
| 738 DartType getUnaliasedType(DartType type) { |
| 739 throw new UnimplementedError('JsElementEnvironment.getUnaliasedType'); |
| 740 } |
| 741 |
| 742 @override |
| 743 FunctionType getLocalFunctionType(Local local) { |
| 744 throw new UnimplementedError('JsElementEnvironment.getLocalFunctionType'); |
| 745 } |
| 746 |
| 747 @override |
| 748 FunctionType getFunctionType(FunctionEntity function) { |
| 749 return _map.toBackendType( |
| 750 _elementEnvironment.getFunctionType(_map.toFrontendMember(function))); |
| 751 } |
| 752 |
| 753 @override |
| 754 DartType getTypeVariableBound(TypeVariableEntity typeVariable) { |
| 755 throw new UnimplementedError('JsElementEnvironment.getTypeVariableBound'); |
| 756 } |
| 757 |
| 758 @override |
| 759 ClassEntity getEffectiveMixinClass(ClassEntity cls) { |
| 760 throw new UnimplementedError('JsElementEnvironment.getEffectiveMixinClass'); |
| 761 } |
| 762 |
| 763 @override |
| 764 bool isUnnamedMixinApplication(ClassEntity cls) { |
| 765 throw new UnimplementedError( |
| 766 'JsElementEnvironment.isUnnamedMixinApplication'); |
| 767 } |
| 768 |
| 769 @override |
| 770 bool isMixinApplication(ClassEntity cls) { |
| 771 throw new UnimplementedError('JsElementEnvironment.isMixinApplication'); |
| 772 } |
| 773 |
| 774 @override |
| 775 bool isGenericClass(ClassEntity cls) { |
| 776 throw new UnimplementedError('JsElementEnvironment.isGenericClass'); |
| 777 } |
| 778 |
| 779 @override |
| 780 InterfaceType getThisType(ClassEntity cls) { |
| 781 throw new UnimplementedError('JsElementEnvironment.getThisType'); |
| 782 } |
| 783 |
| 784 @override |
| 785 InterfaceType getRawType(ClassEntity cls) { |
| 786 throw new UnimplementedError('JsElementEnvironment.getRawType'); |
| 787 } |
| 788 |
| 789 @override |
| 790 DartType get dynamicType { |
| 791 throw new UnimplementedError('JsElementEnvironment.dynamicType'); |
| 792 } |
| 793 |
| 794 @override |
| 795 InterfaceType createInterfaceType( |
| 796 ClassEntity cls, List<DartType> typeArguments) { |
| 797 throw new UnimplementedError('JsElementEnvironment.createInterfaceType'); |
| 798 } |
| 799 |
| 800 @override |
| 801 void forEachMixin(ClassEntity cls, void f(ClassEntity mixin)) { |
| 802 throw new UnimplementedError('JsElementEnvironment.forEachMixin'); |
| 803 } |
| 804 |
| 805 @override |
| 806 void forEachSupertype(ClassEntity cls, void f(InterfaceType supertype)) { |
| 807 throw new UnimplementedError('JsElementEnvironment.forEachSupertype'); |
| 808 } |
| 809 |
| 810 @override |
| 811 ClassEntity getSuperClass(ClassEntity cls, |
| 812 {bool skipUnnamedMixinApplications: false}) { |
| 813 throw new UnimplementedError('JsElementEnvironment.getSuperClass'); |
| 814 } |
| 815 |
| 816 @override |
| 817 void forEachConstructor( |
| 818 ClassEntity cls, void f(ConstructorEntity constructor)) { |
| 819 throw new UnimplementedError('JsElementEnvironment.forEachConstructor'); |
| 820 } |
| 821 |
| 822 @override |
| 823 void forEachClassMember( |
| 824 ClassEntity cls, void f(ClassEntity declarer, MemberEntity member)) { |
| 825 throw new UnimplementedError('JsElementEnvironment.forEachClassMember'); |
| 826 } |
| 827 |
| 828 @override |
| 829 ConstructorEntity lookupConstructor(ClassEntity cls, String name, |
| 830 {bool required: false}) { |
| 831 throw new UnimplementedError('JsElementEnvironment.lookupConstructor'); |
| 832 } |
| 833 |
| 834 @override |
| 835 MemberEntity lookupClassMember(ClassEntity cls, String name, |
| 836 {bool setter: false, bool required: false}) { |
| 837 throw new UnimplementedError('JsElementEnvironment.lookupClassMember'); |
| 838 } |
| 839 |
| 840 @override |
| 841 MemberEntity lookupLibraryMember(LibraryEntity library, String name, |
| 842 {bool setter: false, bool required: false}) { |
| 843 throw new UnimplementedError('JsElementEnvironment.lookupLibraryMember'); |
| 844 } |
| 845 |
| 846 @override |
| 847 void forEachLibraryMember( |
| 848 LibraryEntity library, void f(MemberEntity member)) { |
| 849 _elementEnvironment.forEachLibraryMember(_map.toFrontendLibrary(library), |
| 850 (MemberEntity member) { |
| 851 f(_map.toBackendMember(member)); |
| 852 }); |
| 853 } |
| 854 |
| 855 @override |
| 856 ClassEntity lookupClass(LibraryEntity library, String name, |
| 857 {bool required: false}) { |
| 858 throw new UnimplementedError('JsElementEnvironment.lookupClass'); |
| 859 } |
| 860 |
| 861 @override |
| 862 void forEachClass(LibraryEntity library, void f(ClassEntity cls)) { |
| 863 throw new UnimplementedError('JsElementEnvironment.forEachClass'); |
| 864 } |
| 865 |
| 866 @override |
| 867 LibraryEntity lookupLibrary(Uri uri, {bool required: false}) { |
| 868 throw new UnimplementedError('JsElementEnvironment.lookupLibrary'); |
| 869 } |
| 870 |
| 871 @override |
| 872 String getLibraryName(LibraryEntity library) { |
| 873 return _elementEnvironment.getLibraryName(_map.toFrontendLibrary(library)); |
| 874 } |
| 875 |
| 876 @override |
| 877 Iterable<LibraryEntity> get libraries { |
| 878 throw new UnimplementedError('JsElementEnvironment.libraries'); |
| 879 } |
| 880 |
| 881 @override |
| 882 FunctionEntity get mainFunction { |
| 883 return _map.toBackendMember(_elementEnvironment.mainFunction); |
| 884 } |
| 885 |
| 886 @override |
| 887 LibraryEntity get mainLibrary { |
| 888 return _map.toBackendLibrary(_elementEnvironment.mainLibrary); |
| 889 } |
| 890 } |
| 891 |
301 class JsCommonElements implements CommonElements { | 892 class JsCommonElements implements CommonElements { |
302 final JsToFrontendMap _map; | 893 final JsToFrontendMap _map; |
303 final CommonElements _commonElements; | 894 final CommonElements _commonElements; |
304 | 895 |
305 JsCommonElements(this._map, this._commonElements); | 896 JsCommonElements(this._map, this._commonElements); |
306 | 897 |
307 @override | 898 @override |
308 ClassEntity get objectClass => | 899 ClassEntity get objectClass => |
309 _map.toBackendClass(_commonElements.objectClass); | 900 _map.toBackendClass(_commonElements.objectClass); |
310 | 901 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 _map.toBackendMember(_commonElements.malformedTypeError); | 1582 _map.toBackendMember(_commonElements.malformedTypeError); |
992 | 1583 |
993 @override | 1584 @override |
994 bool isDefaultEqualityImplementation(MemberEntity element) { | 1585 bool isDefaultEqualityImplementation(MemberEntity element) { |
995 return _commonElements | 1586 return _commonElements |
996 .isDefaultEqualityImplementation(_map.toFrontendMember(element)); | 1587 .isDefaultEqualityImplementation(_map.toFrontendMember(element)); |
997 } | 1588 } |
998 | 1589 |
999 @override | 1590 @override |
1000 InterfaceType get symbolImplementationType { | 1591 InterfaceType get symbolImplementationType { |
1001 return _map.fromFrontendType(_commonElements.symbolImplementationType); | 1592 return _map.toBackendType(_commonElements.symbolImplementationType); |
1002 } | 1593 } |
1003 | 1594 |
1004 @override | 1595 @override |
1005 FieldEntity get symbolField => | 1596 FieldEntity get symbolField => |
1006 _map.toBackendMember(_commonElements.symbolField); | 1597 _map.toBackendMember(_commonElements.symbolField); |
1007 | 1598 |
1008 @override | 1599 @override |
1009 InterfaceType getConstantMapTypeFor(InterfaceType sourceType, | 1600 InterfaceType getConstantMapTypeFor(InterfaceType sourceType, |
1010 {bool hasProtoKey: false, bool onlyStringKeys: false}) { | 1601 {bool hasProtoKey: false, bool onlyStringKeys: false}) { |
1011 return _map.fromFrontendType(_commonElements.getConstantMapTypeFor( | 1602 return _map.toBackendType(_commonElements.getConstantMapTypeFor( |
1012 _map.toBackendType(sourceType), | 1603 _map.toFrontendType(sourceType), |
1013 hasProtoKey: hasProtoKey, | 1604 hasProtoKey: hasProtoKey, |
1014 onlyStringKeys: onlyStringKeys)); | 1605 onlyStringKeys: onlyStringKeys)); |
1015 } | 1606 } |
1016 | 1607 |
1017 @override | 1608 @override |
1018 bool isListSupertype(ClassEntity element) { | 1609 bool isListSupertype(ClassEntity element) { |
1019 return _commonElements.isListSupertype(_map.toFrontendClass(element)); | 1610 return _commonElements.isListSupertype(_map.toFrontendClass(element)); |
1020 } | 1611 } |
1021 | 1612 |
1022 @override | 1613 @override |
1023 bool isStringOnlySupertype(ClassEntity element) { | 1614 bool isStringOnlySupertype(ClassEntity element) { |
1024 return _commonElements.isStringOnlySupertype(_map.toFrontendClass(element)); | 1615 return _commonElements.isStringOnlySupertype(_map.toFrontendClass(element)); |
1025 } | 1616 } |
1026 | 1617 |
1027 @override | 1618 @override |
1028 bool isNumberOrStringSupertype(ClassEntity element) { | 1619 bool isNumberOrStringSupertype(ClassEntity element) { |
1029 return _commonElements | 1620 return _commonElements |
1030 .isNumberOrStringSupertype(_map.toFrontendClass(element)); | 1621 .isNumberOrStringSupertype(_map.toFrontendClass(element)); |
1031 } | 1622 } |
1032 | 1623 |
1033 @override | 1624 @override |
1034 InterfaceType streamType([DartType elementType]) { | 1625 InterfaceType streamType([DartType elementType]) { |
1035 return _map.fromFrontendType( | 1626 return _map.toBackendType( |
1036 _commonElements.streamType(_map.toBackendType(elementType))); | 1627 _commonElements.streamType(_map.toFrontendType(elementType))); |
1037 } | 1628 } |
1038 | 1629 |
1039 @override | 1630 @override |
1040 InterfaceType futureType([DartType elementType]) { | 1631 InterfaceType futureType([DartType elementType]) { |
1041 return _map.fromFrontendType( | 1632 return _map.toBackendType( |
1042 _commonElements.futureType(_map.toBackendType(elementType))); | 1633 _commonElements.futureType(_map.toFrontendType(elementType))); |
1043 } | 1634 } |
1044 | 1635 |
1045 @override | 1636 @override |
1046 InterfaceType iterableType([DartType elementType]) { | 1637 InterfaceType iterableType([DartType elementType]) { |
1047 return _map.fromFrontendType( | 1638 return _map.toBackendType( |
1048 _commonElements.iterableType(_map.toBackendType(elementType))); | 1639 _commonElements.iterableType(_map.toFrontendType(elementType))); |
1049 } | 1640 } |
1050 | 1641 |
1051 @override | 1642 @override |
1052 InterfaceType mapType([DartType keyType, DartType valueType]) { | 1643 InterfaceType mapType([DartType keyType, DartType valueType]) { |
1053 return _map.fromFrontendType(_commonElements.mapType( | 1644 return _map.toBackendType(_commonElements.mapType( |
1054 _map.toBackendType(keyType), _map.toBackendType(valueType))); | 1645 _map.toFrontendType(keyType), _map.toFrontendType(valueType))); |
1055 } | 1646 } |
1056 | 1647 |
1057 @override | 1648 @override |
1058 InterfaceType listType([DartType elementType]) { | 1649 InterfaceType listType([DartType elementType]) { |
1059 return _map.fromFrontendType( | 1650 return _map.toBackendType( |
1060 _commonElements.listType(_map.toBackendType(elementType))); | 1651 _commonElements.listType(_map.toFrontendType(elementType))); |
1061 } | 1652 } |
1062 | 1653 |
1063 @override | 1654 @override |
1064 InterfaceType get stackTraceType => | 1655 InterfaceType get stackTraceType => |
1065 _map.fromFrontendType(_commonElements.stackTraceType); | 1656 _map.toBackendType(_commonElements.stackTraceType); |
1066 | 1657 |
1067 @override | 1658 @override |
1068 InterfaceType get typeLiteralType => | 1659 InterfaceType get typeLiteralType => |
1069 _map.fromFrontendType(_commonElements.typeLiteralType); | 1660 _map.toBackendType(_commonElements.typeLiteralType); |
1070 | 1661 |
1071 @override | 1662 @override |
1072 InterfaceType get typeType => _map.fromFrontendType(_commonElements.typeType); | 1663 InterfaceType get typeType => _map.toBackendType(_commonElements.typeType); |
1073 | 1664 |
1074 @override | 1665 @override |
1075 InterfaceType get nullType => _map.fromFrontendType(_commonElements.nullType); | 1666 InterfaceType get nullType => _map.toBackendType(_commonElements.nullType); |
1076 | 1667 |
1077 @override | 1668 @override |
1078 InterfaceType get functionType => | 1669 InterfaceType get functionType => |
1079 _map.fromFrontendType(_commonElements.functionType); | 1670 _map.toBackendType(_commonElements.functionType); |
1080 | 1671 |
1081 @override | 1672 @override |
1082 InterfaceType get symbolType => | 1673 InterfaceType get symbolType => |
1083 _map.fromFrontendType(_commonElements.symbolType); | 1674 _map.toBackendType(_commonElements.symbolType); |
1084 | 1675 |
1085 @override | 1676 @override |
1086 InterfaceType get stringType => | 1677 InterfaceType get stringType => |
1087 _map.fromFrontendType(_commonElements.stringType); | 1678 _map.toBackendType(_commonElements.stringType); |
1088 | 1679 |
1089 @override | 1680 @override |
1090 InterfaceType get resourceType => | 1681 InterfaceType get resourceType => |
1091 _map.fromFrontendType(_commonElements.resourceType); | 1682 _map.toBackendType(_commonElements.resourceType); |
1092 | 1683 |
1093 @override | 1684 @override |
1094 InterfaceType get doubleType => | 1685 InterfaceType get doubleType => |
1095 _map.fromFrontendType(_commonElements.doubleType); | 1686 _map.toBackendType(_commonElements.doubleType); |
1096 | 1687 |
1097 @override | 1688 @override |
1098 InterfaceType get intType => _map.fromFrontendType(_commonElements.intType); | 1689 InterfaceType get intType => _map.toBackendType(_commonElements.intType); |
1099 | 1690 |
1100 @override | 1691 @override |
1101 InterfaceType get numType => _map.fromFrontendType(_commonElements.numType); | 1692 InterfaceType get numType => _map.toBackendType(_commonElements.numType); |
1102 | 1693 |
1103 @override | 1694 @override |
1104 InterfaceType get boolType => _map.fromFrontendType(_commonElements.boolType); | 1695 InterfaceType get boolType => _map.toBackendType(_commonElements.boolType); |
1105 | 1696 |
1106 @override | 1697 @override |
1107 InterfaceType get objectType => | 1698 InterfaceType get objectType => |
1108 _map.fromFrontendType(_commonElements.objectType); | 1699 _map.toBackendType(_commonElements.objectType); |
1109 | 1700 |
1110 @override | 1701 @override |
1111 DynamicType get dynamicType => | 1702 DynamicType get dynamicType => |
1112 _map.fromFrontendType(_commonElements.dynamicType); | 1703 _map.toBackendType(_commonElements.dynamicType); |
1113 | 1704 |
1114 @override | 1705 @override |
1115 bool isFilledListConstructor(ConstructorEntity element) { | 1706 bool isFilledListConstructor(ConstructorEntity element) { |
1116 return _commonElements | 1707 return _commonElements |
1117 .isFilledListConstructor(_map.toFrontendMember(element)); | 1708 .isFilledListConstructor(_map.toFrontendMember(element)); |
1118 } | 1709 } |
1119 | 1710 |
1120 @override | 1711 @override |
1121 bool isUnnamedListConstructor(ConstructorEntity element) { | 1712 bool isUnnamedListConstructor(ConstructorEntity element) { |
1122 return _commonElements | 1713 return _commonElements |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 @override | 1855 @override |
1265 ClassEntity get numClass => _map.toBackendClass(_commonElements.numClass); | 1856 ClassEntity get numClass => _map.toBackendClass(_commonElements.numClass); |
1266 | 1857 |
1267 @override | 1858 @override |
1268 ClassEntity get boolClass => _map.toBackendClass(_commonElements.boolClass); | 1859 ClassEntity get boolClass => _map.toBackendClass(_commonElements.boolClass); |
1269 | 1860 |
1270 @override | 1861 @override |
1271 FunctionEntity get throwUnsupportedError => | 1862 FunctionEntity get throwUnsupportedError => |
1272 _map.toBackendMember(_commonElements.throwUnsupportedError); | 1863 _map.toBackendMember(_commonElements.throwUnsupportedError); |
1273 } | 1864 } |
OLD | NEW |