mirror of
https://github.com/yuzu-mirror/oaknut.git
synced 2026-03-19 00:14:38 +01:00
oaknut: Add ptr accessor to Label
Accesses the underlying `m_addr` for a `Label`. Allows client code to derive the actual memory location of a `Label`. Also adds `is_bound` to ensure the Label has an actual address.
This commit is contained in:
parent
bccb06669f
commit
4af500cb5b
|
|
@ -53,6 +53,18 @@ struct Label {
|
|||
public:
|
||||
Label() = default;
|
||||
|
||||
bool is_bound() const
|
||||
{
|
||||
return m_addr.has_value();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T ptr() const
|
||||
{
|
||||
static_assert(std::is_pointer_v<T> || std::is_same_v<T, std::uintptr_t> || std::is_same_v<T, std::intptr_t>);
|
||||
return reinterpret_cast<T>(m_addr.value());
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename Policy>
|
||||
friend class BasicCodeGenerator;
|
||||
|
|
|
|||
Loading…
Reference in a new issue