-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
namespace jank::runtime | ||
{ | ||
template <> | ||
struct static_object<object_type::reduced> : gc | ||
{ | ||
static constexpr native_bool pointer_free{ false }; | ||
|
||
static_object() = default; | ||
static_object(object_ptr o); | ||
|
||
/* behavior::objectable */ | ||
native_bool equal(object const &) const; | ||
native_persistent_string to_string() const; | ||
void to_string(fmt::memory_buffer &buff) const; | ||
native_hash to_hash() const; | ||
|
||
/* behavior::derefable */ | ||
object_ptr deref() const; | ||
|
||
object base{ object_type::reduced }; | ||
object_ptr val{}; | ||
}; | ||
|
||
namespace obj | ||
{ | ||
using reduced = static_object<object_type::reduced>; | ||
using reduced_ptr = native_box<reduced>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <jank/runtime/obj/reduced.hpp> | ||
|
||
namespace jank::runtime | ||
{ | ||
obj::reduced::static_object(object_ptr const o) | ||
: val{ o } | ||
{ | ||
assert(val); | ||
} | ||
|
||
native_bool obj::reduced::equal(object const &o) const | ||
{ | ||
return &o == &base; | ||
} | ||
|
||
native_persistent_string obj::reduced::to_string() const | ||
{ | ||
fmt::memory_buffer buff; | ||
to_string(buff); | ||
return native_persistent_string{ buff.data(), buff.size() }; | ||
} | ||
|
||
void obj::reduced::to_string(fmt::memory_buffer &buff) const | ||
{ | ||
fmt::format_to(std::back_inserter(buff), | ||
"{}@{}", | ||
magic_enum::enum_name(base.type), | ||
fmt::ptr(&base)); | ||
} | ||
|
||
native_hash obj::reduced::to_hash() const | ||
{ | ||
return static_cast<native_hash>(reinterpret_cast<uintptr_t>(this)); | ||
} | ||
|
||
object_ptr obj::reduced::deref() const | ||
{ | ||
return val; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include <jank/runtime/obj/nil.hpp> | ||
#include <jank/runtime/obj/volatile.hpp> | ||
|
||
namespace jank::runtime | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters