mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 12:58:39 +00:00
40 lines
No EOL
1.3 KiB
C#
40 lines
No EOL
1.3 KiB
C#
using System;
|
|
using System.Reflection;
|
|
|
|
namespace Cosmos.IL2CPU.CustomImplementation.System
|
|
{
|
|
public static class ObjectImplRefs
|
|
{
|
|
public static readonly MethodBase ObjectCtor;
|
|
|
|
public static readonly Assembly RuntimeAssemblyDef;
|
|
|
|
static ObjectImplRefs()
|
|
{
|
|
Type xType = typeof(object);
|
|
ObjectCtor = xType.GetMethod("Ctor", new Type[] { typeof(IntPtr) });
|
|
if (ObjectCtor == null)
|
|
{
|
|
throw new Exception("Implementation of ObjectCtor not found!");
|
|
}
|
|
|
|
|
|
xType = typeof(ObjectImpl);
|
|
foreach (FieldInfo xField in typeof(ObjectImplRefs).GetFields())
|
|
{
|
|
if (xField.Name.EndsWith("Ref"))
|
|
{
|
|
MethodBase xTempMethod = xType.GetMethod(
|
|
xField.Name.Substring(0, xField.Name.Length - "Ref".Length));
|
|
if (xTempMethod == null)
|
|
{
|
|
throw new Exception(
|
|
"Method '" + xField.Name.Substring(0, xField.Name.Length - "Ref".Length)
|
|
+ "' not found on RuntimeEngine!");
|
|
}
|
|
xField.SetValue(null, xTempMethod);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |