From f364366fac8d7068c5ddbeb3d1858bf9efdfea29 Mon Sep 17 00:00:00 2001 From: gero_cp Date: Sat, 5 Sep 2009 17:53:43 +0000 Subject: [PATCH] Log for assembler Property for stack count Clt fixed Jump_End implemented --- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Clt.cs | 2 +- source2/IL2PCU/Cosmos.IL2CPU.X86/ILOp.cs | 6 ++++-- source2/IL2PCU/Cosmos.IL2CPU/Assembler.cs | 6 +++++- source2/IL2PCU/Cosmos.IL2CPU/StackContents.cs | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Clt.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Clt.cs index c3c69f611..89022de58 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Clt.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Clt.cs @@ -68,7 +68,7 @@ namespace Cosmos.IL2CPU.X86.IL //new CPUx86.Jump { DestinationLabel = NextInstructionLabel }; Jump_End( aMethod ); - + new CPU.Label( LabelFalse ); new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; new CPUx86.Push { DestinationValue = 0 }; diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/ILOp.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/ILOp.cs index 7cfb94250..e686f5011 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/ILOp.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/ILOp.cs @@ -23,8 +23,10 @@ namespace Cosmos.IL2CPU.X86 new CPU.Jump { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(aMethod.MethodBase) + "___EXCEPTION___EXIT" }; } - protected void Jump_End(MethodInfo aMethod) { - throw new NotImplementedException(); + protected void Jump_End(MethodInfo aMethod) + { +#warning todo: Jump_End jumps to ___EXCEPTION___EXIT + new CPU.Jump { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( aMethod.MethodBase ) + "___EXCEPTION___EXIT" }; } protected uint GetStackCountForLocal(MethodInfo aMethod, LocalVariableInfo aField) diff --git a/source2/IL2PCU/Cosmos.IL2CPU/Assembler.cs b/source2/IL2PCU/Cosmos.IL2CPU/Assembler.cs index 9ccdc1e2d..9349d9fc0 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU/Assembler.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU/Assembler.cs @@ -17,7 +17,7 @@ namespace Cosmos.IL2CPU { private static SortedList> mCurrentInstance = new SortedList>(); protected internal List mInstructions = new List(); private List mDataMembers = new List(); - + private System.IO.TextWriter mLog; #region Properties public static Stack CurrentInstance @@ -56,6 +56,7 @@ namespace Cosmos.IL2CPU { public Assembler() { + mLog = new System.IO.StreamWriter( "Cosmos.Assembler.Log" ); InitILOps(); CurrentInstance.Push( this ); } @@ -149,7 +150,10 @@ namespace Cosmos.IL2CPU { } else { xILOp = mILOpsHi[xOpCodeVal & 0xFF]; } + mLog.Write ( "[" + xOpCode.ToString() + "] \t Stack start: " + Stack.Count.ToString() ); xILOp.Execute(aMethod, xOpCode); + mLog.WriteLine( " end: " + Stack.Count.ToString() ); + mLog.Flush(); } } diff --git a/source2/IL2PCU/Cosmos.IL2CPU/StackContents.cs b/source2/IL2PCU/Cosmos.IL2CPU/StackContents.cs index 2d5863a7c..31b886794 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU/StackContents.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU/StackContents.cs @@ -56,6 +56,8 @@ namespace Cosmos.IL2CPU { private Stack mStack = new Stack(); + + public int Count {get { return mStack.Count; } } public Item Peek() { return mStack.Peek(); }