Skip to content

Commit

Permalink
Defined the default number of the class fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
shin1m committed Jun 14, 2023
1 parent 1032531 commit 72407b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/xemmai/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ intptr_t t_fiber::f_main(auto a_main)
} else {
std::fprintf(stderr, "caught: <unprintable>\n");
}
if (f_is<t_throwable>(thrown)) thrown->f_invoke_class(/*dump*/26);
if (f_is<t_throwable>(thrown)) thrown->f_invoke_class(/*dump*/t_type::V_fields);
}
} catch (...) {
std::fprintf(stderr, "caught: <unexpected>\n");
Expand Down
1 change: 1 addition & 0 deletions include/xemmai/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct t_type_of<t_object>

static XEMMAI__TYPE__IDS_MODIFIER std::array<t_type_id, 1> V_ids{f_type_id<t_object>()};
static constexpr size_t V_native = 0;
static constexpr size_t V_fields = 26;

static t_pvalue f_transfer(auto* a_library, auto&& a_value)
{
Expand Down
6 changes: 3 additions & 3 deletions src/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,16 @@ t_engine::t_engine(const t_options& a_options, size_t a_count, char** a_argument
#endif
v_thread__internals->f_initialize(v_options.v_stack_size, this);
std::thread(&t_engine::f_collector, this).detach();
auto type_object = f_allocate_for_type<t_type>(26);
auto type_object = f_allocate_for_type<t_type>(t_type::V_fields);
auto type = new(type_object->f_data()) t_type;
type->v_derive = &t_type::f_do_derive;
std::uninitialized_default_construct_n(type->f_fields(), 26);
std::uninitialized_default_construct_n(type->f_fields(), t_type::V_fields);
auto type_type = f_allocate_for_type<t_class>(0);
v_type_type = new(type_type->f_data()) t_class(t_class::V_ids, type);
type_object->f_be(v_type_type);
type_type->f_be(v_type_type);
{
auto type_module__body = f_new_type_on_boot<t_module::t_body>(26, type, nullptr);
auto type_module__body = f_new_type_on_boot<t_module::t_body>(t_type::V_fields, type, nullptr);
auto global = type_module__body->f_as<t_type>().f_new<t_global>(type_object, type_type, type_module__body);
v_module_global = t_module::f_new(L"__global"sv, global, global->f_as<t_global>().f_define());
}
Expand Down
4 changes: 2 additions & 2 deletions src/global.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ std::vector<std::pair<t_root, t_rvalue>> t_global::f_define()
v_type_object->v_module = t_object::f_of(this);
v_type_type->v_module = t_object::f_of(this);
v_type_module__body->v_module = t_object::f_of(this);
v_type_symbol.f_construct(f_engine()->f_new_type_on_boot<t_symbol>(26, v_type_object, t_object::f_of(this)));
v_type_native.f_construct(f_engine()->f_new_type_on_boot<t_native>(26, v_type_object, t_object::f_of(this)));
v_type_symbol.f_construct(f_engine()->f_new_type_on_boot<t_symbol>(t_type::V_fields, v_type_object, t_object::f_of(this)));
v_type_native.f_construct(f_engine()->f_new_type_on_boot<t_native>(t_type::V_fields, v_type_object, t_object::f_of(this)));
v_symbol_initialize = t_symbol::f_instantiate(L"__initialize"sv);
v_symbol_call = t_symbol::f_instantiate(L"__call"sv);
v_symbol_string = t_symbol::f_instantiate(L"__string"sv);
Expand Down

0 comments on commit 72407b1

Please sign in to comment.