Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace jank::runtime

/* Callables need a way to get back to the root object so we can do helpful
* error reporting on failed calls. */
/* TODO: Remove this. */
virtual object_ref this_object_ref() = 0;

/* When dynamically calling a function, we need to know three things:
Expand Down
12 changes: 6 additions & 6 deletions compiler+runtime/include/cpp/jank/runtime/ns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace jank::runtime

using ns_ref = oref<struct ns>;

struct ns : gc
struct ns : object
{
static constexpr object_type obj_type{ object_type::ns };
static constexpr bool pointer_free{ false };
Expand All @@ -38,11 +38,11 @@ namespace jank::runtime
obj::persistent_hash_map_ref get_mappings() const;

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
jtl::immutable_string to_code_string() const;
void to_string(jtl::string_builder &buff) const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
jtl::immutable_string to_code_string() const override;
void to_string(jtl::string_builder &buff) const override;
uhash to_hash() const override;

bool operator==(ns const &rhs) const;

Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/array_chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ namespace jank::runtime::obj
{
using array_chunk_ref = oref<struct array_chunk>;

struct array_chunk : gc
struct array_chunk : object
{
static constexpr object_type obj_type{ object_type::array_chunk };
static constexpr bool pointer_free{ false };

array_chunk() = default;
array_chunk();
array_chunk(native_vector<object_ref> const &buffer);
array_chunk(native_vector<object_ref> const &buffer, usize offset);
array_chunk(native_vector<object_ref> &&buffer, usize offset);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::chunk_like */
array_chunk_ref chunk_next() const;
Expand All @@ -30,7 +30,6 @@ namespace jank::runtime::obj
object_ref nth(object_ref index) const;
object_ref nth(object_ref index, object_ref fallback) const;

object base{ obj_type };
native_vector<object_ref> buffer;
usize offset{};
};
Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/atom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ namespace jank::runtime::obj
using atom_ref = oref<struct atom>;
using persistent_vector_ref = oref<struct persistent_vector>;

