fixed string support in metal-mode

This commit is contained in:
mterwoord_cp 2007-11-04 16:48:10 +00:00
parent 5082f79909
commit 36f4dfd119
7 changed files with 38 additions and 21 deletions

View file

@ -79,7 +79,7 @@ namespace Cosmos.Kernel.Boot {
}
public static void Main() {
Console.WriteLine("This is CosmOS Booting...");
Console.WriteLine("This is CosmOS Booting..."); // 25 chars
if (!BootInfoSet) {
Console.WriteLine("No boot info available, terminating!");
return;

View file

@ -840,6 +840,8 @@ namespace Indy.IL2CPU.IL.X86.Native.CustomImplementations.System {
}
private static void OutputString(string aText) {
int theLength = aText.Length;
global::System.Diagnostics.Debugger.Break();
for (int i = 0; i < aText.Length; i++) {
Write_char_(aText[i]);
}

View file

@ -7,7 +7,7 @@ namespace Indy.IL2CPU.IL.X86.CustomImplementations.System {
public static class StringImpl {
public static unsafe int get_Length(int* aThis) {
int* xThis = aThis;
xThis += 3;
xThis += 2;
xThis = (int*)*xThis;
xThis += 2;
return *xThis;
@ -17,11 +17,24 @@ namespace Indy.IL2CPU.IL.X86.CustomImplementations.System {
return 0;
}
public static unsafe byte get_Chars_Metal(byte* aThis, int aIndex) {
byte* xThis = aThis;
xThis += 4;
xThis += aIndex;
return *xThis;
public static unsafe byte get_Chars_Metal(uint* aThis, int aIndex) {
uint* xThis = aThis;
xThis += 3;
xThis = (uint*)*xThis;
xThis += 3;
byte* aBytes = (byte*)xThis;
aBytes += aIndex;
return *aBytes;
}
public static unsafe ushort get_Chars_Normal(uint* aThis, int aIndex) {
uint* xThis = aThis;
xThis += 3;
xThis = (uint*)*xThis;
xThis += 3;
ushort* aBytes = (ushort*)xThis;
aBytes += aIndex;
return *aBytes;
}
}
}

View file

@ -10,6 +10,7 @@ namespace Indy.IL2CPU.IL.X86.CustomImplementations.System {
public static readonly AssemblyDefinition RuntimeAssemblyDef;
public static readonly MethodDefinition get_LengthRef;
public static readonly MethodDefinition get_Chars_MetalRef;
public static readonly MethodDefinition get_Chars_NormalRef;
static StringImplRefs() {
RuntimeAssemblyDef = AssemblyFactory.GetAssembly(typeof(StringImpl).Assembly.Location);

View file

@ -34,8 +34,8 @@ namespace Indy.IL2CPU.IL.X86 {
if (String.IsNullOrEmpty(xDataName)) {
xDataName = Assembler.GetIdentifier("StringLiteral");
StringBuilder xRefByteArray = new StringBuilder();
xRefByteArray.Append(BitConverter.GetBytes(Engine.RegisterType(Engine.GetTypeDefinition("mscorlib", "System.String"))).Aggregate("", (r, b) => r + b + ","));
xRefByteArray.Append(BitConverter.GetBytes((int)InstanceTypeEnum.NormalObject).Aggregate("", (r, b) => r + b + ","));
xRefByteArray.Append("0x" + ((uint)Engine.RegisterType(Engine.GetTypeDefinition("mscorlib", "System.String"))).ToString("X"));
xRefByteArray.Append(",0x" + ((int)InstanceTypeEnum.NormalObject).ToString("X") + ",0,");
xRefByteArray.Append(xDataName + "__Contents,");
xRefByteArray.Append("0,0,0");
Assembler.DataMembers.Add(new DataMember(xDataName, "dd", xRefByteArray.ToString()));
@ -43,7 +43,7 @@ namespace Indy.IL2CPU.IL.X86 {
} else {
xDataName = xDataName.Substring(0, xDataName.Length - "__Contents".Length);
}
Move(Assembler, "eax", "[" + xDataName + "]");
Move(Assembler, "eax", xDataName);
Pushd(4, "eax");
} else {
var xDataByteArray = new StringBuilder();

View file

@ -44,17 +44,18 @@ namespace Indy.IL2CPU.IL.X86 {
}
case "System_UInt32____Indy_IL2CPU_CustomImplementation_System_StringImpl_GetStorage___System_String___": {
//if (aInMetalMode) {
//return CustomImplementation.System.StringImplRefs.GetStorageMetalRef;
//return CustomImplementation.System.StringImplRefs.GetStorageMetalRef;
//} else {
//return CustomImplementation.System.StringImplRefs.GetStorageNormalRef;
//return CustomImplementation.System.StringImplRefs.GetStorageNormalRef;
//}
return CustomImplementation.System.StringImplRefs.GetStorage_ImplRef;
return CustomImplementation.System.StringImplRefs.GetStorage_ImplRef;
}
case "System_Char___System_String_get_Chars___System_Int32___": {
if (aInMetalMode) {
return CustomImplementations.System.StringImplRefs.get_Chars_MetalRef;
} else {
return CustomImplementations.System.StringImplRefs.get_Chars_NormalRef;
}
goto default;
}
case "System_Void___System_EventHandler__ctor___System_Object__System_IntPtr___": {
return CustomImplementations.System.EventHandlerImplRefs.CtorRef;

View file

@ -44,12 +44,12 @@ namespace Indy.IL2CPU.CustomImplementation.System {
return (uint)xThis;
}
public static unsafe uint* GetStorageNormal(uint* aStringPtr) {
uint* xResult = aStringPtr;
xResult = xResult + 3;
xResult = (uint*)(*xResult);
xResult += 3;
return xResult;
}
// public static unsafe uint* GetStorageNormal(uint* aStringPtr) {
// uint* xResult = aStringPtr;
// xResult = xResult + 3;
// xResult = (uint*)(*xResult);
// xResult += 3;
// return xResult;
// }
}
}