mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-11 02:31:22 +00:00
Fixes.
This commit is contained in:
parent
88b6604f0c
commit
7f2a50a1b9
6 changed files with 14 additions and 8 deletions
|
|
@ -28,7 +28,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
Initialize(aMethod, aCurrentILOffset);
|
||||
}
|
||||
|
||||
public static void EmitExceptionLogic(Assembler.Assembler aAssembler, int aCurrentOpOffset, MethodInformation aMethodInfo, string aNextLabel, bool aDoTest) {
|
||||
public static void EmitExceptionLogic(Assembler.Assembler aAssembler, int aCurrentOpOffset, MethodInformation aMethodInfo, string aNextLabel, bool aDoTest, Action aCleanup) {
|
||||
string xJumpTo = MethodFooterOp.EndOfMethodLabelNameException;
|
||||
if (aMethodInfo != null && aMethodInfo.CurrentHandler != null) {
|
||||
if (aMethodInfo.CurrentHandler.HandlerOffset >= aCurrentOpOffset && (aMethodInfo.CurrentHandler.HandlerLength + aMethodInfo.CurrentHandler.HandlerOffset) <= aCurrentOpOffset) {
|
||||
|
|
@ -53,7 +53,13 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPUx86.JumpAlways(xJumpTo);
|
||||
} else {
|
||||
new CPUx86.Test("ecx", "2");
|
||||
new CPUx86.JumpIfNotEquals(xJumpTo);
|
||||
if (aCleanup != null) {
|
||||
new CPUx86.JumpIfEquals(aNextLabel);
|
||||
aCleanup();
|
||||
new CPUx86.JumpAlways(xJumpTo);
|
||||
} else {
|
||||
new CPUx86.JumpIfNotEquals(xJumpTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +112,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
}
|
||||
public void Assemble(string aMethod, int aArgumentCount) {
|
||||
new CPUx86.Call(aMethod);
|
||||
EmitExceptionLogic(Assembler, mCurrentILOffset, mMethodInfo, mNextLabelName, true);
|
||||
EmitExceptionLogic(Assembler, mCurrentILOffset, mMethodInfo, mNextLabelName, true, null);
|
||||
for (int i = 0; i < aArgumentCount; i++) {
|
||||
Assembler.StackContents.Pop();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPUx86.Pushd(CPUx86.Registers.AtEAX);
|
||||
new CPUx86.Pushd("0" + mMethodIdentifier.ToString("X") + "h");
|
||||
new CPUx86.Call(CPU.Label.GenerateLabelName(VTablesImplRefs.GetMethodAddressForTypeRef));
|
||||
Call.EmitExceptionLogic(Assembler, mCurrentILOffset, mCurrentMethodInfo, mLabelName + "_AfterAddressCheck", true);
|
||||
Call.EmitExceptionLogic(Assembler, mCurrentILOffset, mCurrentMethodInfo, mLabelName + "_AfterAddressCheck", true, xEmitCleanup);
|
||||
new CPU.Label(mLabelName + "_AfterAddressCheck");
|
||||
if (mTargetMethodInfo.Arguments[0].ArgumentType == typeof(object)) {
|
||||
new CPUx86.Push("eax");
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPU.Label(mReturnNullLabel);
|
||||
new CPUx86.Add("esp", "4");
|
||||
Newobj.Assemble(Assembler, typeof(InvalidCastException).GetConstructor(new Type[0]), Engine.RegisterType(typeof(InvalidCastException)), mThisLabel, mMethodInfo, mCurrentILOffset);
|
||||
Call.EmitExceptionLogic(Assembler, mCurrentILOffset, mMethodInfo, mNextOpLabel, false);
|
||||
Call.EmitExceptionLogic(Assembler, mCurrentILOffset, mMethodInfo, mNextOpLabel, false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
foreach (var xStackInt in aAssembler.StackContents) {
|
||||
new CPUx86.Add("esp", xStackInt.Size.ToString());
|
||||
}
|
||||
Call.EmitExceptionLogic(aAssembler, aCurrentILOffset, aCurrentMethodInformation, aCurrentLabel + "_NO_ERROR_4", false);
|
||||
Call.EmitExceptionLogic(aAssembler, aCurrentILOffset, aCurrentMethodInformation, aCurrentLabel + "_NO_ERROR_4", false, null);
|
||||
new CPU.Label(aCurrentLabel + "_NO_ERROR_4");
|
||||
new CPUx86.Pop(CPUx86.Registers.EAX);
|
||||
// aAssembler.StackSizes.Pop();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
new CPUx86.Call(Label.GenerateLabelName(CPU.Assembler.CurrentExceptionOccurredRef));
|
||||
new CPUx86.Move("ecx", "3");
|
||||
aEmitCleanupMethod();
|
||||
Call.EmitExceptionLogic(aAssembler, aCurrentILOffset, aMethodInfo, aNextLabel, false);
|
||||
Call.EmitExceptionLogic(aAssembler, aCurrentILOffset, aMethodInfo, aNextLabel, false, null);
|
||||
}
|
||||
|
||||
public Op(ILReader aReader, MethodInformation aMethodInfo)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Indy.IL2CPU.IL.X86 {
|
|||
Engine.QueueMethod(CPU.Assembler.CurrentExceptionOccurredRef);
|
||||
new CPUx86.Call(CPU.Label.GenerateLabelName(CPU.Assembler.CurrentExceptionOccurredRef));
|
||||
new CPUx86.Move("ecx", "3");
|
||||
Call.EmitExceptionLogic(aAssembler,aCurrentILOffset, aMethodInfo, null, false);
|
||||
Call.EmitExceptionLogic(aAssembler, aCurrentILOffset, aMethodInfo, null, false, null);
|
||||
aAssembler.StackContents.Pop();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue