Files
revng-revng/include/revng/Support/MetaAddress/KeyTraits.h
Alessandro Di Federico 38031f2f8a Import preliminary model
This commit imports:

* support for (de-)serializing tuple-like objects in YAML
* the Model data structure
* the {Load,Serialize}ModelPass
2021-01-27 19:46:53 +01:00

37 lines
894 B
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <array>
#include <cstdint>
#include <string>
// Local libraries includes
#include "revng/Support/MetaAddress.h"
template<>
struct KeyTraits<MetaAddress> {
static constexpr size_t IntsCount = 4;
using IntsArray = std::array<KeyInt, IntsCount>;
static MetaAddress fromInts(const IntsArray &KeyAsInts) {
return MetaAddress(KeyAsInts[3],
static_cast<MetaAddressType::Values>(KeyAsInts[2]),
KeyAsInts[0],
KeyAsInts[1]);
}
static IntsArray toInts(const MetaAddress &MA) {
return { MA.epoch(),
MA.addressSpace(),
static_cast<uint16_t>(MA.type()),
MA.address() };
}
static std::string toString(const MetaAddress &Value) {
return Value.toString();
}
};