Skip to content

Commit

Permalink
Cleanup code for 13
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekSelander committed Sep 30, 2019
1 parent 7a5bd73 commit 81b4698
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Compiling this will be a bit of a pain in the butt on your end. You'll need to c

Compiled SHA1
```
SHA1: 3c42fbbd3b7aa0bb6d99c4f6b0796ddb574170c4
SHA1: 79ddc71f544d525d3bf3ebeef333203a93852b74
```

### Credits
Expand Down
Binary file modified compiled/dsdump
Binary file not shown.
76 changes: 39 additions & 37 deletions dsdump/XRMachOLibrary+Swift.mm
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,49 @@ - (void)printParentClassIfApplicable:(swift_class*)cls {
printf(" : %s%s%s", dcolor(color), demangledName, color_end());
}

- (void)dumpDescriptors:(const std::vector<swift::TargetTypeContextDescriptor<swift::InProcess> *, std::allocator<swift::TargetTypeContextDescriptor<swift::InProcess> *> > &)descriptors {
for (auto &descriptor : descriptors) {

ContextDescriptorKind kind = descriptor->Flags.getKind();
const char* name = descriptor->Name.get();
if (!ContainsFilteredWords(name)) {
continue;
}
printf(" %s %s%s%s", getKindString(kind), dcolor(DSCOLOR_CYAN), name, color_end());
switch (kind) {
case ContextDescriptorKind::Struct: {
auto structDescriptor = static_cast<StructDescriptor *>(descriptor);
[self dumpSwiftStructType:structDescriptor];
[self dumpTargetTypeContextDescriptorFields:structDescriptor];
break;
} case ContextDescriptorKind::Class: {
auto classDescriptorDisk = static_cast<ClassDescriptor *>(descriptor);
[self dumpSwiftClass:classDescriptorDisk];
break;
} case ContextDescriptorKind::Protocol:
printf("TODO Protocol\n");
break;
case ContextDescriptorKind::Enum: {
printf(" {");
auto enumDescriptor = static_cast<EnumDescriptor*>(descriptor);
[self dumpTargetTypeContextDescriptorFields:enumDescriptor];
break;
}

default:
break;
}
printf(" }\n\n");
}
}

- (void)dumpSwiftTypes {

// Iterate all Swift descriptors in swift5_types
for (auto ptr = moduleDescriptorDictionary.begin(); ptr != moduleDescriptorDictionary.end(); ++ptr ) {
auto module = ptr->first;
auto descriptors = ptr->second;

// if ((module->Name.isNull() || module->isCImportedContext()) && xref_options.verbose < VERBOSE_4) {
// continue;
// }

if (module->isCImportedContext() && (xref_options.undefined || xref_options.defined) && !xref_options.undefined) {
continue;
}
Expand All @@ -375,42 +408,11 @@ - (void)dumpSwiftTypes {
printf("module %s%s%s {\n", dcolor(DSCOLOR_GREEN), module->Name.get(), color_end());

[self dumpSwiftProtocols];
for (auto &descriptor : descriptors) {

ContextDescriptorKind kind = descriptor->Flags.getKind();
const char* name = descriptor->Name.get();
if (!ContainsFilteredWords(name)) {
continue;
}
printf(" %s %s%s%s", getKindString(kind), dcolor(DSCOLOR_CYAN), name, color_end());
switch (kind) {
case ContextDescriptorKind::Struct: {
auto structDescriptor = static_cast<StructDescriptor *>(descriptor);
[self dumpSwiftStructType:structDescriptor];
[self dumpTargetTypeContextDescriptorFields:structDescriptor];
break;
} case ContextDescriptorKind::Class: {
auto classDescriptorDisk = static_cast<ClassDescriptor *>(descriptor);
[self dumpSwiftClass:classDescriptorDisk];
break;
} case ContextDescriptorKind::Protocol:
printf("TODO Protocol\n");
break;
case ContextDescriptorKind::Enum: {
printf(" {");
auto enumDescriptor = static_cast<EnumDescriptor*>(descriptor);
[self dumpTargetTypeContextDescriptorFields:enumDescriptor];
break;
}

default:
break;
}
printf(" }\n\n");
}
[self dumpDescriptors:descriptors];
printf("}\n");
}

[self dumpDescriptors:descriptorsWithNoModule];
putchar('\n');
}

Expand Down

0 comments on commit 81b4698

Please sign in to comment.