xo-alloc xo-object: + Object.self_tp
This commit is contained in:
parent
ea60d107e8
commit
150bfa4aa2
11 changed files with 76 additions and 14 deletions
|
|
@ -21,9 +21,10 @@ namespace xo {
|
|||
|
||||
// inherited from Object..
|
||||
|
||||
virtual std::size_t _shallow_size() const override;
|
||||
virtual Object * _shallow_copy() const override;
|
||||
virtual std::size_t _forward_children() override;
|
||||
virtual TaggedPtr self_tp() const final override;
|
||||
virtual std::size_t _shallow_size() const final override;
|
||||
virtual Object * _shallow_copy() const final override;
|
||||
virtual std::size_t _forward_children() final override;
|
||||
|
||||
private:
|
||||
explicit Boolean(bool x) : value_{x} {}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ namespace xo {
|
|||
int_type value() const { return value_; }
|
||||
|
||||
// inherited from Object..
|
||||
virtual std::size_t _shallow_size() const override;
|
||||
virtual Object * _shallow_copy() const override;
|
||||
virtual std::size_t _forward_children() override;
|
||||
virtual TaggedPtr self_tp() const final override;
|
||||
virtual std::size_t _shallow_size() const final override;
|
||||
virtual Object * _shallow_copy() const final override;
|
||||
virtual std::size_t _forward_children() final override;
|
||||
|
||||
private:
|
||||
int_type value_ = 0;
|
||||
|
|
|
|||
|
|
@ -53,9 +53,10 @@ namespace xo {
|
|||
|
||||
// inherited from Object..
|
||||
|
||||
virtual std::size_t _shallow_size() const override;
|
||||
virtual Object * _shallow_copy() const override;
|
||||
virtual std::size_t _forward_children() override;
|
||||
virtual TaggedPtr self_tp() const final override;
|
||||
virtual std::size_t _shallow_size() const final override;
|
||||
virtual Object * _shallow_copy() const final override;
|
||||
virtual std::size_t _forward_children() final override;
|
||||
|
||||
private:
|
||||
List(gp<Object> head, gp<List> rest);
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ namespace xo {
|
|||
std::size_t length() const;
|
||||
|
||||
// inherited from Object..
|
||||
|
||||
virtual std::size_t _shallow_size() const override;
|
||||
virtual Object * _shallow_copy() const override;
|
||||
virtual std::size_t _forward_children() override;
|
||||
virtual TaggedPtr self_tp() const final override;
|
||||
virtual std::size_t _shallow_size() const final override;
|
||||
virtual Object * _shallow_copy() const final override;
|
||||
virtual std::size_t _forward_children() final override;
|
||||
|
||||
private:
|
||||
String(owner owner, std::size_t z, char * s);
|
||||
|
|
|
|||
|
|
@ -4,11 +4,16 @@
|
|||
*/
|
||||
|
||||
#include "Boolean.hpp"
|
||||
#include "TaggedPtr.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
|
||||
namespace obj {
|
||||
gp<Boolean>
|
||||
Boolean::boolean_obj(bool x)
|
||||
|
|
@ -31,6 +36,12 @@ namespace xo {
|
|||
return boolean_obj(false);
|
||||
}
|
||||
|
||||
TaggedPtr
|
||||
Boolean::self_tp() const
|
||||
{
|
||||
return Reflect::make_tp(const_cast<Boolean*>(this));
|
||||
}
|
||||
|
||||
std::size_t
|
||||
Boolean::_shallow_size() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@
|
|||
*/
|
||||
|
||||
#include "Integer.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
|
||||
namespace obj {
|
||||
Integer::Integer(int_type x) : value_{x} {}
|
||||
|
||||
|
|
@ -20,6 +24,11 @@ namespace xo {
|
|||
return dynamic_cast<Integer*>(x.ptr());
|
||||
}
|
||||
|
||||
TaggedPtr
|
||||
Integer::self_tp() const {
|
||||
return Reflect::make_tp(const_cast<Integer*>(this));
|
||||
}
|
||||
|
||||
std::size_t
|
||||
Integer::_shallow_size() const {
|
||||
return sizeof(Integer);
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@
|
|||
**/
|
||||
|
||||
#include "List.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include "xo/indentlog/scope.hpp"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
|
||||
namespace obj {
|
||||
List::List(gp<Object> head, gp<List> rest)
|
||||
: head_{head}, rest_{rest} {}
|
||||
|
|
@ -66,6 +70,11 @@ namespace xo {
|
|||
Object::assign_member(this, &(this->rest_), tail);
|
||||
}
|
||||
|
||||
TaggedPtr
|
||||
List::self_tp() const {
|
||||
return Reflect::make_tp(const_cast<List*>(this));
|
||||
}
|
||||
|
||||
std::size_t
|
||||
List::_shallow_size() const {
|
||||
return sizeof(List);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@
|
|||
|
||||
#include "String.hpp"
|
||||
#include "GC.hpp"
|
||||
#include "TaggedPtr.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
#include <bsd/string.h>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::Reflect;
|
||||
using xo::reflect::TaggedPtr;
|
||||
|
||||
namespace obj {
|
||||
String::String(owner owner, std::size_t z, char * s)
|
||||
: owner_{owner}, z_chars_{z}, chars_{s}
|
||||
|
|
@ -86,6 +91,11 @@ namespace xo {
|
|||
return ::strlen(chars_);
|
||||
}
|
||||
|
||||
TaggedPtr
|
||||
String::self_tp() const {
|
||||
return Reflect::make_tp(const_cast<String*>(this));
|
||||
}
|
||||
|
||||
// ----- GC support -----
|
||||
|
||||
std::size_t
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue