This commit is contained in:
mterwoord_cp 2008-03-27 15:14:06 +00:00
parent 88b6604f0c
commit 7f2a50a1b9
6 changed files with 14 additions and 8 deletions

View file

@ -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();
}

View file

@ -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");

View file

@ -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);
}
}
}

View file

@ -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();

View file

@ -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)

View file

@ -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();
}