Skip to content

Commit

Permalink
Fix ub
Browse files Browse the repository at this point in the history
  • Loading branch information
hrzlgnm committed Dec 15, 2024
1 parent 4ff6bb5 commit b79e9fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 8 additions & 1 deletion source/eval/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
#include <fmt/ranges.h>
#include <overloaded.hpp>

builtin_object::builtin_object(const builtin_function_expression* bltn)

: function_object {bltn, nullptr}
, builtin {bltn}
{
}

auto operator<<(std::ostream& ostrm, object::object_type type) -> std::ostream&
{
using enum object::object_type;
Expand Down Expand Up @@ -59,7 +66,7 @@ auto integer_object::hash_key() const -> hash_key_type

auto builtin_object::inspect() const -> std::string
{
return fmt::format("builtin {}({}){{...}}", builtin->name, fmt::join(builtin->parameters, ", "));
return fmt::format("fn<builtin>{}({}){{...}}", builtin->name, fmt::join(builtin->parameters, ", "));
}

auto function_object::inspect() const -> std::string
Expand Down
9 changes: 3 additions & 6 deletions source/eval/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,17 @@ struct closure_object : object

[[nodiscard]] auto type() const -> object_type override { return object_type::closure; }

[[nodiscard]] auto inspect() const -> std::string override { return "closure{...}"; }
[[nodiscard]] auto inspect() const -> std::string override { return "fn<closure>{...}"; }

const compiled_function_object* fn {};
std::vector<const object*> free;
};

struct builtin_function_expression;

struct builtin_object : object
struct builtin_object : function_object
{
explicit builtin_object(const builtin_function_expression* bltn)
: builtin {bltn}
{
}
explicit builtin_object(const builtin_function_expression* bltn);

[[nodiscard]] auto type() const -> object_type override { return object_type::builtin; }

Expand Down

0 comments on commit b79e9fb

Please sign in to comment.