|
@@ -456,6 +456,74 @@ public final class TypeMembers {
|
456
|
456
|
return false;
|
457
|
457
|
}
|
458
|
458
|
|
|
459
|
+ public Map<DefinitionMemberRef, IDefinitionMember> borrowInterfaceMembersFromDefinition(Set<IDefinitionMember> implemented, TypeMembers definitionMembers) {
|
|
460
|
+ Map<DefinitionMemberRef, IDefinitionMember> result = new HashMap<>();
|
|
461
|
+
|
|
462
|
+ for (TypeMember<CasterMemberRef> caster : casters) {
|
|
463
|
+ if (implemented.contains(caster.member.member))
|
|
464
|
+ continue;
|
|
465
|
+
|
|
466
|
+ CasterMemberRef implementation = definitionMembers.getCaster(caster.member.toType);
|
|
467
|
+ if (implementation != null)
|
|
468
|
+ result.put(caster.member, implementation.getTarget());
|
|
469
|
+ }
|
|
470
|
+ for (TypeMember<IteratorMemberRef> iterator : iterators) {
|
|
471
|
+ if (implemented.contains(iterator.member.target))
|
|
472
|
+ continue;
|
|
473
|
+
|
|
474
|
+ IteratorMemberRef implementation = definitionMembers.getIterator(iterator.member.getLoopVariableCount());
|
|
475
|
+ if (implementation != null)
|
|
476
|
+ result.put(iterator.member, implementation.getTarget());
|
|
477
|
+ }
|
|
478
|
+ for (Map.Entry<String, TypeMemberGroup> entry : members.entrySet()) {
|
|
479
|
+ TypeMemberGroup group = entry.getValue();
|
|
480
|
+ TypeMemberGroup definitionGroup = definitionMembers.getGroup(entry.getKey());
|
|
481
|
+ if (definitionGroup == null)
|
|
482
|
+ continue;
|
|
483
|
+
|
|
484
|
+ if (group.getGetter() != null) {
|
|
485
|
+ if (!implemented.contains(group.getGetter().member)) {
|
|
486
|
+ GetterMemberRef implementation = definitionGroup.getGetter();
|
|
487
|
+ if (implementation != null)
|
|
488
|
+ result.put(group.getGetter(), implementation.getTarget());
|
|
489
|
+ }
|
|
490
|
+ }
|
|
491
|
+ if (group.getSetter() != null) {
|
|
492
|
+ if (!implemented.contains(group.getSetter().member)) {
|
|
493
|
+ SetterMemberRef implementation = definitionGroup.getSetter();
|
|
494
|
+ if (implementation != null)
|
|
495
|
+ result.put(group.getSetter(), implementation.getTarget());
|
|
496
|
+ }
|
|
497
|
+ }
|
|
498
|
+ for (TypeMember<FunctionalMemberRef> member : group.getMethodMembers()) {
|
|
499
|
+ if (!implemented.contains(member.member.getTarget())) {
|
|
500
|
+ FunctionalMemberRef functional = definitionGroup.getMethod(member.member.getHeader());
|
|
501
|
+ if (functional != null)
|
|
502
|
+ result.put(member.member, functional.getTarget());
|
|
503
|
+ }
|
|
504
|
+ }
|
|
505
|
+ }
|
|
506
|
+ for (Map.Entry<OperatorType, TypeMemberGroup> entry : operators.entrySet()) {
|
|
507
|
+ if (entry.getKey() == OperatorType.DESTRUCTOR)
|
|
508
|
+ continue; // destructor doesn't have to be implemented; the compiler can do so automatically
|
|
509
|
+
|
|
510
|
+ TypeMemberGroup group = entry.getValue();
|
|
511
|
+ TypeMemberGroup definitionGroup = definitionMembers.getGroup(entry.getKey());
|
|
512
|
+ if (definitionGroup == null)
|
|
513
|
+ continue;
|
|
514
|
+
|
|
515
|
+ for (TypeMember<FunctionalMemberRef> member : group.getMethodMembers()) {
|
|
516
|
+ if (!implemented.contains(member.member.getTarget())) {
|
|
517
|
+ FunctionalMemberRef functional = definitionGroup.getMethod(member.member.getHeader());
|
|
518
|
+ if (functional != null)
|
|
519
|
+ result.put(member.member, functional.getTarget());
|
|
520
|
+ }
|
|
521
|
+ }
|
|
522
|
+ }
|
|
523
|
+
|
|
524
|
+ return result;
|
|
525
|
+ }
|
|
526
|
+
|
459
|
527
|
private Expression castEquivalent(CodePosition position, Expression value, StoredType toType) {
|
460
|
528
|
if (toType.equals(value.type))
|
461
|
529
|
return value;
|