mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
61 lines
No EOL
1.8 KiB
C#
61 lines
No EOL
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Indy.IL2CPU {
|
|
public static class VTablesImpl {
|
|
private static VTable[] mTypes;
|
|
public static bool IsInstance(int aObjectType, int aDesiredObjectType) {
|
|
int xCurrentType = aObjectType;
|
|
if (aObjectType == 0) {
|
|
return true;
|
|
}
|
|
do {
|
|
if (xCurrentType == aDesiredObjectType) {
|
|
return true;
|
|
}
|
|
xCurrentType = mTypes[xCurrentType].BaseTypeIdentifier;
|
|
} while (xCurrentType != 0);
|
|
return false;
|
|
}
|
|
|
|
public static void LoadTypeTable(int aTypeCount) {
|
|
//mTypes = new VTable[aTypeCount];
|
|
}
|
|
|
|
public static void SetTypeInfo(int aType, int aBaseType, ref int[] aMethodIndexes, ref int[] aMethodAddresses, char[] aName) {
|
|
mTypes[aType] = new VTable();
|
|
mTypes[aType].BaseTypeIdentifier = aBaseType;
|
|
mTypes[aType].MethodIndexes = aMethodIndexes;
|
|
mTypes[aType].MethodAddresses = aMethodAddresses;
|
|
mTypes[aType].Name = aName;
|
|
}
|
|
|
|
public static string GetTypeName(int aType) {
|
|
return new String(mTypes[aType].Name);
|
|
}
|
|
|
|
public static void SetMethodInfo(int aType, int aMethodIndex, int aMethodIdentifier, int aMethodAddress, char[] aName) {
|
|
mTypes[aType].MethodIndexes[aMethodIndex] = aMethodIdentifier;
|
|
mTypes[aType].MethodAddresses[aMethodIndex] = aMethodAddress;
|
|
}
|
|
|
|
public static int GetMethodAddressForType(int aType, int aMethodIndex) {
|
|
VTable xTable = mTypes[aType];
|
|
for (int i = 0; i < xTable.MethodIndexes.Length; i++) {
|
|
if (xTable.MethodIndexes[i] == aMethodIndex) {
|
|
return xTable.MethodAddresses[i];
|
|
}
|
|
}
|
|
return 0x00000000;
|
|
}
|
|
}
|
|
|
|
public struct VTable {
|
|
public int BaseTypeIdentifier;
|
|
public char[] Name;
|
|
public int[] MethodIndexes;
|
|
public int[] MethodAddresses;
|
|
}
|
|
} |