mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 07:14:09 +02:00
Reflection fixes for static values
This commit is contained in:
parent
78dd56d6c5
commit
6cd66a2182
9 changed files with 165 additions and 99 deletions
|
@ -478,7 +478,7 @@ namespace System
|
|||
for (var field in typeInst.GetFields())
|
||||
{
|
||||
if (str == field.[Friend]mFieldData.mName)
|
||||
return .Ok(*((T*)(&field.[Friend]mFieldData.mConstValue)));
|
||||
return .Ok(*((T*)(&field.[Friend]mFieldData.mData)));
|
||||
}
|
||||
|
||||
return .Err;
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace System.Reflection
|
|||
{
|
||||
get
|
||||
{
|
||||
return mFieldData.mDataOffset;
|
||||
return (int32)mFieldData.mData;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace System.Reflection
|
|||
}
|
||||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
void* fieldDataAddr = ((uint8*)(void*)obj) + mFieldData.mDataOffset + dataOffsetAdjust;
|
||||
void* fieldDataAddr = ((uint8*)(void*)obj) + mFieldData.mData + dataOffsetAdjust;
|
||||
|
||||
Type rawValueType = value.[Friend]RawGetType();
|
||||
void* valueDataAddr = ((uint8*)(void*)value) + rawValueType.[Friend]mMemberDataOffset;
|
||||
|
@ -123,7 +123,7 @@ namespace System.Reflection
|
|||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
|
||||
void* dataAddr = ((uint8*)(void*)obj) + mFieldData.mDataOffset + dataOffsetAdjust;
|
||||
void* dataAddr = ((uint8*)(void*)obj) + mFieldData.mData + dataOffsetAdjust;
|
||||
|
||||
if (value.VariantType != fieldType)
|
||||
return .Err;//("Invalid type");
|
||||
|
@ -175,7 +175,7 @@ namespace System.Reflection
|
|||
|
||||
Type tMember = typeof(TMember);
|
||||
|
||||
targetDataAddr = (uint8*)targetDataAddr + mFieldData.mDataOffset;
|
||||
targetDataAddr = (uint8*)targetDataAddr + mFieldData.mData;
|
||||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
|
||||
|
@ -207,7 +207,7 @@ namespace System.Reflection
|
|||
if (!tTarget.IsSubtypeOf(mTypeInstance))
|
||||
Runtime.FatalError("Invalid type");
|
||||
|
||||
targetDataAddr = (uint8*)targetDataAddr + mFieldData.mDataOffset;
|
||||
targetDataAddr = (uint8*)targetDataAddr + mFieldData.mData;
|
||||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
|
||||
|
@ -236,14 +236,14 @@ namespace System.Reflection
|
|||
|
||||
if (mFieldData.mFlags.HasFlag(FieldFlags.Const))
|
||||
{
|
||||
return Variant.Create(FieldType, &mFieldData.mConstValue);
|
||||
return Variant.Create(FieldType, &mFieldData.mData);
|
||||
}
|
||||
|
||||
ThrowUnimplemented();
|
||||
|
||||
//Type tTarget;
|
||||
#unwarn
|
||||
void* targetDataAddr = (void*)(int)mFieldData.mConstValue;
|
||||
void* targetDataAddr = (void*)(int)mFieldData.mData;
|
||||
|
||||
Type fieldType = Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||
value.[Friend]mStructType = (int)Internal.UnsafeCastToPtr(fieldType);
|
||||
|
|
|
@ -246,12 +246,27 @@ namespace System
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsBoxedStructPtr
|
||||
public Type BoxedPtrType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (mTypeFlags & (TypeFlags.Boxed | TypeFlags.Pointer)) == TypeFlags.Boxed | TypeFlags.Pointer;
|
||||
}
|
||||
get
|
||||
{
|
||||
if (!mTypeFlags.HasFlag(.Boxed))
|
||||
return null;
|
||||
|
||||
if (mTypeFlags.HasFlag(.Pointer))
|
||||
{
|
||||
return UnderlyingType;
|
||||
}
|
||||
|
||||
let underyingType = UnderlyingType;
|
||||
if (var genericTypeInstance = underyingType as SpecializedGenericType)
|
||||
{
|
||||
if (genericTypeInstance.UnspecializedType == typeof(Pointer<>))
|
||||
return genericTypeInstance.GetGenericArg(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnum
|
||||
|
@ -469,7 +484,7 @@ namespace System
|
|||
{
|
||||
return FieldInfo.Enumerator(null, bindingFlags);
|
||||
}
|
||||
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
GetFullName(strBuffer);
|
||||
|
@ -531,7 +546,8 @@ namespace System
|
|||
Char16,
|
||||
Char32,
|
||||
Float,
|
||||
Double,
|
||||
Double,
|
||||
Float2,
|
||||
Object,
|
||||
Interface,
|
||||
Struct,
|
||||
|
@ -558,8 +574,7 @@ namespace System.Reflection
|
|||
public struct FieldData
|
||||
{
|
||||
public String mName;
|
||||
public int64 mConstValue;
|
||||
public int32 mDataOffset;
|
||||
public int64 mData;
|
||||
public TypeId mFieldTypeId;
|
||||
public FieldFlags mFlags;
|
||||
public int32 mCustomAttributesIdx;
|
||||
|
@ -708,6 +723,12 @@ namespace System.Reflection
|
|||
}
|
||||
strBuffer.Append(')');
|
||||
}
|
||||
else if (mTypeFlags.HasFlag(.Boxed))
|
||||
{
|
||||
strBuffer.Append("boxed ");
|
||||
let ut = UnderlyingType;
|
||||
ut.GetFullName(strBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mOuterType != 0)
|
||||
|
@ -720,8 +741,9 @@ namespace System.Reflection
|
|||
if (!String.IsNullOrEmpty(mNamespace))
|
||||
strBuffer.Append(mNamespace, ".");
|
||||
}
|
||||
|
||||
strBuffer.Append(mName);
|
||||
|
||||
if (mName != null)
|
||||
strBuffer.Append(mName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -744,7 +766,7 @@ namespace System.Reflection
|
|||
public override FieldInfo.Enumerator GetFields(BindingFlags bindingFlags = cDefaultLookup)
|
||||
{
|
||||
return FieldInfo.Enumerator(this, bindingFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Ordered, AlwaysInclude(AssumeInstantiated=true)]
|
||||
|
@ -853,6 +875,14 @@ namespace System.Reflection
|
|||
TypeId mUnspecializedType;
|
||||
TypeId* mResolvedTypeRefs;
|
||||
|
||||
public Type UnspecializedType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Type.[Friend]GetType(mUnspecializedType);
|
||||
}
|
||||
}
|
||||
|
||||
public override int32 GenericParamCount
|
||||
{
|
||||
get
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue