mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-21 05:18:38 +00:00
23 lines
No EOL
596 B
C#
23 lines
No EOL
596 B
C#
using System;
|
|
using System.Linq;
|
|
using Mono.Cecil;
|
|
|
|
namespace Indy.IL2CPU {
|
|
public static class ObjectUtilities {
|
|
public static uint GetObjectStorageSize(TypeDefinition aType) {
|
|
uint xResult = ObjectImpl.FieldDataOffset;
|
|
foreach (FieldDefinition xField in aType.Fields) {
|
|
if (xField.IsStatic) {
|
|
continue;
|
|
}
|
|
TypeDefinition xFieldType = Engine.GetDefinitionFromTypeReference(xField.FieldType);
|
|
if (xFieldType.IsClass) {
|
|
xResult += 4;
|
|
} else {
|
|
xResult += Engine.GetFieldStorageSize(xFieldType);
|
|
}
|
|
}
|
|
return xResult;
|
|
}
|
|
}
|
|
} |