| OLD | NEW |
| 1 // (c) 2015, the Dart Team. All rights reserved. Use of this | 1 // (c) 2015, the Dart Team. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in | 2 // source code is governed by a BSD-style license that can be found in |
| 3 // the LICENSE file. | 3 // the LICENSE file. |
| 4 | 4 |
| 5 library reflectable.src.transformer_implementation; | 5 library reflectable.src.transformer_implementation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 /// Libraries that must be imported to `reflector.library`. | 94 /// Libraries that must be imported to `reflector.library`. |
| 95 final Set<LibraryElement> _missingImports = new Set<LibraryElement>(); | 95 final Set<LibraryElement> _missingImports = new Set<LibraryElement>(); |
| 96 | 96 |
| 97 _ReflectorDomain(this._reflector, this._capabilities) {} | 97 _ReflectorDomain(this._reflector, this._capabilities) {} |
| 98 | 98 |
| 99 // TODO(eernst) future: Perhaps reconsider what the best strategy | 99 // TODO(eernst) future: Perhaps reconsider what the best strategy |
| 100 // for caching is. | 100 // for caching is. |
| 101 Map<ClassElement, Map<String, ExecutableElement>> _instanceMemberCache = | 101 Map<ClassElement, Map<String, ExecutableElement>> _instanceMemberCache = |
| 102 new Map<ClassElement, Map<String, ExecutableElement>>(); | 102 new Map<ClassElement, Map<String, ExecutableElement>>(); |
| 103 | 103 |
| 104 Map<ClassElement, Map<String, ExecutableElement>> _staticMemberCache = |
| 105 new Map<ClassElement, Map<String, ExecutableElement>>(); |
| 106 |
| 104 /// Returns a string that evaluates to a closure invoking [constructor] with | 107 /// Returns a string that evaluates to a closure invoking [constructor] with |
| 105 /// the given arguments. | 108 /// the given arguments. |
| 106 /// [importCollector] is used to record all the imports needed to make the | 109 /// [importCollector] is used to record all the imports needed to make the |
| 107 /// constant. | 110 /// constant. |
| 108 /// This is to provide something that can be called with [Function.apply]. | 111 /// This is to provide something that can be called with [Function.apply]. |
| 109 /// | 112 /// |
| 110 /// For example for a constructor Foo(x, {y: 3}): | 113 /// For example for a constructor Foo(x, {y: 3}): |
| 111 /// returns "(x, {y: 3}) => new prefix1.Foo(x, y)", and records an import of | 114 /// returns "(x, {y: 3}) => new prefix1.Foo(x, y)", and records an import of |
| 112 /// the library of `Foo` associated with prefix1 in [importCollector]. | 115 /// the library of `Foo` associated with prefix1 in [importCollector]. |
| 113 String _constructorCode( | 116 String _constructorCode( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Add all the formal parameters (as a single, global set) which | 216 // Add all the formal parameters (as a single, global set) which |
| 214 // are declared by any of the methods in `classDomain._declarations`. | 217 // are declared by any of the methods in `classDomain._declarations`. |
| 215 classDomain._declaredParameters.forEach(parameters.add); | 218 classDomain._declaredParameters.forEach(parameters.add); |
| 216 | 219 |
| 217 // Gather the fields declared in the target class (not inherited | 220 // Gather the fields declared in the target class (not inherited |
| 218 // ones) in [fields], i.e., the elements missing from [members] | 221 // ones) in [fields], i.e., the elements missing from [members] |
| 219 // at this point, in order to support `declarations` in a | 222 // at this point, in order to support `declarations` in a |
| 220 // [ClassMirror]. | 223 // [ClassMirror]. |
| 221 classDomain._declaredFields.forEach(fields.add); | 224 classDomain._declaredFields.forEach(fields.add); |
| 222 | 225 |
| 223 // Gather all getters and setters based on [instanceMembers], including | 226 // Gather all getter and setter names based on [instanceMembers], |
| 224 // both explicitly declared ones, implicitly generated ones for fields, | 227 // including both explicitly declared ones, implicitly generated ones |
| 225 // and the implicitly generated ones that correspond to method tear-offs. | 228 // for fields, and the implicitly generated ones that correspond to |
| 229 // method tear-offs. |
| 226 classDomain._instanceMembers.forEach((ExecutableElement instanceMember) { | 230 classDomain._instanceMembers.forEach((ExecutableElement instanceMember) { |
| 227 if (instanceMember is PropertyAccessorElement) { | 231 if (instanceMember is PropertyAccessorElement) { |
| 228 // A getter or a setter, synthetic or declared. | 232 // A getter or a setter, synthetic or declared. |
| 229 if (instanceMember.isGetter) { | 233 if (instanceMember.isGetter) { |
| 230 instanceGetterNames.add(instanceMember.name); | 234 instanceGetterNames.add(instanceMember.name); |
| 231 } else { | 235 } else { |
| 232 instanceSetterNames.add(instanceMember.name); | 236 instanceSetterNames.add(instanceMember.name); |
| 233 } | 237 } |
| 234 } else if (instanceMember is MethodElement) { | 238 } else if (instanceMember is MethodElement) { |
| 235 instanceGetterNames.add(instanceMember.name); | 239 instanceGetterNames.add(instanceMember.name); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 int classIndex = 0; | 342 int classIndex = 0; |
| 339 String classMirrorsCode = | 343 String classMirrorsCode = |
| 340 _formatAsList(includedClasses.map((_ClassDomain classDomain) { | 344 _formatAsList(includedClasses.map((_ClassDomain classDomain) { |
| 341 // Fields go first in [memberMirrors], so they will get the | 345 // Fields go first in [memberMirrors], so they will get the |
| 342 // same index as in [fields]. | 346 // same index as in [fields]. |
| 343 Iterable<int> fieldsIndices = | 347 Iterable<int> fieldsIndices = |
| 344 classDomain._declaredFields.map((FieldElement element) { | 348 classDomain._declaredFields.map((FieldElement element) { |
| 345 return fields.indexOf(element); | 349 return fields.indexOf(element); |
| 346 }); | 350 }); |
| 347 | 351 |
| 348 int fieldsLength = fields.length; | |
| 349 | |
| 350 // All the elements in the behavioral interface go after the | 352 // All the elements in the behavioral interface go after the |
| 351 // fields in [memberMirrors], so they must get an offset of | 353 // fields in [memberMirrors], so they must get an offset of |
| 352 // `fields.length` on the index. | 354 // `fields.length` on the index. |
| 353 Iterable<int> methodsIndices = classDomain._declarations | 355 Iterable<int> methodsIndices = classDomain._declarations |
| 354 .where(_executableIsntImplicitGetterOrSetter) | 356 .where(_executableIsntImplicitGetterOrSetter) |
| 355 .map((ExecutableElement element) { | 357 .map((ExecutableElement element) { |
| 356 // TODO(eernst) implement: The "magic" default constructor in `Object` | 358 // TODO(eernst) implement: The "magic" default constructor in `Object` |
| 357 // (the one that ultimately allocates the memory for _every_ new object) | 359 // (the one that ultimately allocates the memory for _every_ new object) |
| 358 // has no index, which creates the need to catch a `null` here. | 360 // has no index, which creates the need to catch a `null` here. |
| 359 // Search for "magic" to find other occurrences of the same issue. | 361 // Search for "magic" to find other occurrences of the same issue. |
| 360 // For now, we provide the index -1 for this declaration, because | 362 // For now, we provide the index -1 for this declaration, because |
| 361 // it is not yet supported. Need to find the correct solution, though! | 363 // it is not yet supported. Need to find the correct solution, though! |
| 362 int index = members.indexOf(element); | 364 int index = members.indexOf(element); |
| 363 return index == null ? -1 : index + fieldsLength; | 365 return index == null ? -1 : index + fields.length; |
| 364 }); | 366 }); |
| 365 | 367 |
| 366 String declarationsCode = "<int>[-1]"; // Encodes no capability. | 368 String declarationsCode = "<int>[-1]"; // Encodes no capability. |
| 367 if (_capabilities._impliesDeclarations) { | 369 if (_capabilities._impliesDeclarations) { |
| 368 List<int> declarationsIndices = <int>[] | 370 List<int> declarationsIndices = <int>[] |
| 369 ..addAll(fieldsIndices) | 371 ..addAll(fieldsIndices) |
| 370 ..addAll(methodsIndices); | 372 ..addAll(methodsIndices); |
| 371 declarationsCode = _formatAsList(declarationsIndices); | 373 declarationsCode = _formatAsList(declarationsIndices); |
| 372 } | 374 } |
| 373 | 375 |
| 374 // All instance members belong to the behavioral interface, so they | 376 // All instance members belong to the behavioral interface, so they |
| 375 // also get an offset of `fields.length`. | 377 // also get an offset of `fields.length`. |
| 376 String instanceMembersCode = _formatAsList( | 378 String instanceMembersCode = _formatAsList( |
| 377 classDomain._instanceMembers.map((ExecutableElement element) { | 379 classDomain._instanceMembers.map((ExecutableElement element) { |
| 378 // TODO(eernst) implement: The "magic" default constructor has | 380 // TODO(eernst) implement: The "magic" default constructor has |
| 379 // index: -1; adjust this when support for it has been implemented. | 381 // index: -1; adjust this when support for it has been implemented. |
| 380 int index = members.indexOf(element); | 382 int index = members.indexOf(element); |
| 381 return index == null ? -1 : index + fieldsLength; | 383 return index == null ? -1 : index + fields.length; |
| 384 })); |
| 385 |
| 386 // All static members belong to the behavioral interface, so they |
| 387 // also get an offset of `fields.length`. |
| 388 String staticMembersCode = _formatAsList( |
| 389 classDomain._staticMembers.map((ExecutableElement element) { |
| 390 int index = members.indexOf(element); |
| 391 return index == null ? -1 : index + fields.length; |
| 382 })); | 392 })); |
| 383 | 393 |
| 384 InterfaceType superType = classDomain._classElement.supertype; | 394 InterfaceType superType = classDomain._classElement.supertype; |
| 385 ClassElement superclass = superType == null ? null : superType.element; | 395 ClassElement superclass = superType == null ? null : superType.element; |
| 386 String superclassIndex; | 396 String superclassIndex; |
| 387 if (superclass == null) { | 397 if (superclass == null) { |
| 388 superclassIndex = null; | 398 superclassIndex = null; |
| 389 } else { | 399 } else { |
| 390 int index = classes.indexOf(superclass); | 400 int index = classes.indexOf(superclass); |
| 391 if (index == null) { | 401 if (index == null) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 staticGettingClosure(classDomain._classElement, element.name))); | 435 staticGettingClosure(classDomain._classElement, element.name))); |
| 426 String staticSettersCode = _formatAsMap(classDomain | 436 String staticSettersCode = _formatAsMap(classDomain |
| 427 ._declaredAndImplicitAccessors | 437 ._declaredAndImplicitAccessors |
| 428 .where((PropertyAccessorElement element) => | 438 .where((PropertyAccessorElement element) => |
| 429 element.isStatic && element.isSetter) | 439 element.isStatic && element.isSetter) |
| 430 .map((PropertyAccessorElement element) => | 440 .map((PropertyAccessorElement element) => |
| 431 _staticSettingClosure(classDomain._classElement, element.name))); | 441 _staticSettingClosure(classDomain._classElement, element.name))); |
| 432 String result = 'new r.ClassMirrorImpl(r"${classDomain._simpleName}", ' | 442 String result = 'new r.ClassMirrorImpl(r"${classDomain._simpleName}", ' |
| 433 'r"${classDomain._qualifiedName}", $classIndex, ' | 443 'r"${classDomain._qualifiedName}", $classIndex, ' |
| 434 '${_constConstructionCode(importCollector)}, ' | 444 '${_constConstructionCode(importCollector)}, ' |
| 435 '$declarationsCode, $instanceMembersCode, $superclassIndex, ' | 445 '$declarationsCode, $instanceMembersCode, $staticMembersCode, ' |
| 436 '$staticGettersCode, $staticSettersCode, $constructorsCode, ' | 446 '$superclassIndex, $staticGettersCode, $staticSettersCode, ' |
| 437 '$classMetadataCode)'; | 447 '$constructorsCode, $classMetadataCode)'; |
| 438 classIndex++; | 448 classIndex++; |
| 439 return result; | 449 return result; |
| 440 })); | 450 })); |
| 441 | 451 |
| 442 String gettersCode = _formatAsMap(instanceGetterNames.map(gettingClosure)); | 452 String gettersCode = _formatAsMap(instanceGetterNames.map(gettingClosure)); |
| 443 String settersCode = _formatAsMap(instanceSetterNames.map(settingClosure)); | 453 String settersCode = _formatAsMap(instanceSetterNames.map(settingClosure)); |
| 444 | 454 |
| 445 Iterable<String> methodsList = | 455 Iterable<String> methodsList = |
| 446 members.items.map((ExecutableElement element) { | 456 members.items.map((ExecutableElement element) { |
| 447 int descriptor = _declarationDescriptor(element); | 457 if (element is PropertyAccessorElement && element.isSynthetic) { |
| 448 int ownerIndex = classes.indexOf(element.enclosingElement); | 458 // There is no type propagation, so we declare an `accessorElement`. |
| 449 Iterable<int> parameterIndices = | 459 PropertyAccessorElement accessorElement = element; |
| 450 element.parameters.map((ParameterElement parameterElement) { | 460 int variableMirrorIndex = fields.indexOf(accessorElement.variable); |
| 451 return parameters.indexOf(parameterElement); | 461 // The `indexOf` is non-null: `accessorElement` came from `members`. |
| 452 }); | 462 int selfIndex = members.indexOf(accessorElement) + fields.length; |
| 453 String parameterIndicesCode = _formatAsList(parameterIndices); | 463 if (accessorElement.isGetter) { |
| 454 String metadataCode; | 464 return 'new r.ImplicitGetterMirrorImpl(' |
| 455 if (_capabilities._supportsMetadata) { | 465 '${_constConstructionCode(importCollector)}, ' |
| 456 metadataCode = _extractMetadataCode( | 466 '$variableMirrorIndex, $selfIndex)'; |
| 457 element, resolver, importCollector, logger, dataId); | 467 } else { |
| 468 assert(accessorElement.isSetter); |
| 469 return 'new r.ImplicitSetterMirrorImpl(' |
| 470 '${_constConstructionCode(importCollector)}, ' |
| 471 '$variableMirrorIndex, $selfIndex)'; |
| 472 } |
| 458 } else { | 473 } else { |
| 459 metadataCode = null; | 474 int descriptor = _declarationDescriptor(element); |
| 475 int returnTypeIndex = classes._contains(element.returnType.element) |
| 476 ? classes.indexOf(element.returnType.element) |
| 477 : -1; |
| 478 int ownerIndex = classes.indexOf(element.enclosingElement); |
| 479 String parameterIndicesCode = _formatAsList( |
| 480 element.parameters.map((ParameterElement parameterElement) { |
| 481 return parameters.indexOf(parameterElement); |
| 482 })); |
| 483 String metadataCode = _capabilities._supportsMetadata |
| 484 ? _extractMetadataCode( |
| 485 element, resolver, importCollector, logger, dataId) |
| 486 : null; |
| 487 return 'new r.MethodMirrorImpl(r"${element.name}", $descriptor, ' |
| 488 '$ownerIndex, $returnTypeIndex, $parameterIndicesCode, ' |
| 489 '${_constConstructionCode(importCollector)}, $metadataCode)'; |
| 460 } | 490 } |
| 461 return 'new r.MethodMirrorImpl(r"${element.name}", $descriptor, ' | |
| 462 '$ownerIndex, $parameterIndicesCode, ' | |
| 463 '${_constConstructionCode(importCollector)}, $metadataCode)'; | |
| 464 }); | 491 }); |
| 465 | 492 |
| 466 Iterable<String> fieldsList = fields.items.map((FieldElement element) { | 493 Iterable<String> fieldsList = fields.items.map((FieldElement element) { |
| 467 int descriptor = _fieldDescriptor(element); | 494 int descriptor = _fieldDescriptor(element); |
| 468 int ownerIndex = classes.indexOf(element.enclosingElement); | 495 int ownerIndex = classes.indexOf(element.enclosingElement); |
| 469 int classMirrorIndex = classes._contains(element.type.element) | 496 int classMirrorIndex = classes._contains(element.type.element) |
| 470 ? classes.indexOf(element.type.element) | 497 ? classes.indexOf(element.type.element) |
| 471 : -1; | 498 : -1; |
| 472 String metadataCode; | 499 String metadataCode; |
| 473 if (_capabilities._supportsMetadata) { | 500 if (_capabilities._supportsMetadata) { |
| 474 metadataCode = _extractMetadataCode( | 501 metadataCode = _extractMetadataCode( |
| 475 element, resolver, importCollector, logger, dataId); | 502 element, resolver, importCollector, logger, dataId); |
| 476 } else { | 503 } else { |
| 477 metadataCode = null; | 504 metadataCode = null; |
| 478 } | 505 } |
| 479 return 'new r.VariableMirrorImpl(r"${element.name}", $descriptor, ' | 506 return 'new r.VariableMirrorImpl(r"${element.name}", $descriptor, ' |
| 480 '$ownerIndex, ${_constConstructionCode(importCollector)}, ' | 507 '$ownerIndex, ${_constConstructionCode(importCollector)}, ' |
| 481 '$classMirrorIndex, $metadataCode)'; | 508 '$classMirrorIndex, $metadataCode)'; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (member.isPrivate) return; | 617 if (member.isPrivate) return; |
| 591 // If [member] is a synthetic accessor created from a field, search for | 618 // If [member] is a synthetic accessor created from a field, search for |
| 592 // the metadata on the original field. | 619 // the metadata on the original field. |
| 593 List<ElementAnnotation> metadata = (member is PropertyAccessorElement && | 620 List<ElementAnnotation> metadata = (member is PropertyAccessorElement && |
| 594 member.isSynthetic) ? member.variable.metadata : member.metadata; | 621 member.isSynthetic) ? member.variable.metadata : member.metadata; |
| 595 if (_reflectorDomain._capabilities | 622 if (_reflectorDomain._capabilities |
| 596 .supportsInstanceInvoke(member.name, metadata)) { | 623 .supportsInstanceInvoke(member.name, metadata)) { |
| 597 result[member.name] = member; | 624 result[member.name] = member; |
| 598 } | 625 } |
| 599 } | 626 } |
| 627 |
| 600 if (classElement.supertype != null) { | 628 if (classElement.supertype != null) { |
| 601 helper(classElement.supertype.element) | 629 helper(classElement.supertype.element) |
| 602 .forEach((String name, ExecutableElement member) { | 630 .forEach((String name, ExecutableElement member) { |
| 603 addIfCapable(member); | 631 addIfCapable(member); |
| 604 }); | 632 }); |
| 605 } | 633 } |
| 606 for (InterfaceType mixin in classElement.mixins) { | 634 for (InterfaceType mixin in classElement.mixins) { |
| 607 helper(mixin.element).forEach((String name, ExecutableElement member) { | 635 helper(mixin.element).forEach((String name, ExecutableElement member) { |
| 608 addIfCapable(member); | 636 addIfCapable(member); |
| 609 }); | 637 }); |
| 610 } | 638 } |
| 611 for (MethodElement member in classElement.methods) { | 639 for (MethodElement member in classElement.methods) { |
| 612 if (member.isAbstract || member.isStatic) continue; | 640 if (member.isAbstract || member.isStatic) continue; |
| 613 addIfCapable(member); | 641 addIfCapable(member); |
| 614 } | 642 } |
| 615 for (PropertyAccessorElement member in classElement.accessors) { | 643 for (PropertyAccessorElement member in classElement.accessors) { |
| 616 if (member.isAbstract || member.isStatic) continue; | 644 if (member.isAbstract || member.isStatic) continue; |
| 617 addIfCapable(member); | 645 addIfCapable(member); |
| 618 } | 646 } |
| 619 return result; | 647 return result; |
| 620 } | 648 } |
| 649 |
| 621 return helper(_classElement).values; | 650 return helper(_classElement).values; |
| 622 } | 651 } |
| 623 | 652 |
| 653 /// Finds all static members. |
| 654 Iterable<ExecutableElement> get _staticMembers { |
| 655 Map<String, ExecutableElement> helper(ClassElement classElement) { |
| 656 if (_reflectorDomain._staticMemberCache[classElement] != null) { |
| 657 return _reflectorDomain._staticMemberCache[classElement]; |
| 658 } |
| 659 Map<String, ExecutableElement> result = |
| 660 new Map<String, ExecutableElement>(); |
| 661 |
| 662 void addIfCapable(ExecutableElement member) { |
| 663 if (member.isPrivate) return; |
| 664 // If [member] is a synthetic accessor created from a field, search for |
| 665 // the metadata on the original field. |
| 666 List<ElementAnnotation> metadata = (member is PropertyAccessorElement && |
| 667 member.isSynthetic) ? member.variable.metadata : member.metadata; |
| 668 if (_reflectorDomain._capabilities |
| 669 .supportsInstanceInvoke(member.name, metadata)) { |
| 670 result[member.name] = member; |
| 671 } |
| 672 } |
| 673 |
| 674 for (MethodElement member in classElement.methods) { |
| 675 if (member.isAbstract || !member.isStatic) continue; |
| 676 addIfCapable(member); |
| 677 } |
| 678 for (PropertyAccessorElement member in classElement.accessors) { |
| 679 if (member.isAbstract || !member.isStatic) continue; |
| 680 addIfCapable(member); |
| 681 } |
| 682 return result; |
| 683 } |
| 684 |
| 685 return helper(_classElement).values; |
| 686 } |
| 687 |
| 624 String toString() { | 688 String toString() { |
| 625 return "ClassDomain($_classElement)"; | 689 return "ClassDomain($_classElement)"; |
| 626 } | 690 } |
| 627 | 691 |
| 628 bool operator ==(Object other) { | 692 bool operator ==(Object other) { |
| 629 if (other is _ClassDomain) { | 693 if (other is _ClassDomain) { |
| 630 return _classElement == other._classElement && | 694 return _classElement == other._classElement && |
| 631 _reflectorDomain == other._reflectorDomain; | 695 _reflectorDomain == other._reflectorDomain; |
| 632 } else { | 696 } else { |
| 633 return false; | 697 return false; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } else if (element is PropertyAccessorElement) { | 1052 } else if (element is PropertyAccessorElement) { |
| 989 PropertyInducingElement variable = element.variable; | 1053 PropertyInducingElement variable = element.variable; |
| 990 // Surprisingly, we have to use [ConstTopLevelVariableElementImpl] | 1054 // Surprisingly, we have to use [ConstTopLevelVariableElementImpl] |
| 991 // here (or a similar type). This is because none of the "public name" | 1055 // here (or a similar type). This is because none of the "public name" |
| 992 // types (types whose name does not end in `..Impl`) declare the getter | 1056 // types (types whose name does not end in `..Impl`) declare the getter |
| 993 // `evaluationResult`. Another possible choice of type would be | 1057 // `evaluationResult`. Another possible choice of type would be |
| 994 // [VariableElementImpl], but with that one we would have to test | 1058 // [VariableElementImpl], but with that one we would have to test |
| 995 // `isConst` as well. | 1059 // `isConst` as well. |
| 996 if (variable is ConstTopLevelVariableElementImpl) { | 1060 if (variable is ConstTopLevelVariableElementImpl) { |
| 997 EvaluationResultImpl result = variable.evaluationResult; | 1061 EvaluationResultImpl result = variable.evaluationResult; |
| 998 if (result.value == null) return null; // Errors during evaluation. | 1062 if (result.value == null) return null; // Errors during evaluation. |
| 999 bool isOk = checkInheritance(result.value.type, focusClass.type); | 1063 bool isOk = checkInheritance(result.value.type, focusClass.type); |
| 1000 return isOk ? result.value.type.element : null; | 1064 return isOk ? result.value.type.element : null; |
| 1001 } else { | 1065 } else { |
| 1002 // Not a const top level variable, not relevant. | 1066 // Not a const top level variable, not relevant. |
| 1003 return null; | 1067 return null; |
| 1004 } | 1068 } |
| 1005 } | 1069 } |
| 1006 // Otherwise [element] is some other construct which is not supported. | 1070 // Otherwise [element] is some other construct which is not supported. |
| 1007 // | 1071 // |
| 1008 // TODO(eernst) clarify: We need to consider whether there could be some | 1072 // TODO(eernst) clarify: We need to consider whether there could be some |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 | 1572 |
| 1509 String originalEntryPointFilename = | 1573 String originalEntryPointFilename = |
| 1510 path.basename(originalEntryPointId.path); | 1574 path.basename(originalEntryPointId.path); |
| 1511 | 1575 |
| 1512 LibraryElement entryPointLibrary = | 1576 LibraryElement entryPointLibrary = |
| 1513 _resolver.getLibrary(entryPointAsset.id); | 1577 _resolver.getLibrary(entryPointAsset.id); |
| 1514 | 1578 |
| 1515 // Generate a new file with the name of the entry-point, whose main | 1579 // Generate a new file with the name of the entry-point, whose main |
| 1516 // initializes the reflection data, and calls the main from | 1580 // initializes the reflection data, and calls the main from |
| 1517 // [originalEntryPointId]. | 1581 // [originalEntryPointId]. |
| 1518 aggregateTransform.addOutput(new Asset.fromString(entryPointAsset.id, | 1582 aggregateTransform.addOutput(new Asset.fromString( |
| 1583 entryPointAsset.id, |
| 1519 _generateNewEntryPoint(world, entryPointAsset.id, | 1584 _generateNewEntryPoint(world, entryPointAsset.id, |
| 1520 originalEntryPointFilename, entryPointLibrary))); | 1585 originalEntryPointFilename, entryPointLibrary))); |
| 1521 _resolver.release(); | 1586 _resolver.release(); |
| 1522 } | 1587 } |
| 1523 } | 1588 } |
| 1524 } | 1589 } |
| 1525 | 1590 |
| 1526 /// Wrapper of `AggregateTransform` of type `Transform`, allowing us to | 1591 /// Wrapper of `AggregateTransform` of type `Transform`, allowing us to |
| 1527 /// get a `Resolver` for a given `AggregateTransform` with a given | 1592 /// get a `Resolver` for a given `AggregateTransform` with a given |
| 1528 /// selection of a primary entry point. | 1593 /// selection of a primary entry point. |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 List<ConstructorElement> declaredConstructorsOfClass = | 1976 List<ConstructorElement> declaredConstructorsOfClass = |
| 1912 _declaredConstructors(type, domain._capabilities).toList(); | 1977 _declaredConstructors(type, domain._capabilities).toList(); |
| 1913 return new _ClassDomain( | 1978 return new _ClassDomain( |
| 1914 type, | 1979 type, |
| 1915 declaredFieldsOfClass, | 1980 declaredFieldsOfClass, |
| 1916 declaredMethodsOfClass, | 1981 declaredMethodsOfClass, |
| 1917 declaredParametersOfClass, | 1982 declaredParametersOfClass, |
| 1918 declaredAndImplicitAccessorsOfClass, | 1983 declaredAndImplicitAccessorsOfClass, |
| 1919 declaredConstructorsOfClass, | 1984 declaredConstructorsOfClass, |
| 1920 domain); | 1985 domain); |
| 1921 } | 1986 } |
| OLD | NEW |