diff --git a/include/xo/alloc/Forwarding1.hpp b/include/xo/alloc/Forwarding1.hpp index 4fb61d08..17a38df2 100644 --- a/include/xo/alloc/Forwarding1.hpp +++ b/include/xo/alloc/Forwarding1.hpp @@ -12,6 +12,7 @@ namespace xo { explicit Forwarding1(gp 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; diff --git a/include/xo/alloc/Object.hpp b/include/xo/alloc/Object.hpp index 347b5018..47b26261 100644 --- a/include/xo/alloc/Object.hpp +++ b/include/xo/alloc/Object.hpp @@ -5,7 +5,7 @@ #pragma once -#include "xo/reflect/SelfTagging.hpp" +#include "xo/reflect/TaggedPtr.hpp" #include "IAlloc.hpp" #include #include @@ -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. diff --git a/src/alloc/Forwarding1.cpp b/src/alloc/Forwarding1.cpp index 32d95b60..2122d248 100644 --- a/src/alloc/Forwarding1.cpp +++ b/src/alloc/Forwarding1.cpp @@ -4,15 +4,25 @@ */ #include "Forwarding1.hpp" +#include "xo/reflect/Reflect.hpp" #include #include namespace xo { + using xo::reflect::Reflect; + using xo::reflect::TaggedPtr; + namespace obj { Forwarding1::Forwarding1(gp dest) : dest_{dest} {} + TaggedPtr + Forwarding1::self_tp() const + { + return Reflect::make_tp(const_cast(this)); + } + Object * Forwarding1::_offset_destination(Object * src) const {