| 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/names.dart' show Names; | 7 import '../common/names.dart' show Names; |
| 8 import '../elements/entities.dart'; | 8 import '../elements/entities.dart'; |
| 9 import '../elements/names.dart'; | 9 import '../elements/names.dart'; |
| 10 import '../elements/types.dart'; | 10 import '../elements/types.dart'; |
| 11 import '../kernel/elements.dart'; | 11 import '../kernel/indexed.dart'; |
| 12 import '../kernel/element_map_impl.dart'; | |
| 13 import 'closure.dart' show KernelClosureClass; | 12 import 'closure.dart' show KernelClosureClass; |
| 14 | 13 |
| 15 /// Map from 'frontend' to 'backend' elements. | 14 /// Map from 'frontend' to 'backend' elements. |
| 16 /// | 15 /// |
| 17 /// Frontend elements are what we read in, these typically represents concepts | 16 /// Frontend elements are what we read in, these typically represents concepts |
| 18 /// in Dart. Backend elements are what we generate, these may include elements | 17 /// in Dart. Backend elements are what we generate, these may include elements |
| 19 /// that do not correspond to a Dart concept, such as closure classes. | 18 /// that do not correspond to a Dart concept, such as closure classes. |
| 20 /// | 19 /// |
| 21 /// Querying for the frontend element for a backend-only element throws an | 20 /// Querying for the frontend element for a backend-only element throws an |
| 22 /// exception. | 21 /// exception. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (entity is ClassEntity) return toBackendClass(entity); | 83 if (entity is ClassEntity) return toBackendClass(entity); |
| 85 assert(entity is TypeVariableEntity); | 84 assert(entity is TypeVariableEntity); |
| 86 return toBackendTypeVariable(entity); | 85 return toBackendTypeVariable(entity); |
| 87 } | 86 } |
| 88 | 87 |
| 89 TypeVariableEntity toBackendTypeVariable(TypeVariableEntity typeVariable); | 88 TypeVariableEntity toBackendTypeVariable(TypeVariableEntity typeVariable); |
| 90 } | 89 } |
| 91 | 90 |
| 92 // TODO(johnniwinther): Merge this with [JsKernelToElementMap]. | 91 // TODO(johnniwinther): Merge this with [JsKernelToElementMap]. |
| 93 class JsElementCreatorMixin { | 92 class JsElementCreatorMixin { |
| 94 IndexedLibrary createLibrary( | 93 IndexedLibrary createLibrary(String name, Uri canonicalUri) { |
| 95 int libraryIndex, String name, Uri canonicalUri) { | 94 return new JLibrary(name, canonicalUri); |
| 96 return new JLibrary(libraryIndex, name, canonicalUri); | |
| 97 } | 95 } |
| 98 | 96 |
| 99 IndexedClass createClass(LibraryEntity library, int classIndex, String name, | 97 IndexedClass createClass(LibraryEntity library, String name, |
| 100 {bool isAbstract}) { | 98 {bool isAbstract}) { |
| 101 return new JClass(library, classIndex, name, isAbstract: isAbstract); | 99 return new JClass(library, name, isAbstract: isAbstract); |
| 102 } | 100 } |
| 103 | 101 |
| 104 IndexedTypedef createTypedef( | 102 IndexedTypedef createTypedef(LibraryEntity library, String name) { |
| 105 LibraryEntity library, int typedefIndex, String name) { | 103 return new JTypedef(library, name); |
| 106 return new JTypedef(library, typedefIndex, name); | |
| 107 } | 104 } |
| 108 | 105 |
| 109 TypeVariableEntity createTypeVariable( | 106 TypeVariableEntity createTypeVariable( |
| 110 int typeVariableIndex, Entity typeDeclaration, String name, int index) { | 107 Entity typeDeclaration, String name, int index) { |
| 111 return new JTypeVariable(typeVariableIndex, typeDeclaration, name, index); | 108 return new JTypeVariable(typeDeclaration, name, index); |
| 112 } | 109 } |
| 113 | 110 |
| 114 IndexedConstructor createGenerativeConstructor( | 111 IndexedConstructor createGenerativeConstructor(ClassEntity enclosingClass, |
| 115 int memberIndex, | 112 Name name, ParameterStructure parameterStructure, |
| 116 ClassEntity enclosingClass, | 113 {bool isExternal, bool isConst}) { |
| 117 Name name, | 114 return new JGenerativeConstructor(enclosingClass, name, parameterStructure, |
| 118 ParameterStructure parameterStructure, | |
| 119 {bool isExternal, | |
| 120 bool isConst}) { | |
| 121 return new JGenerativeConstructor( | |
| 122 memberIndex, enclosingClass, name, parameterStructure, | |
| 123 isExternal: isExternal, isConst: isConst); | 115 isExternal: isExternal, isConst: isConst); |
| 124 } | 116 } |
| 125 | 117 |
| 126 IndexedConstructor createFactoryConstructor( | 118 IndexedConstructor createFactoryConstructor(ClassEntity enclosingClass, |
| 127 int memberIndex, | 119 Name name, ParameterStructure parameterStructure, |
| 128 ClassEntity enclosingClass, | 120 {bool isExternal, bool isConst, bool isFromEnvironmentConstructor}) { |
| 129 Name name, | 121 return new JFactoryConstructor(enclosingClass, name, parameterStructure, |
| 130 ParameterStructure parameterStructure, | |
| 131 {bool isExternal, | |
| 132 bool isConst, | |
| 133 bool isFromEnvironmentConstructor}) { | |
| 134 return new JFactoryConstructor( | |
| 135 memberIndex, enclosingClass, name, parameterStructure, | |
| 136 isExternal: isExternal, | 122 isExternal: isExternal, |
| 137 isConst: isConst, | 123 isConst: isConst, |
| 138 isFromEnvironmentConstructor: isFromEnvironmentConstructor); | 124 isFromEnvironmentConstructor: isFromEnvironmentConstructor); |
| 139 } | 125 } |
| 140 | 126 |
| 141 ConstructorBodyEntity createConstructorBody( | 127 JConstructorBody createConstructorBody(ConstructorEntity constructor) { |
| 142 int memberIndex, ConstructorEntity constructor) { | 128 return new JConstructorBody(constructor); |
| 143 return new JConstructorBody(memberIndex, constructor); | |
| 144 } | 129 } |
| 145 | 130 |
| 146 IndexedFunction createGetter(int memberIndex, LibraryEntity library, | 131 IndexedFunction createGetter(LibraryEntity library, |
| 147 ClassEntity enclosingClass, Name name, AsyncMarker asyncMarker, | 132 ClassEntity enclosingClass, Name name, AsyncMarker asyncMarker, |
| 148 {bool isStatic, bool isExternal, bool isAbstract}) { | 133 {bool isStatic, bool isExternal, bool isAbstract}) { |
| 149 return new JGetter(memberIndex, library, enclosingClass, name, asyncMarker, | 134 return new JGetter(library, enclosingClass, name, asyncMarker, |
| 150 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); | 135 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); |
| 151 } | 136 } |
| 152 | 137 |
| 153 IndexedFunction createMethod( | 138 IndexedFunction createMethod( |
| 154 int memberIndex, | |
| 155 LibraryEntity library, | 139 LibraryEntity library, |
| 156 ClassEntity enclosingClass, | 140 ClassEntity enclosingClass, |
| 157 Name name, | 141 Name name, |
| 158 ParameterStructure parameterStructure, | 142 ParameterStructure parameterStructure, |
| 159 AsyncMarker asyncMarker, | 143 AsyncMarker asyncMarker, |
| 160 {bool isStatic, | 144 {bool isStatic, |
| 161 bool isExternal, | 145 bool isExternal, |
| 162 bool isAbstract}) { | 146 bool isAbstract}) { |
| 163 return new JMethod(memberIndex, library, enclosingClass, name, | 147 return new JMethod( |
| 164 parameterStructure, asyncMarker, | 148 library, enclosingClass, name, parameterStructure, asyncMarker, |
| 165 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); | 149 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); |
| 166 } | 150 } |
| 167 | 151 |
| 168 IndexedFunction createSetter(int memberIndex, LibraryEntity library, | 152 IndexedFunction createSetter( |
| 169 ClassEntity enclosingClass, Name name, | 153 LibraryEntity library, ClassEntity enclosingClass, Name name, |
| 170 {bool isStatic, bool isExternal, bool isAbstract}) { | 154 {bool isStatic, bool isExternal, bool isAbstract}) { |
| 171 return new JSetter(memberIndex, library, enclosingClass, name, | 155 return new JSetter(library, enclosingClass, name, |
| 172 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); | 156 isStatic: isStatic, isExternal: isExternal, isAbstract: isAbstract); |
| 173 } | 157 } |
| 174 | 158 |
| 175 IndexedField createField(int memberIndex, LibraryEntity library, | 159 IndexedField createField( |
| 176 ClassEntity enclosingClass, Name name, | 160 LibraryEntity library, ClassEntity enclosingClass, Name name, |
| 177 {bool isStatic, bool isAssignable, bool isConst}) { | 161 {bool isStatic, bool isAssignable, bool isConst}) { |
| 178 return new JField(memberIndex, library, enclosingClass, name, | 162 return new JField(library, enclosingClass, name, |
| 179 isStatic: isStatic, isAssignable: isAssignable, isConst: isConst); | 163 isStatic: isStatic, isAssignable: isAssignable, isConst: isConst); |
| 180 } | 164 } |
| 181 | 165 |
| 182 LibraryEntity convertLibrary(IndexedLibrary library) { | 166 LibraryEntity convertLibrary(IndexedLibrary library) { |
| 183 return createLibrary( | 167 return createLibrary(library.name, library.canonicalUri); |
| 184 library.libraryIndex, library.name, library.canonicalUri); | |
| 185 } | 168 } |
| 186 | 169 |
| 187 ClassEntity convertClass(LibraryEntity library, IndexedClass cls) { | 170 ClassEntity convertClass(LibraryEntity library, IndexedClass cls) { |
| 188 return createClass(library, cls.classIndex, cls.name, | 171 return createClass(library, cls.name, isAbstract: cls.isAbstract); |
| 189 isAbstract: cls.isAbstract); | |
| 190 } | 172 } |
| 191 | 173 |
| 192 MemberEntity convertMember( | 174 MemberEntity convertMember( |
| 193 LibraryEntity library, ClassEntity cls, IndexedMember member) { | 175 LibraryEntity library, ClassEntity cls, IndexedMember member) { |
| 194 Name memberName = new Name(member.memberName.text, library, | 176 Name memberName = new Name(member.memberName.text, library, |
| 195 isSetter: member.memberName.isSetter); | 177 isSetter: member.memberName.isSetter); |
| 196 if (member.isField) { | 178 if (member.isField) { |
| 197 IndexedField field = member; | 179 IndexedField field = member; |
| 198 return createField(member.memberIndex, library, cls, memberName, | 180 return createField(library, cls, memberName, |
| 199 isStatic: field.isStatic, | 181 isStatic: field.isStatic, |
| 200 isAssignable: field.isAssignable, | 182 isAssignable: field.isAssignable, |
| 201 isConst: field.isConst); | 183 isConst: field.isConst); |
| 202 } else if (member.isConstructor) { | 184 } else if (member.isConstructor) { |
| 203 IndexedConstructor constructor = member; | 185 IndexedConstructor constructor = member; |
| 204 if (constructor.isFactoryConstructor) { | 186 if (constructor.isFactoryConstructor) { |
| 205 // TODO(redemption): This should be a JFunction. | 187 // TODO(redemption): This should be a JFunction. |
| 206 return createFactoryConstructor( | 188 return createFactoryConstructor( |
| 207 member.memberIndex, cls, memberName, constructor.parameterStructure, | 189 cls, memberName, constructor.parameterStructure, |
| 208 isExternal: constructor.isExternal, | 190 isExternal: constructor.isExternal, |
| 209 isConst: constructor.isConst, | 191 isConst: constructor.isConst, |
| 210 isFromEnvironmentConstructor: | 192 isFromEnvironmentConstructor: |
| 211 constructor.isFromEnvironmentConstructor); | 193 constructor.isFromEnvironmentConstructor); |
| 212 } else { | 194 } else { |
| 213 return createGenerativeConstructor( | 195 return createGenerativeConstructor( |
| 214 member.memberIndex, cls, memberName, constructor.parameterStructure, | 196 cls, memberName, constructor.parameterStructure, |
| 215 isExternal: constructor.isExternal, isConst: constructor.isConst); | 197 isExternal: constructor.isExternal, isConst: constructor.isConst); |
| 216 } | 198 } |
| 217 } else if (member.isGetter) { | 199 } else if (member.isGetter) { |
| 218 IndexedFunction getter = member; | 200 IndexedFunction getter = member; |
| 219 return createGetter( | 201 return createGetter(library, cls, memberName, getter.asyncMarker, |
| 220 member.memberIndex, library, cls, memberName, getter.asyncMarker, | |
| 221 isStatic: getter.isStatic, | 202 isStatic: getter.isStatic, |
| 222 isExternal: getter.isExternal, | 203 isExternal: getter.isExternal, |
| 223 isAbstract: getter.isAbstract); | 204 isAbstract: getter.isAbstract); |
| 224 } else if (member.isSetter) { | 205 } else if (member.isSetter) { |
| 225 IndexedFunction setter = member; | 206 IndexedFunction setter = member; |
| 226 return createSetter(member.memberIndex, library, cls, memberName, | 207 return createSetter(library, cls, memberName, |
| 227 isStatic: setter.isStatic, | 208 isStatic: setter.isStatic, |
| 228 isExternal: setter.isExternal, | 209 isExternal: setter.isExternal, |
| 229 isAbstract: setter.isAbstract); | 210 isAbstract: setter.isAbstract); |
| 230 } else { | 211 } else { |
| 231 IndexedFunction function = member; | 212 IndexedFunction function = member; |
| 232 return createMethod(member.memberIndex, library, cls, memberName, | 213 return createMethod(library, cls, memberName, function.parameterStructure, |
| 233 function.parameterStructure, function.asyncMarker, | 214 function.asyncMarker, |
| 234 isStatic: function.isStatic, | 215 isStatic: function.isStatic, |
| 235 isExternal: function.isExternal, | 216 isExternal: function.isExternal, |
| 236 isAbstract: function.isAbstract); | 217 isAbstract: function.isAbstract); |
| 237 } | 218 } |
| 238 } | 219 } |
| 239 } | 220 } |
| 240 | 221 |
| 241 typedef Entity EntityConverter(Entity cls); | 222 typedef Entity EntityConverter(Entity cls); |
| 242 | 223 |
| 243 class TypeConverter implements DartTypeVisitor<DartType, EntityConverter> { | 224 class TypeConverter implements DartTypeVisitor<DartType, EntityConverter> { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 271 } |
| 291 | 272 |
| 292 @override | 273 @override |
| 293 DartType visitVoidType(VoidType type, EntityConverter converter) { | 274 DartType visitVoidType(VoidType type, EntityConverter converter) { |
| 294 return const VoidType(); | 275 return const VoidType(); |
| 295 } | 276 } |
| 296 } | 277 } |
| 297 | 278 |
| 298 const String jsElementPrefix = 'j:'; | 279 const String jsElementPrefix = 'j:'; |
| 299 | 280 |
| 300 class JLibrary implements LibraryEntity, IndexedLibrary { | 281 class JLibrary extends IndexedLibrary { |
| 301 /// Library index used for fast lookup in [JsToFrontendMapImpl]. | |
| 302 final int libraryIndex; | |
| 303 final String name; | 282 final String name; |
| 304 final Uri canonicalUri; | 283 final Uri canonicalUri; |
| 305 | 284 |
| 306 JLibrary(this.libraryIndex, this.name, this.canonicalUri); | 285 JLibrary(this.name, this.canonicalUri); |
| 307 | 286 |
| 308 String toString() => '${jsElementPrefix}library($name)'; | 287 String toString() => '${jsElementPrefix}library($name)'; |
| 309 } | 288 } |
| 310 | 289 |
| 311 class JClass implements ClassEntity, IndexedClass { | 290 class JClass extends IndexedClass { |
| 312 final JLibrary library; | 291 final JLibrary library; |
| 313 | 292 |
| 314 /// Class index used for fast lookup in [JsToFrontendMapImpl]. | |
| 315 final int classIndex; | |
| 316 | |
| 317 final String name; | 293 final String name; |
| 318 final bool isAbstract; | 294 final bool isAbstract; |
| 319 | 295 |
| 320 JClass(this.library, this.classIndex, this.name, {this.isAbstract}); | 296 JClass(this.library, this.name, {this.isAbstract}); |
| 321 | 297 |
| 322 @override | 298 @override |
| 323 bool get isClosure => false; | 299 bool get isClosure => false; |
| 324 | 300 |
| 325 String toString() => '${jsElementPrefix}class($name)'; | 301 String toString() => '${jsElementPrefix}class($name)'; |
| 326 } | 302 } |
| 327 | 303 |
| 328 class JTypedef implements TypedefEntity, IndexedTypedef { | 304 class JTypedef extends IndexedTypedef { |
| 329 final JLibrary library; | 305 final JLibrary library; |
| 330 | 306 |
| 331 /// Typedef index used for fast lookup in [JsToFrontendMapImpl]. | |
| 332 final int typedefIndex; | |
| 333 | |
| 334 final String name; | 307 final String name; |
| 335 | 308 |
| 336 JTypedef(this.library, this.typedefIndex, this.name); | 309 JTypedef(this.library, this.name); |
| 337 | 310 |
| 338 String toString() => '${jsElementPrefix}typedef($name)'; | 311 String toString() => '${jsElementPrefix}typedef($name)'; |
| 339 } | 312 } |
| 340 | 313 |
| 341 abstract class JMember implements MemberEntity, IndexedMember { | 314 abstract class JMember extends IndexedMember { |
| 342 /// Member index used for fast lookup in [JsToFrontendMapImpl]. | |
| 343 final int memberIndex; | |
| 344 final JLibrary library; | 315 final JLibrary library; |
| 345 final JClass enclosingClass; | 316 final JClass enclosingClass; |
| 346 final Name _name; | 317 final Name _name; |
| 347 final bool _isStatic; | 318 final bool _isStatic; |
| 348 | 319 |
| 349 JMember(this.memberIndex, this.library, this.enclosingClass, this._name, | 320 JMember(this.library, this.enclosingClass, this._name, {bool isStatic: false}) |
| 350 {bool isStatic: false}) | |
| 351 : _isStatic = isStatic; | 321 : _isStatic = isStatic; |
| 352 | 322 |
| 353 String get name => _name.text; | 323 String get name => _name.text; |
| 354 | 324 |
| 355 Name get memberName => _name; | 325 Name get memberName => _name; |
| 356 | 326 |
| 357 @override | 327 @override |
| 358 bool get isAssignable => false; | 328 bool get isAssignable => false; |
| 359 | 329 |
| 360 @override | 330 @override |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 String toString() => '${jsElementPrefix}$_kind' | 362 String toString() => '${jsElementPrefix}$_kind' |
| 393 '(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; | 363 '(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; |
| 394 } | 364 } |
| 395 | 365 |
| 396 abstract class JFunction extends JMember | 366 abstract class JFunction extends JMember |
| 397 implements FunctionEntity, IndexedFunction { | 367 implements FunctionEntity, IndexedFunction { |
| 398 final ParameterStructure parameterStructure; | 368 final ParameterStructure parameterStructure; |
| 399 final bool isExternal; | 369 final bool isExternal; |
| 400 final AsyncMarker asyncMarker; | 370 final AsyncMarker asyncMarker; |
| 401 | 371 |
| 402 JFunction(int memberIndex, JLibrary library, JClass enclosingClass, Name name, | 372 JFunction(JLibrary library, JClass enclosingClass, Name name, |
| 403 this.parameterStructure, this.asyncMarker, | 373 this.parameterStructure, this.asyncMarker, |
| 404 {bool isStatic: false, this.isExternal: false}) | 374 {bool isStatic: false, this.isExternal: false}) |
| 405 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); | 375 : super(library, enclosingClass, name, isStatic: isStatic); |
| 406 } | 376 } |
| 407 | 377 |
| 408 abstract class JConstructor extends JFunction | 378 abstract class JConstructor extends JFunction |
| 409 implements ConstructorEntity, IndexedConstructor { | 379 implements ConstructorEntity, IndexedConstructor { |
| 410 final bool isConst; | 380 final bool isConst; |
| 411 | 381 |
| 412 JConstructor(int memberIndex, JClass enclosingClass, Name name, | 382 JConstructor( |
| 413 ParameterStructure parameterStructure, {bool isExternal, this.isConst}) | 383 JClass enclosingClass, Name name, ParameterStructure parameterStructure, |
| 414 : super(memberIndex, enclosingClass.library, enclosingClass, name, | 384 {bool isExternal, this.isConst}) |
| 415 parameterStructure, AsyncMarker.SYNC, | 385 : super(enclosingClass.library, enclosingClass, name, parameterStructure, |
| 386 AsyncMarker.SYNC, |
| 416 isExternal: isExternal); | 387 isExternal: isExternal); |
| 417 | 388 |
| 418 @override | 389 @override |
| 419 bool get isConstructor => true; | 390 bool get isConstructor => true; |
| 420 | 391 |
| 421 @override | 392 @override |
| 422 bool get isInstanceMember => false; | 393 bool get isInstanceMember => false; |
| 423 | 394 |
| 424 @override | 395 @override |
| 425 bool get isStatic => false; | 396 bool get isStatic => false; |
| 426 | 397 |
| 427 @override | 398 @override |
| 428 bool get isTopLevel => false; | 399 bool get isTopLevel => false; |
| 429 | 400 |
| 430 @override | 401 @override |
| 431 bool get isFromEnvironmentConstructor => false; | 402 bool get isFromEnvironmentConstructor => false; |
| 432 | 403 |
| 433 String get _kind => 'constructor'; | 404 String get _kind => 'constructor'; |
| 434 } | 405 } |
| 435 | 406 |
| 436 class JGenerativeConstructor extends JConstructor { | 407 class JGenerativeConstructor extends JConstructor { |
| 437 JGenerativeConstructor(int constructorIndex, JClass enclosingClass, Name name, | 408 JGenerativeConstructor( |
| 438 ParameterStructure parameterStructure, {bool isExternal, bool isConst}) | 409 JClass enclosingClass, Name name, ParameterStructure parameterStructure, |
| 439 : super(constructorIndex, enclosingClass, name, parameterStructure, | 410 {bool isExternal, bool isConst}) |
| 411 : super(enclosingClass, name, parameterStructure, |
| 440 isExternal: isExternal, isConst: isConst); | 412 isExternal: isExternal, isConst: isConst); |
| 441 | 413 |
| 442 @override | 414 @override |
| 443 bool get isFactoryConstructor => false; | 415 bool get isFactoryConstructor => false; |
| 444 | 416 |
| 445 @override | 417 @override |
| 446 bool get isGenerativeConstructor => true; | 418 bool get isGenerativeConstructor => true; |
| 447 } | 419 } |
| 448 | 420 |
| 449 class JFactoryConstructor extends JConstructor { | 421 class JFactoryConstructor extends JConstructor { |
| 450 @override | 422 @override |
| 451 final bool isFromEnvironmentConstructor; | 423 final bool isFromEnvironmentConstructor; |
| 452 | 424 |
| 453 JFactoryConstructor(int memberIndex, JClass enclosingClass, Name name, | 425 JFactoryConstructor( |
| 454 ParameterStructure parameterStructure, | 426 JClass enclosingClass, Name name, ParameterStructure parameterStructure, |
| 455 {bool isExternal, bool isConst, this.isFromEnvironmentConstructor}) | 427 {bool isExternal, bool isConst, this.isFromEnvironmentConstructor}) |
| 456 : super(memberIndex, enclosingClass, name, parameterStructure, | 428 : super(enclosingClass, name, parameterStructure, |
| 457 isExternal: isExternal, isConst: isConst); | 429 isExternal: isExternal, isConst: isConst); |
| 458 | 430 |
| 459 @override | 431 @override |
| 460 bool get isFactoryConstructor => true; | 432 bool get isFactoryConstructor => true; |
| 461 | 433 |
| 462 @override | 434 @override |
| 463 bool get isGenerativeConstructor => false; | 435 bool get isGenerativeConstructor => false; |
| 464 } | 436 } |
| 465 | 437 |
| 466 class JConstructorBody extends JFunction implements ConstructorBodyEntity { | 438 class JConstructorBody extends JFunction implements ConstructorBodyEntity { |
| 467 final ConstructorEntity constructor; | 439 final ConstructorEntity constructor; |
| 468 | 440 |
| 469 JConstructorBody(int memberIndex, this.constructor) | 441 JConstructorBody(this.constructor) |
| 470 : super( | 442 : super( |
| 471 memberIndex, | |
| 472 constructor.library, | 443 constructor.library, |
| 473 constructor.enclosingClass, | 444 constructor.enclosingClass, |
| 474 constructor.memberName, | 445 constructor.memberName, |
| 475 constructor.parameterStructure, | 446 constructor.parameterStructure, |
| 476 AsyncMarker.SYNC, | 447 AsyncMarker.SYNC, |
| 477 isStatic: false, | 448 isStatic: false, |
| 478 isExternal: false); | 449 isExternal: false); |
| 479 | 450 |
| 480 String get _kind => 'constructor_body'; | 451 String get _kind => 'constructor_body'; |
| 481 } | 452 } |
| 482 | 453 |
| 483 class JMethod extends JFunction { | 454 class JMethod extends JFunction { |
| 484 final bool isAbstract; | 455 final bool isAbstract; |
| 485 | 456 |
| 486 JMethod(int memberIndex, JLibrary library, JClass enclosingClass, Name name, | 457 JMethod(JLibrary library, JClass enclosingClass, Name name, |
| 487 ParameterStructure parameterStructure, AsyncMarker asyncMarker, | 458 ParameterStructure parameterStructure, AsyncMarker asyncMarker, |
| 488 {bool isStatic, bool isExternal, this.isAbstract}) | 459 {bool isStatic, bool isExternal, this.isAbstract}) |
| 489 : super(memberIndex, library, enclosingClass, name, parameterStructure, | 460 : super(library, enclosingClass, name, parameterStructure, asyncMarker, |
| 490 asyncMarker, | |
| 491 isStatic: isStatic, isExternal: isExternal); | 461 isStatic: isStatic, isExternal: isExternal); |
| 492 | 462 |
| 493 @override | 463 @override |
| 494 bool get isFunction => true; | 464 bool get isFunction => true; |
| 495 | 465 |
| 496 String get _kind => 'method'; | 466 String get _kind => 'method'; |
| 497 } | 467 } |
| 498 | 468 |
| 499 class JGetter extends JFunction { | 469 class JGetter extends JFunction { |
| 500 final bool isAbstract; | 470 final bool isAbstract; |
| 501 | 471 |
| 502 JGetter(int memberIndex, JLibrary library, JClass enclosingClass, Name name, | 472 JGetter(JLibrary library, JClass enclosingClass, Name name, |
| 503 AsyncMarker asyncMarker, | 473 AsyncMarker asyncMarker, |
| 504 {bool isStatic, bool isExternal, this.isAbstract}) | 474 {bool isStatic, bool isExternal, this.isAbstract}) |
| 505 : super(memberIndex, library, enclosingClass, name, | 475 : super(library, enclosingClass, name, const ParameterStructure.getter(), |
| 506 const ParameterStructure.getter(), asyncMarker, | 476 asyncMarker, |
| 507 isStatic: isStatic, isExternal: isExternal); | 477 isStatic: isStatic, isExternal: isExternal); |
| 508 | 478 |
| 509 @override | 479 @override |
| 510 bool get isGetter => true; | 480 bool get isGetter => true; |
| 511 | 481 |
| 512 String get _kind => 'getter'; | 482 String get _kind => 'getter'; |
| 513 } | 483 } |
| 514 | 484 |
| 515 class JSetter extends JFunction { | 485 class JSetter extends JFunction { |
| 516 final bool isAbstract; | 486 final bool isAbstract; |
| 517 | 487 |
| 518 JSetter(int memberIndex, JLibrary library, JClass enclosingClass, Name name, | 488 JSetter(JLibrary library, JClass enclosingClass, Name name, |
| 519 {bool isStatic, bool isExternal, this.isAbstract}) | 489 {bool isStatic, bool isExternal, this.isAbstract}) |
| 520 : super(memberIndex, library, enclosingClass, name, | 490 : super(library, enclosingClass, name, const ParameterStructure.setter(), |
| 521 const ParameterStructure.setter(), AsyncMarker.SYNC, | 491 AsyncMarker.SYNC, |
| 522 isStatic: isStatic, isExternal: isExternal); | 492 isStatic: isStatic, isExternal: isExternal); |
| 523 | 493 |
| 524 @override | 494 @override |
| 525 bool get isAssignable => true; | 495 bool get isAssignable => true; |
| 526 | 496 |
| 527 @override | 497 @override |
| 528 bool get isSetter => true; | 498 bool get isSetter => true; |
| 529 | 499 |
| 530 String get _kind => 'setter'; | 500 String get _kind => 'setter'; |
| 531 } | 501 } |
| 532 | 502 |
| 533 class JField extends JMember implements FieldEntity, IndexedField { | 503 class JField extends JMember implements FieldEntity, IndexedField { |
| 534 final bool isAssignable; | 504 final bool isAssignable; |
| 535 final bool isConst; | 505 final bool isConst; |
| 536 | 506 |
| 537 JField(int memberIndex, JLibrary library, JClass enclosingClass, Name name, | 507 JField(JLibrary library, JClass enclosingClass, Name name, |
| 538 {bool isStatic, this.isAssignable, this.isConst}) | 508 {bool isStatic, this.isAssignable, this.isConst}) |
| 539 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); | 509 : super(library, enclosingClass, name, isStatic: isStatic); |
| 540 | 510 |
| 541 @override | 511 @override |
| 542 bool get isField => true; | 512 bool get isField => true; |
| 543 | 513 |
| 544 String get _kind => 'field'; | 514 String get _kind => 'field'; |
| 545 } | 515 } |
| 546 | 516 |
| 547 class JClosureCallMethod extends JMethod { | 517 class JClosureCallMethod extends JMethod { |
| 548 JClosureCallMethod(int memberIndex, KernelClosureClass containingClass, | 518 JClosureCallMethod(KernelClosureClass containingClass, |
| 549 ParameterStructure parameterStructure, AsyncMarker asyncMarker) | 519 ParameterStructure parameterStructure, AsyncMarker asyncMarker) |
| 550 : super( | 520 : super( |
| 551 memberIndex, | |
| 552 containingClass.closureClassEntity.library, | 521 containingClass.closureClassEntity.library, |
| 553 containingClass.closureClassEntity, | 522 containingClass.closureClassEntity, |
| 554 Names.call, | 523 Names.call, |
| 555 parameterStructure, | 524 parameterStructure, |
| 556 asyncMarker, | 525 asyncMarker, |
| 557 isStatic: false, | 526 isStatic: false, |
| 558 isExternal: false, | 527 isExternal: false, |
| 559 isAbstract: false); | 528 isAbstract: false); |
| 560 | 529 |
| 561 String get _kind => 'closure_call'; | 530 String get _kind => 'closure_call'; |
| 562 } | 531 } |
| 563 | 532 |
| 564 class JTypeVariable implements TypeVariableEntity, IndexedTypeVariable { | 533 class JTypeVariable extends IndexedTypeVariable { |
| 565 final int typeVariableIndex; | |
| 566 final Entity typeDeclaration; | 534 final Entity typeDeclaration; |
| 567 final String name; | 535 final String name; |
| 568 final int index; | 536 final int index; |
| 569 | 537 |
| 570 JTypeVariable( | 538 JTypeVariable(this.typeDeclaration, this.name, this.index); |
| 571 this.typeVariableIndex, this.typeDeclaration, this.name, this.index); | |
| 572 | 539 |
| 573 String toString() => | 540 String toString() => |
| 574 '${jsElementPrefix}type_variable(${typeDeclaration.name}.$name)'; | 541 '${jsElementPrefix}type_variable(${typeDeclaration.name}.$name)'; |
| 575 } | 542 } |
| OLD | NEW |