struct atom : gc
struct atom : object
{
static constexpr object_type obj_type{ object_type::atom };
static constexpr bool pointer_free{ false };

atom() = default;
atom();
atom(object_ref o);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::derefable */
object_ref deref() const;
Expand All @@ -44,7 +44,6 @@ namespace jank::runtime::obj

object_ref compare_and_set(object_ref old_val, object_ref new_val);

object base{ obj_type };
std::atomic<object *> val{};
};
}
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/big_integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace jank::runtime::obj
{
using big_integer_ref = oref<struct big_integer>;

struct big_integer : gc
struct big_integer : object
{
static constexpr object_type obj_type{ object_type::big_integer };
static constexpr bool pointer_free{ true };

big_integer() = default;
big_integer();
big_integer(big_integer &&) noexcept = default;
big_integer(big_integer const &) = default;

Expand All @@ -46,11 +46,11 @@ namespace jank::runtime::obj
explicit big_integer(jtl::immutable_string const &, i64, bool);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::comparable */
i64 compare(object const &) const;
Expand All @@ -70,7 +70,6 @@ namespace jank::runtime::obj

void init(jtl::immutable_string const &);

object base{ obj_type };
native_big_integer data{};
};

Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ namespace jank::runtime::obj
{
using character_ref = oref<struct character>;

struct character : gc
struct character : object
{
static constexpr object_type obj_type{ object_type::character };
static constexpr bool pointer_free{ false };

character() = default;
character();
character(character &&) noexcept = default;
character(character const &) = default;
character(jtl::immutable_string const &);
character(char);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

object base{ obj_type };
/* Holds the raw form of the character bytes. Supports Unicode. */
jtl::immutable_string data;
};
Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/chunk_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,28 @@ namespace jank::runtime::obj
using array_chunk_ref = oref<struct array_chunk>;
using chunk_buffer_ref = oref<struct chunk_buffer>;

struct chunk_buffer : gc
struct chunk_buffer : object
{
static constexpr object_type obj_type{ object_type::chunk_buffer };
static constexpr bool pointer_free{ false };

chunk_buffer() = default;
chunk_buffer();
chunk_buffer(usize capacity);
chunk_buffer(object_ref capacity);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::countable */
usize count() const;

void append(object_ref o);
obj::array_chunk_ref chunk();

object base{ obj_type };
native_vector<object_ref> buffer;
usize capacity{};
};
Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/chunked_cons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ namespace jank::runtime::obj
using cons_ref = oref<struct cons>;
using chunked_cons_ref = oref<struct chunked_cons>;

struct chunked_cons : gc
struct chunked_cons : object
{
static constexpr object_type obj_type{ object_type::chunked_cons };
static constexpr bool pointer_free{ false };
static constexpr bool is_sequential{ true };

chunked_cons() = default;
chunked_cons();
chunked_cons(chunked_cons &&) noexcept = default;
chunked_cons(chunked_cons const &) = default;
chunked_cons(object_ref head, object_ref tail);
chunked_cons(object_ref meta, object_ref head, object_ref tail);

/* behavior::object_like */
bool equal(object const &) const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_string() const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_string() const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::metadatable */
chunked_cons_ref with_meta(object_ref m) const;
Expand All @@ -47,7 +47,6 @@ namespace jank::runtime::obj
object_ref chunked_first() const;
object_ref chunked_next() const;

object base{ obj_type };
object_ref head{};
object_ref tail{};
jtl::option<object_ref> meta;
Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/cons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ namespace jank::runtime::obj
{
using cons_ref = oref<struct cons>;

struct cons : gc
struct cons : object
{
static constexpr object_type obj_type{ object_type::cons };
static constexpr bool pointer_free{ false };
static constexpr bool is_sequential{ true };

cons() = default;
cons();
cons(cons &&) noexcept = default;
cons(cons const &) = default;
cons(object_ref const head, object_ref const tail);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::metadatable */
cons_ref with_meta(object_ref m) const;
Expand All @@ -40,7 +40,6 @@ namespace jank::runtime::obj
/* behavior::conjable */
cons_ref conj(object_ref head) const;

object base{ obj_type };
object_ref head{};
object_ref tail{};
mutable uhash hash{};
Expand Down
15 changes: 7 additions & 8 deletions compiler+runtime/include/cpp/jank/runtime/obj/delay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ namespace jank::runtime::obj
{
using delay_ref = oref<struct delay>;

struct delay : gc
struct delay : object
{
static constexpr object_type obj_type{ object_type::delay };
static constexpr bool pointer_free{ false };

delay() = default;
delay();
delay(object_ref fn);

/* behavior::object_like */
bool equal(object const &) const;
jtl::immutable_string to_string() const;
void to_string(jtl::string_builder &buff) const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
bool equal(object const &) const override;
jtl::immutable_string to_string() const override;
void to_string(jtl::string_builder &buff) const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::derefable */
object_ref deref();

object base{ obj_type };
object_ref val{};
object_ref fn{};
object_ref error{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ namespace jank::runtime::obj::detail
/* Array maps and hash maps share a lot of common code, so we have a common base.
* No virtual fns are used, so this structure won't survive release optimizations. */
template <typename PT, typename ST, typename V>
struct base_persistent_map : gc
struct base_persistent_map : object
{
static constexpr bool pointer_free{ false };
static constexpr bool is_map_like{ true };

using value_type = V;

base_persistent_map() = default;
base_persistent_map();
base_persistent_map(jtl::option<object_ref> const &meta);

/* behavior::object_like */
bool equal(object const &o) const;
bool equal(object const &o) const override;
static void to_string_impl(typename V::const_iterator const &begin,
typename V::const_iterator const &end,
jtl::string_builder &buff,
bool const to_code);
void to_string(jtl::string_builder &buff) const;
void to_string(jtl::string_builder &buff) const override;

jtl::immutable_string to_string() const;
jtl::immutable_string to_code_string() const;
uhash to_hash() const;
jtl::immutable_string to_string() const override;
jtl::immutable_string to_code_string() const override;
uhash to_hash() const override;

/* behavior::seqable */
oref<ST> seq() const;
Expand All @@ -57,7 +57,6 @@ namespace jank::runtime::obj::detail
/* behavior::conjable */
object_ref conj(object_ref const head) const;

object base{ PT::obj_type };
jtl::option<object_ref> meta;
mutable uhash hash{};
};
Expand Down
Loading
Loading