xo-alloc xo-object: + Object.self_tp
This commit is contained in:
parent
432e0efce2
commit
227b2e5cf7
3 changed files with 21 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ namespace xo {
|
|||
explicit Forwarding1(gp<Object> dest);
|
||||
|
||||
// inherited from Object..
|
||||
virtual TaggedPtr self_tp() const final override;
|
||||
virtual bool _is_forwarded() const final override { return true; }
|
||||
virtual Object * _offset_destination(Object * src) const final override;
|
||||
virtual Object * _destination() final override;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "xo/reflect/SelfTagging.hpp"
|
||||
#include "xo/reflect/TaggedPtr.hpp"
|
||||
#include "IAlloc.hpp"
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
|
|
@ -79,6 +79,9 @@ namespace xo {
|
|||
* but cost would be an extra layer of indirection
|
||||
**/
|
||||
class Object {
|
||||
public:
|
||||
using TaggedPtr = xo::reflect::TaggedPtr;
|
||||
|
||||
public:
|
||||
virtual ~Object() = default;
|
||||
|
||||
|
|
@ -148,6 +151,12 @@ namespace xo {
|
|||
**/
|
||||
static Object * _shallow_move(Object * src, gc::GC * gc);
|
||||
|
||||
// Reflection support
|
||||
|
||||
/** tagged pointer with runtime type information
|
||||
**/
|
||||
virtual TaggedPtr self_tp() const = 0;
|
||||
|
||||
// GC support
|
||||
|
||||
/** true iff this object represents a forwarding pointer.
|
||||
|
|
|
|||
|
|
@ -4,15 +4,25 @@
|
|||
*/
|
||||
|
||||
#include "Forwarding1.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
|
||||
namespace obj {
|
||||
Forwarding1::Forwarding1(gp<Object> dest)
|
||||
: dest_{dest}
|
||||
{}
|
||||
|
||||
TaggedPtr
|
||||
Forwarding1::self_tp() const
|
||||
{
|
||||
return Reflect::make_tp(const_cast<Forwarding1*>(this));
|
||||
}
|
||||
|
||||
Object *
|
||||
Forwarding1::_offset_destination(Object * src) const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue