From 2c9532ef215bb54b30f2d48e5dff85d1c2bc4092 Mon Sep 17 00:00:00 2001 From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD> Date: Wed, 5 Sep 2007 17:14:17 +0000 Subject: [PATCH] Incredibly easy testing framework done. it has a bunch of .net .exe and .asm files.The .exe files are fed to the IL2CPU console app, and the resulting .asm file is compared to the framework's .asm versions. WATCH OUT: please only change the .asm file if the contents are verified to be correct! --- source/IL2CPU.Tests/IL2CPU.Tests.csproj | 97 ++++++++++++++++++ .../IL2CPU.Tests/IL2CPU.Tests.csproj.vspscc | 10 ++ source/IL2CPU.Tests/Program.cs | 86 ++++++++++++++++ .../IL2CPU.Tests/Properties/AssemblyInfo.cs | 36 +++++++ .../Tests/EmptyMethod/TestEmptyMethodApp.cs | 10 ++ .../Tests/EmptyMethod/TestEmptyMethodApp.exe | Bin 0 -> 3072 bytes .../TestEmptyMethodApp.expected.asm | 16 +++ .../SimpleMethodCall/SimpleMethodCall.cs | 12 +++ .../SimpleMethodCall/SimpleMethodCall.exe | Bin 0 -> 3072 bytes .../SimpleMethodCall.expected.asm | 27 +++++ .../IL2CPU.Tests/Tests/SimpleVar/SimpleVar.cs | 11 ++ .../Tests/SimpleVar/SimpleVar.exe | Bin 0 -> 3072 bytes .../Tests/SimpleVar/SimpleVar.expected.asm | 23 +++++ .../SingleMethodWithParam.cs | 14 +++ .../SingleMethodWithParam.exe | Bin 0 -> 3072 bytes .../SingleMethodWithParam.expected.asm | 29 ++++++ source/IL2CPU.sln | 11 +- source/IL2CPU/Program.cs | 9 +- .../Indy.IL2CPU.IL.X86/X86MethodFooterOp.cs | 2 +- 19 files changed, 388 insertions(+), 5 deletions(-) create mode 100644 source/IL2CPU.Tests/IL2CPU.Tests.csproj create mode 100644 source/IL2CPU.Tests/IL2CPU.Tests.csproj.vspscc create mode 100644 source/IL2CPU.Tests/Program.cs create mode 100644 source/IL2CPU.Tests/Properties/AssemblyInfo.cs create mode 100644 source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.cs create mode 100644 source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.exe create mode 100644 source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.expected.asm create mode 100644 source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.cs create mode 100644 source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.exe create mode 100644 source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.expected.asm create mode 100644 source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.cs create mode 100644 source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.exe create mode 100644 source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.expected.asm create mode 100644 source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.cs create mode 100644 source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.exe create mode 100644 source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.expected.asm diff --git a/source/IL2CPU.Tests/IL2CPU.Tests.csproj b/source/IL2CPU.Tests/IL2CPU.Tests.csproj new file mode 100644 index 000000000..be90bd7fd --- /dev/null +++ b/source/IL2CPU.Tests/IL2CPU.Tests.csproj @@ -0,0 +1,97 @@ + + + + Debug + AnyCPU + 9.0.20706 + 2.0 + {3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1} + Exe + Properties + IL2CPU.Tests + IL2CPU.Tests + v3.5 + 512 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + + + + + + + + + + Always + + + + + {B7E87073-CFFB-4972-BA0B-DCF0C3A0C930} + IL2CPU + + + + + Always + + + Always + + + + + Always + + + Always + + + Always + + + + + Always + + + Always + + + + + \ No newline at end of file diff --git a/source/IL2CPU.Tests/IL2CPU.Tests.csproj.vspscc b/source/IL2CPU.Tests/IL2CPU.Tests.csproj.vspscc new file mode 100644 index 000000000..feffdecaa --- /dev/null +++ b/source/IL2CPU.Tests/IL2CPU.Tests.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/source/IL2CPU.Tests/Program.cs b/source/IL2CPU.Tests/Program.cs new file mode 100644 index 000000000..7181e9d33 --- /dev/null +++ b/source/IL2CPU.Tests/Program.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.IO; +using System.Text; + +namespace IL2CPU.Tests { + class Program { + public const int TestTimeout_Seconds = 10; + public const int TestTimeout_Milliseconds = TestTimeout_Seconds * 1000; + static void Main(string[] args) { + SortedList xTests = new SortedList(); + Console.WriteLine("IL2CPU Tester. Please be patient while all tests are executed"); + Console.WriteLine(); + string xBaseDir = Path.GetDirectoryName(typeof(Program).Assembly.Location); + string xBaseTestsDir = Path.Combine(xBaseDir, "Tests"); + foreach (string s in Directory.GetFiles(xBaseTestsDir, "*.expected.asm", SearchOption.AllDirectories)) { + if (File.Exists(s.Replace(".expected.asm", ".exe"))) { + xTests.Add(s.Replace(".expected.asm", ".exe"), null); + } + } + Console.WriteLine("Found {0} tests. Executing now:", xTests.Count); + for (int i = 0; i < xTests.Count; i++) { + string xTestExe = xTests.Keys[i]; + string xExpectedResultFile = xTestExe.Substring(0, xTestExe.Length - ".exe".Length) + ".expected.asm"; + string xActualOutputFile = Path.GetTempFileName(); + try { + ProcessStartInfo xStartInfo = new ProcessStartInfo(); + xStartInfo.CreateNoWindow = true; + xStartInfo.UseShellExecute = false; + xStartInfo.FileName = Path.Combine(xBaseDir, "IL2CPU.exe"); + xStartInfo.Arguments = "\"" + xTestExe + "\" \"" + xActualOutputFile + "\""; + Process xProc = Process.Start(xStartInfo); + if (!xProc.WaitForExit(TestTimeout_Milliseconds)) { + xTests[xTestExe] = null; + Console.Write("E"); + } + if (String.Equals(File.ReadAllText(xExpectedResultFile), File.ReadAllText(xActualOutputFile))) { + xTests[xTestExe] = true; + Console.Write("."); + } else { + xTests[xTestExe] = false; + Console.Write("F"); + } + } finally { + File.Delete(xActualOutputFile); + } + } + Console.WriteLine(); + Console.WriteLine("Test execution done."); + if ((from item in xTests + where item.Value == false + select item.Key).Count() > 0) { + Console.WriteLine("Tests Failed:"); + foreach (string s in (from item in xTests + where item.Value == false + select item.Key)) { + Console.WriteLine("\t" + s); + } + } + if ((from item in xTests + where item.Value == null + select item.Key).Count() > 0) { + Console.WriteLine("Tests Timed out:"); + foreach (string s in (from item in xTests + where item.Value == null + select item.Key)) { + Console.WriteLine("\t" + s); + } + } + int xPassCount = (from item in xTests + where item.Value == true + select item).Count(); + int xFailCount = (from item in xTests + where item.Value == false + select item).Count(); + int xTimeoutCount = (from item in xTests + where item.Value == null + select item).Count(); + Console.WriteLine("\tTests passed: {0}/{1}", xPassCount, xTests.Count); + Console.WriteLine("\tTests failed: {0}/{1}", xFailCount, xTests.Count); + Console.WriteLine("\tTests timed out: {0}/{1}", xTimeoutCount, xTests.Count); + } + } +} diff --git a/source/IL2CPU.Tests/Properties/AssemblyInfo.cs b/source/IL2CPU.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..e37166f08 --- /dev/null +++ b/source/IL2CPU.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IL2CPU.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IL2CPU.Tests")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7be32638-7ce5-4584-a737-ccf459665a54")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.cs b/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.cs new file mode 100644 index 000000000..e31353398 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IL2CPU.Tests.Tests { + public class TestEmptyMethodApp { + public static void Main() { + } + } +} diff --git a/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.exe b/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.exe new file mode 100644 index 0000000000000000000000000000000000000000..280be06376210044123d09ac2f053c2390b9f1ec GIT binary patch literal 3072 zcmeHI&2Jk;6#uQ0RIb}vp+x<-l+6dCs;ZTh29*PXP2x19#Elg@X;oD;{urEv^{%x$ zDK>{HC#2qbf&YL5w;m8gNJt#HRO+DzPN?F<0SV3=T7GYK9Vby#C`ahC=goU>e)GO| zXSQ_nK864cb3A(n>~I!x4Szn{=5qeE@ACNi=)>_HYx&`Lb<>OOP87DHTH9{af*{m( zUD?rAV0(dGT&dXYu&JCACvsD%>+%AyYz^U!$3I``M|*<2bmi~S3H zVD?vx_Su;R@?3ib4V=VT@;q}9?%)_slfMcZ!`nDOAwBtq?`Cc8BUaVCcEA@|5L!(sl0yqsF zM(KjHx)o@zt(^I=-SK=CRaA7xYp58Bp{BhsSXF+lYovHq^KsR;v_iU3U|gzuzNdSG zRUSs$)b!iM%;#6vcZ%QKzx(l{{4ZZ3`|YQ<*3Zs7xyL7C5o8V9mX*y~>FGHq&8}un zU5{#=Yhkd^ZK#gqP~D8ePhtzdP7GT0ROBSgz?e$?_Z+xAA4UsZWlA?~QOarh@-FfQ zd>yuHr2i+AcN{pA+@gD0AP)g39AX!c+#NSuKxaftNM~j!tfPY4}a3_qq*i#chcJlb1_czR$k1=gMXW>A+N;37|}wTmw@ddyQUemeW&*u)n29uKhV z#70C9aw+gu7!2?RI!(M(qYXA-?mqifLz_BKHPJLX+BVU8DAA&^$?BSzrL9Ac3SEN+ z&YN79skMx!dEz?gnQU9!CEp;)^M;ALlG>#s61U%7(f(ch8B>3mekH#x_DS=}?eD^% se(449mf17QKE*_~*>#^8+kd-{TVK+PcEC=)&7+rIbmL3>f1v|^0bJ+~<^TWy literal 0 HcmV?d00001 diff --git a/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.expected.asm b/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.expected.asm new file mode 100644 index 000000000..e71f2fed4 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/EmptyMethod/TestEmptyMethodApp.expected.asm @@ -0,0 +1,16 @@ +format PE console +entry ___ENTRYPOINT___ + + +section '.code' code readable executable + + ___ENTRYPOINT___: + jmp System_Void___IL2CPU_Tests_Tests_TestEmptyMethodApp_Main____ + + System_Void___IL2CPU_Tests_Tests_TestEmptyMethodApp_Main____: + mov ebp,esp + ; IL: Nop + nop + ; IL: Ret + ret + diff --git a/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.cs b/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.cs new file mode 100644 index 000000000..21dfcb5e4 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.cs @@ -0,0 +1,12 @@ +using System; + +public static class Program +{ + public static void Main() + { + TheMethod(); + } + public static void TheMethod() + { + } +} \ No newline at end of file diff --git a/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.exe b/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.exe new file mode 100644 index 0000000000000000000000000000000000000000..174b24dabe96b659ebbb0a12f4188eebaa883d28 GIT binary patch literal 3072 zcmeHI&u<$=6#gc$BR8d1P)lhqbQ%{?RcK|kLE%t^ZJeZ}#EliZX+f2mwLRF2_J_5* zE=~_995`@5LPCJVAAmT5REeq*Hx3-A#2^gR$sz7guK6~E0_vU+V z-g~<(HU;Q(5TRGO#8l5!}DOGTiL}isGOsq)APs)?$gXr^e#-o^rF7Z?p4(&ihl&JP!7df3 zzqzXcR-y(8^&`6ZTr&mi+n?qwD~h8QmrZVVhRb?F&5+IPtw?zxfhN~2nsuycjxn-< z#WB^0f6S&9o!bQRxGsTf^cB=O_U)8npTuWzn%+}5GmSHg^-GJwL`w6zdDbdhua)P| z&g%$yc;vruls*8?bF&|{Tu&l5=)@FF4Z4S=D|HkYl}{3-i&s{cI3J^KYkkoRo18V# zBrYBS4rt|1aSlh*I&_P*Hckl zMK|4+ijf+e#0`TDMY0-CPpCfg&-{xo$RlhRc4b^goW zZoT!-y&Lxd$Kf$%vd3qCli5i0s6?q}$z?IC?d5dY8jsdC*cl zom-9O>iI@ZBD_0XHgPv^-FzMW%g9S#3|hi@X6}hO~|J|760P zv192iI@W^p6qg@k*C2g&T(bdhLTf2`6LSUwNWuRkI@tc1__)td9G3GnAHlA zJ#3pyJM`1vADv^v?75!VbvN{$!_I2$-|szV>aH=S&aTh?Bz$6fs~^>^djPy{d@is* iF_AvI?J-;Vw|;beMo-%TnSPsR&OL2_XMX?X4*Uh6_zAWE literal 0 HcmV?d00001 diff --git a/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.expected.asm b/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.expected.asm new file mode 100644 index 000000000..eb09caafa --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SimpleMethodCall/SimpleMethodCall.expected.asm @@ -0,0 +1,27 @@ +format PE console +entry ___ENTRYPOINT___ + + +section '.code' code readable executable + + ___ENTRYPOINT___: + jmp System_Void___Program_Main____ + + System_Void___Program_Main____: + mov ebp,esp + ; IL: Nop + nop + ; IL: Call System.Void Program::TheMethod() + call System_Void___Program_TheMethod____ + ; IL: Nop + nop + ; IL: Ret + ret + + System_Void___Program_TheMethod____: + mov ebp,esp + ; IL: Nop + nop + ; IL: Ret + ret + diff --git a/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.cs b/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.cs new file mode 100644 index 000000000..b1b86e1b0 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IL2CPU.Tests.Tests { + public class TestEmptyMethodApp { + public static void Main() { + int TempInt = 5; + } + } +} diff --git a/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.exe b/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.exe new file mode 100644 index 0000000000000000000000000000000000000000..3863a08e48b71a3c46f59c157d48e325399ce102 GIT binary patch literal 3072 zcmeHIOK%%h6#lN`6gQ<&`cO%!6sC2MqJjo14JtxaaUO06%1g16qNq|bwlDFZ@yuvu zTpSjV6@ncr*04i}1q-BBNU&zp9ZOVI`~mg|QND9$94Apl*i=HO$GPWy&;8DsnVY4} z&oKZX&-M5*aGz4BZ1_L3J%)#0`e7K~pL}rnzFK^6xz=)HD~y7j$Z1;*$M=K8s%tCi z_?GKib1PM=9W=Fl`t;CvR(iDpEUE#VfB5iL@3co4R;N@U1$83z+C@r>tIQ?LqR6Ew z)C_)+*yEyKXaMCwV8s0OWoD)+_~i<4Tl6yUb+#`HrD7X+{*dEe8Wz9~_NhSo?R^Wd z6WvW{Ps#8ZGYuR$pYCltilYX@23tAH%Vt8$P?_lMNP7Vj4c2YCrPdJF0V)GC2TY@m z$XrQ+Er&t0EWqPlMVsr$Npv1V=Ss@7!o6p3Y3S-$Zh{>SU7e}EGowt^6yx1VyJWv! zx;}Yb3J$^}|COuw5wURd&!Sh8$n|$(su&?AnP+jmic#u(swmE{FU(O+&=y&o@q#*~ z5M65id=4kY_(NU8g|sJvF{5GJy!RrrUNdw7SfGP;RjT4%6{v$#k;OgzGEoWdpYa~Q`9$nW6@{X|=k^+@4nPrb1e zG&`QYiK^QUJ-y*Xw(e@wbevS$VY0iVlUC524nr&~PR_2b+Y*UWj&|G#BG0X(x*I3D zjg|WQx{+YXaedg0B#5$rz1Hy)x2^5jpdGrNj;cDk>o#7IE^VOTJnU7Jp_u-w5i&Kw2Pmk(5Gp+aT z9}aBI22rJ}%}mU^w6>d`yq~-wUxrmS+W(WuI}N_o<`zBBq6{1;J;5(Ya(BF2<~^Ph zE2YKU6qOBBu|;0N8np$i@SEDAT*fWxLO^8Arz6%4D80{pR{n`PLPyI*3@u z<=vrK)5m)VOwzcyfohC8^u~-kNSGJUO6j}&w=AlNDPfjN|IQOCeQI(_>^uEUp)NDP ztNb?Ae*PR!kI^u7!b9g+%q{Vq?dNVVH)3`lONqBYe*rhljUnA6Cf6r+kMnZSrVS!? zsfDKJbOJX0T@#xyxE87Jm|e5%IK-|&wu2Tc0)lDIoUxMmrF%J}H%YOMKWobLwaOX+ zn&`0qgiqvfcm2MkN8k;!XPW)T%xrU-9?@CH?&H>H^t2{mrT>ph*Phk^&+7h{C-66( Cr32dl literal 0 HcmV?d00001 diff --git a/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.expected.asm b/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.expected.asm new file mode 100644 index 000000000..10fab663d --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SimpleVar/SimpleVar.expected.asm @@ -0,0 +1,23 @@ +format PE console +entry ___ENTRYPOINT___ + + +section '.code' code readable executable + + ___ENTRYPOINT___: + jmp System_Void___IL2CPU_Tests_Tests_TestEmptyMethodApp_Main____ + + System_Void___IL2CPU_Tests_Tests_TestEmptyMethodApp_Main____: + mov ebp,esp + pushd ebp + ; IL: Nop + nop + ; IL: Ldc_I4_5 + pushd 5 + ; IL: Stloc_0 + pop eax + mov [ebp + 12],eax + ; IL: Ret + pop ebp + ret + diff --git a/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.cs b/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.cs new file mode 100644 index 000000000..b300c4b16 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.cs @@ -0,0 +1,14 @@ +using System; + +public static class Program +{ + public static void Main() + { + TheMethod(2); + } + + public static void TheMethod(int aParam) + { + + } +} \ No newline at end of file diff --git a/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.exe b/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.exe new file mode 100644 index 0000000000000000000000000000000000000000..a873d558fc11ff38aa022a3363629ce6f9c82dee GIT binary patch literal 3072 zcmeHI&2Jk;6#tFmL}^N+po%I*RoUXCsw%XyT36vvft#;3C~2(NO;A*+S=)oXXuWIg zu8V^z6poyrNFYu~{0AHmL`WRDH8&1DR8{XBxFQae-vx(8o1$a!k6RF^&1gcoMAGVWA0WNQ{?$Ik-L6tX`Zw|S!iz73#z07RH^H) z0mnr6OI^mPq!$@8ZDvVtgS^Nxtb~r>Dz31B5NpKW5DO$W>Eu&20XerqzQjqKCZ2?i<2XZn64S`;-~jwcS?cP6!dpESxVjS5JDz?AWsb(v zD>`ll^$j;}mK9sm5 z)30PsZG=wyX5cS$Yq~A9R+?e(QKXQbYuVte@Ro4@hTi$_TkgyS;X+rNX_-lCZPz_H zr+gu&VHFMcVj^Yk*JSdF4z!ru;QS$aagw*={UUI0;PBqd6sTS2+j@t1fw!oPC9L8m zJDudf`j-l)hWc ztI;(v7fij&ut05YO0rgWba;|BK`jw3T6%^=9X$ZoL9^* vxPKb`Imk?aw@u77&MTs4i_`a5we{RMhQ5TOPQXfjm-Cm88t~HZMVi1rv!oSP literal 0 HcmV?d00001 diff --git a/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.expected.asm b/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.expected.asm new file mode 100644 index 000000000..156b88348 --- /dev/null +++ b/source/IL2CPU.Tests/Tests/SingleMethodWithParam/SingleMethodWithParam.expected.asm @@ -0,0 +1,29 @@ +format PE console +entry ___ENTRYPOINT___ + + +section '.code' code readable executable + + ___ENTRYPOINT___: + jmp System_Void___Program_Main____ + + System_Void___Program_Main____: + mov ebp,esp + ; IL: Nop + nop + ; IL: Ldc_I4_2 + pushd 2 + ; IL: Call System.Void Program::TheMethod(System.Int32) + call System_Void___Program_TheMethod___System_Int32___ + ; IL: Nop + nop + ; IL: Ret + ret + + System_Void___Program_TheMethod___System_Int32___: + mov ebp,esp + ; IL: Nop + nop + ; IL: Ret + ret 4 + diff --git a/source/IL2CPU.sln b/source/IL2CPU.sln index 164077e57..ddedc0e41 100644 --- a/source/IL2CPU.sln +++ b/source/IL2CPU.sln @@ -21,9 +21,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldAssembler", "Hell EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldMetal", "HelloWorldMetal\HelloWorldMetal.csproj", "{B57BEF6D-48D6-49DD-B4C5-893537E0EBB8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IL2CPU.Tests", "IL2CPU.Tests\IL2CPU.Tests.csproj", "{3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1}" +EndProject Global GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 11 + SccNumberOfProjects = 12 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs04.codeplex.com/ SccLocalPath0 = . @@ -57,6 +59,9 @@ Global SccProjectUniqueName10 = HelloWorldMetal\\HelloWorldMetal.csproj SccProjectName10 = HelloWorldMetal SccLocalPath10 = HelloWorldMetal + SccProjectUniqueName11 = IL2CPU.Tests\\IL2CPU.Tests.csproj + SccProjectName11 = IL2CPU.Tests + SccLocalPath11 = IL2CPU.Tests EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -103,6 +108,10 @@ Global {B57BEF6D-48D6-49DD-B4C5-893537E0EBB8}.Debug|Any CPU.Build.0 = Debug|Any CPU {B57BEF6D-48D6-49DD-B4C5-893537E0EBB8}.Release|Any CPU.ActiveCfg = Release|Any CPU {B57BEF6D-48D6-49DD-B4C5-893537E0EBB8}.Release|Any CPU.Build.0 = Release|Any CPU + {3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A0BAC46-1D4E-4E21-89CA-72903B9FCEB1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/source/IL2CPU/Program.cs b/source/IL2CPU/Program.cs index aa9352739..839d79459 100644 --- a/source/IL2CPU/Program.cs +++ b/source/IL2CPU/Program.cs @@ -9,14 +9,18 @@ namespace IL2CPU { public static void Main(string[] args) { try { string exeName = "HelloWorldMetal.exe"; - if(args.Length ==1 ) { + if (args.Length > 0) { exeName = args[0]; } + string outputFileName = @"output.asm"; + if(args.Length > 1) { + outputFileName = args[1]; + } Engine e = new Engine(); e.DebugLog += delegate(string aMessage) { Console.WriteLine(aMessage); }; - using (FileStream fs = new FileStream(@"output.asm", FileMode.Create)) { + using (FileStream fs = new FileStream(outputFileName, FileMode.Create)) { using (StreamWriter br = new StreamWriter(fs)) { e.Execute(exeName, TargetPlatformEnum.x86, br); } @@ -26,7 +30,6 @@ namespace IL2CPU { } Console.WriteLine(""); Console.WriteLine("Completed"); - Console.ReadLine(); } } } \ No newline at end of file diff --git a/source/Indy.IL2CPU.IL.X86/X86MethodFooterOp.cs b/source/Indy.IL2CPU.IL.X86/X86MethodFooterOp.cs index 5d9bfeec4..590778cb2 100644 --- a/source/Indy.IL2CPU.IL.X86/X86MethodFooterOp.cs +++ b/source/Indy.IL2CPU.IL.X86/X86MethodFooterOp.cs @@ -31,7 +31,7 @@ namespace Indy.IL2CPU.IL.X86 { for (int i = 0; i < LocalsCount; i++) { Assembler.Add(new CPU.Pop("ebp")); } - Assembler.Add(new CPU.Ret("")); + Assembler.Add(new CPU.Ret(TotalArgsSize == 0 ? "" : TotalArgsSize.ToString())); } } } \ No newline at end of file