Skip to content

Commit

Permalink
Update heterogeneous_pointer to be a base class of gc_pointer
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Nov 4, 2023
1 parent 76fe894 commit 34af76c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.72_amd64.deb
sudo apt install build/meevax_0.5.73_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.72.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.73.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.72_amd64.deb`
| `package` | Generate debian package `meevax_0.5.73_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.72
0.5.73
8 changes: 4 additions & 4 deletions include/meevax/kernel/pair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
#define INCLUDED_MEEVAX_KERNEL_PAIR_HPP

#include <meevax/kernel/instruction.hpp>
#include <meevax/memory/heterogeneous_pointer.hpp>
#include <meevax/memory/gc_pointer.hpp>

namespace meevax
{
inline namespace kernel
{
struct pair;

using object = heterogeneous_pointer<gc_pointer, pair, bool, std::int32_t, std::uint32_t, float, instruction>;
using object = gc_pointer<pair, bool, std::int32_t, std::uint32_t, float, instruction>;

using let = object;

let extern unit;

template <typename T, typename... Ts>
auto make(Ts&&... xs)
auto make(Ts&&... xs) -> object
{
return object::allocate<T>(std::forward<decltype(xs)>(xs)...);
}

template <typename T>
auto make(T&& x)
auto make(T&& x) -> object
{
return object::allocate<std::decay_t<T>>(std::forward<decltype(x)>(x));
}
Expand Down
26 changes: 17 additions & 9 deletions include/meevax/memory/gc_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,36 @@
#define INCLUDED_MEEVAX_MEMORY_GC_POINTER_HPP

#include <meevax/memory/collector.hpp>
#include <meevax/memory/heterogeneous_pointer.hpp>
#include <meevax/memory/nan_boxing_pointer.hpp>

namespace meevax
{
inline namespace memory
{
template <typename... Ts>
struct gc_pointer : public nan_boxing_pointer<Ts...>
struct gc_pointer : public heterogeneous_pointer<nan_boxing_pointer, Ts...>
, private collector::registration
{
explicit constexpr gc_pointer(std::nullptr_t = nullptr)
using pointer = heterogeneous_pointer<nan_boxing_pointer, Ts...>;

gc_pointer(gc_pointer const& gcp)
: pointer { gcp }
, collector::registration { gcp.header }
{}

template <typename T, REQUIRES(std::is_scalar<T>)>
explicit gc_pointer(T const& datum)
: nan_boxing_pointer<Ts...> { datum }
, collector::registration { locate(nan_boxing_pointer<Ts...>::get()) }
: pointer { datum }
, collector::registration { locate(pointer::get()) }
{}

explicit gc_pointer(gc_pointer const& gcp)
: nan_boxing_pointer<Ts...> { gcp }
, collector::registration { gcp.header }
gc_pointer(pointer const& p)
: pointer { p }
, collector::registration { locate(pointer::get()) }
{}

gc_pointer(std::nullptr_t = nullptr)
{}

auto operator =(gc_pointer const& gcp) -> auto &
Expand All @@ -50,13 +58,13 @@ inline namespace memory

auto reset(gc_pointer const& gcp) -> void
{
nan_boxing_pointer<Ts...>::reset(gcp);
pointer::reset(gcp);
collector::registration::reset(gcp.header);
}

auto reset(std::nullptr_t = nullptr) -> void
{
nan_boxing_pointer<Ts...>::reset();
pointer::reset();
collector::registration::reset();
}
};
Expand Down
1 change: 1 addition & 0 deletions include/meevax/memory/heterogeneous_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <meevax/memory/gc_pointer.hpp>
#include <meevax/type_traits/is_equality_comparable.hpp>
#include <meevax/type_traits/is_output_streamable.hpp>
#include <meevax/type_traits/requires.hpp>
#include <meevax/utility/combination.hpp>
#include <meevax/utility/debug.hpp>
#include <meevax/utility/demangle.hpp>
Expand Down

0 comments on commit 34af76c

Please sign in to comment.