From 72407b1adb19c902402d9a4b0f8f8e5df5754877 Mon Sep 17 00:00:00 2001 From: Shin-ichi MORITA Date: Wed, 14 Jun 2023 22:04:03 +0900 Subject: [PATCH] Defined the default number of the class fields. --- include/xemmai/global.h | 2 +- include/xemmai/type.h | 1 + src/engine.cc | 6 +++--- src/global.cc | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/xemmai/global.h b/include/xemmai/global.h index eedce3c7..bb8b8b4f 100644 --- a/include/xemmai/global.h +++ b/include/xemmai/global.h @@ -543,7 +543,7 @@ intptr_t t_fiber::f_main(auto a_main) } else { std::fprintf(stderr, "caught: \n"); } - if (f_is(thrown)) thrown->f_invoke_class(/*dump*/26); + if (f_is(thrown)) thrown->f_invoke_class(/*dump*/t_type::V_fields); } } catch (...) { std::fprintf(stderr, "caught: \n"); diff --git a/include/xemmai/type.h b/include/xemmai/type.h index ab68e593..b284c6ee 100644 --- a/include/xemmai/type.h +++ b/include/xemmai/type.h @@ -109,6 +109,7 @@ struct t_type_of static XEMMAI__TYPE__IDS_MODIFIER std::array V_ids{f_type_id()}; 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) { diff --git a/src/engine.cc b/src/engine.cc index 760149bb..6b12a4a7 100644 --- a/src/engine.cc +++ b/src/engine.cc @@ -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(26); + auto type_object = f_allocate_for_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(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(26, type, nullptr); + auto type_module__body = f_new_type_on_boot(t_type::V_fields, type, nullptr); auto global = type_module__body->f_as().f_new(type_object, type_type, type_module__body); v_module_global = t_module::f_new(L"__global"sv, global, global->f_as().f_define()); } diff --git a/src/global.cc b/src/global.cc index 16c8e4a0..7929c307 100644 --- a/src/global.cc +++ b/src/global.cc @@ -70,8 +70,8 @@ std::vector> 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(26, v_type_object, t_object::f_of(this))); - v_type_native.f_construct(f_engine()->f_new_type_on_boot(26, v_type_object, t_object::f_of(this))); + v_type_symbol.f_construct(f_engine()->f_new_type_on_boot(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_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);