Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/wiz/format/debug/mlb_debug_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace wiz {
return ""_sv;
}

void dumpAddress(Writer* writer, const Definition* definition, DebugFormatContext& context) {
void dumpAddress(Writer* writer, const Definition* definition, DebugFormatContext& context, MlbAddressOwnership& addressOwnership) {
const auto outputContext = context.outputContext;
const auto address = definition->getAddress();

Expand Down Expand Up @@ -104,11 +104,11 @@ namespace wiz {
: startValue;

for (std::size_t i = startValue; i <= endValue; i++) {
const auto match = context.addressOwnership.find(i);
if (match != context.addressOwnership.end()) {
const auto match = addressOwnership.find({ i, labelTypes });
if (match != addressOwnership.end()) {
return;
} else {
context.addressOwnership[i] = definition;
addressOwnership[{ i, labelTypes }] = definition;
}
}

Expand Down Expand Up @@ -149,11 +149,12 @@ namespace wiz {
MlbDebugFormat::~MlbDebugFormat() {}

bool MlbDebugFormat::generate(DebugFormatContext& context) {
MlbAddressOwnership addressOwnership;
const auto debugName = path::stripExtension(context.outputName).toString() + ".mlb";

if (auto writer = context.resourceManager->openWriter(StringView(debugName))) {
for (const auto& definition : context.definitions) {
dumpAddress(writer.get(), definition, context);
dumpAddress(writer.get(), definition, context, addressOwnership);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/wiz/format/debug/mlb_debug_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
#include <wiz/format/debug/debug_format.h>

namespace wiz {
typedef std::pair<std::size_t, StringView> OwnershipKey;
struct OwnershipKeyHash {
std::size_t operator() (const OwnershipKey& pair) const {
return std::hash<std::size_t>()(pair.first) ^ std::hash<StringView>()(pair.second);
}
};
typedef std::unordered_map<OwnershipKey, const Definition*, OwnershipKeyHash> MlbAddressOwnership;

class MlbDebugFormat : public DebugFormat {
public:
MlbDebugFormat();
Expand Down