diff --git a/src/Type.h b/src/Type.h index 91b1c3e801..cbdc4a3602 100644 --- a/src/Type.h +++ b/src/Type.h @@ -398,16 +398,6 @@ class TableType : public IndexType public: TableType(TypeListPtr ind, TypePtr yield); - // Used by script compilation to update a "stub" table type - // (which is specified by using a nil "ind" value in the constructor) - // with its actual index & yield - necessary for dealing with - // recursive types. - void SetIndexAndYield(TypeListPtr ind, TypePtr yield) - { - ind = std::move(indices); - yield_type = std::move(yield); - } - /** * Assesses whether an &expire_func attribute's function type is compatible * with this table type. diff --git a/src/script_opt/CPP/RuntimeInitSupport.h b/src/script_opt/CPP/RuntimeInitSupport.h index 37a8782bf7..7e00f2668c 100644 --- a/src/script_opt/CPP/RuntimeInitSupport.h +++ b/src/script_opt/CPP/RuntimeInitSupport.h @@ -16,6 +16,21 @@ using FuncValPtr = IntrusivePtr; namespace detail { +// A version of TableType that allows us to first build a "stub" and +// then fill in its actual index & yield later - necessary for dealing +// with recursive types. +class CPPTableType : public TableType + { +public: + CPPTableType() : TableType(nullptr, nullptr){}; + + void SetIndexAndYield(TypeListPtr ind, TypePtr yield) + { + ind = std::move(indices); + yield_type = std::move(yield); + } + }; + // An initialization hook for a collection of compiled-to-C++ functions // (the result of a single invocation of the compiler on a set of scripts). using CPP_init_func = void (*)(); diff --git a/src/script_opt/CPP/RuntimeInits.cc b/src/script_opt/CPP/RuntimeInits.cc index a5d9e280ff..ac811a82b8 100644 --- a/src/script_opt/CPP/RuntimeInits.cc +++ b/src/script_opt/CPP/RuntimeInits.cc @@ -272,7 +272,7 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals) } else if ( tag == TYPE_TABLE ) - inits_vec[offset] = make_intrusive(nullptr, nullptr); + inits_vec[offset] = make_intrusive(); // else no pre-initialization needed } @@ -399,7 +399,7 @@ TypePtr CPP_TypeInits::BuildTypeList(InitsManager* im, ValElemVec& init_vals, in TypePtr CPP_TypeInits::BuildTableType(InitsManager* im, ValElemVec& init_vals, int offset) const { - auto t = cast_intrusive(inits_vec[offset]); + auto t = cast_intrusive(inits_vec[offset]); ASSERT(t); auto index = cast_intrusive(im->Types(init_vals[1]));