|
@@ -32,6 +32,7 @@ namespace System
|
|
|
struct Exception;
|
|
struct Exception;
|
|
|
struct String;
|
|
struct String;
|
|
|
struct Object;
|
|
struct Object;
|
|
|
|
|
+ struct RuntimeType;
|
|
|
|
|
|
|
|
template <class T>
|
|
template <class T>
|
|
|
struct SZArray_1;
|
|
struct SZArray_1;
|
|
@@ -52,6 +53,7 @@ struct gc_ref;
|
|
|
template <class T>
|
|
template <class T>
|
|
|
struct gc_ptr;
|
|
struct gc_ptr;
|
|
|
|
|
|
|
|
|
|
+struct clr_vtable;
|
|
|
struct clr_exception;
|
|
struct clr_exception;
|
|
|
|
|
|
|
|
[[noreturn]] void throw_null_ref_exception();
|
|
[[noreturn]] void throw_null_ref_exception();
|
|
@@ -117,23 +119,6 @@ struct vtable_holder
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-typedef struct _vtable
|
|
|
|
|
-{
|
|
|
|
|
- uint32_t ElementSize;
|
|
|
|
|
-
|
|
|
|
|
- constexpr _vtable()
|
|
|
|
|
- : ElementSize(0)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- virtual void dummy() const noexcept {}
|
|
|
|
|
-
|
|
|
|
|
- template <class TFunc>
|
|
|
|
|
- constexpr void override_vfunc_impl(std::string_view name, TFunc func)
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-} vtable_t;
|
|
|
|
|
-
|
|
|
|
|
enum object_attributes
|
|
enum object_attributes
|
|
|
{
|
|
{
|
|
|
OBJ_ATTR_NONE
|
|
OBJ_ATTR_NONE
|
|
@@ -148,9 +133,9 @@ struct object_header
|
|
|
{
|
|
{
|
|
|
object_attributes attributes_;
|
|
object_attributes attributes_;
|
|
|
object_sync_header sync_header_;
|
|
object_sync_header sync_header_;
|
|
|
- const vtable_t *vtable_;
|
|
|
|
|
|
|
+ const clr_vtable *vtable_;
|
|
|
|
|
|
|
|
- constexpr object_header(object_attributes attributes, const vtable_t *vtable)
|
|
|
|
|
|
|
+ constexpr object_header(object_attributes attributes, const clr_vtable *vtable)
|
|
|
: attributes_(attributes), vtable_(vtable)
|
|
: attributes_(attributes), vtable_(vtable)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
@@ -608,6 +593,26 @@ struct gc_obj_ref
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+struct clr_vtable
|
|
|
|
|
+{
|
|
|
|
|
+ uint32_t ElementSize;
|
|
|
|
|
+
|
|
|
|
|
+ constexpr clr_vtable()
|
|
|
|
|
+ : ElementSize(0)
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ virtual gc_obj_ref<::System_Private_CoreLib::System::RuntimeType> runtime_type() const noexcept
|
|
|
|
|
+ {
|
|
|
|
|
+ pure_call();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ template <class TFunc>
|
|
|
|
|
+ constexpr void override_vfunc_impl(std::string_view name, TFunc func)
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
struct clr_exception
|
|
struct clr_exception
|
|
|
{
|
|
{
|
|
|
template <class T>
|
|
template <class T>
|
|
@@ -753,7 +758,7 @@ struct vtable_class : public TBase, public vtable_impl_t<TBase, TIFaces>...
|
|
|
constexpr void override_vfunc(std::string_view name, TFunc func)
|
|
constexpr void override_vfunc(std::string_view name, TFunc func)
|
|
|
{
|
|
{
|
|
|
TBase::override_vfunc_impl(name, func);
|
|
TBase::override_vfunc_impl(name, func);
|
|
|
- if constexpr (!std::is_same_v<TBase, vtable_t>)
|
|
|
|
|
|
|
+ if constexpr (!std::is_same_v<TBase, clr_vtable>)
|
|
|
TBase::override_vfunc(name, func);
|
|
TBase::override_vfunc(name, func);
|
|
|
int ignore[] = { 0, (vtable_impl_t<TBase, TIFaces>::override_vfunc_impl(name, func), 0)... };
|
|
int ignore[] = { 0, (vtable_impl_t<TBase, TIFaces>::override_vfunc_impl(name, func), 0)... };
|
|
|
}
|
|
}
|
|
@@ -789,6 +794,17 @@ struct szarray_literal
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+template <class T>
|
|
|
|
|
+struct runtime_type_literal
|
|
|
|
|
+{
|
|
|
|
|
+ const void *vtable_;
|
|
|
|
|
+
|
|
|
|
|
+ constexpr runtime_type_literal()
|
|
|
|
|
+ : vtable_(&vtable_holder<typename T::VTable>::get())
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
template <class TObject, class TValue>
|
|
template <class TObject, class TValue>
|
|
|
struct static_object
|
|
struct static_object
|
|
|
{
|
|
{
|
|
@@ -824,6 +840,17 @@ constexpr auto make_szarray_literal(const std::array<T, N> &values)
|
|
|
return static_object<::System_Private_CoreLib::System::SZArray_1<T>,
|
|
return static_object<::System_Private_CoreLib::System::SZArray_1<T>,
|
|
|
szarray_literal<T, N>>(values);
|
|
szarray_literal<T, N>>(values);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+template <class T>
|
|
|
|
|
+struct runtime_type_holder
|
|
|
|
|
+{
|
|
|
|
|
+ static const constexpr static_object<::System_Private_CoreLib::System::RuntimeType, runtime_type_literal<T>> value = { runtime_type_literal<T>() };
|
|
|
|
|
+
|
|
|
|
|
+ static constexpr gc_obj_ref<::System_Private_CoreLib::System::RuntimeType> get() noexcept
|
|
|
|
|
+ {
|
|
|
|
|
+ return value.get();
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#define NATSU_PRIMITIVE_IMPL_BYTE \
|
|
#define NATSU_PRIMITIVE_IMPL_BYTE \
|