cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/0000755000175000017500000000000011620326252017357 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/0000755000175000017500000000000011620326252023010 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/AssemblyInfo.cs0000644000175000017500000000325511620326252025737 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System.Reflection; #if !EMBEDDED [assembly: AssemblyTitle ("Cecil.FlowAnalysis")] [assembly: AssemblyDescription ("A flow analysis framework for Mono.Cecil")] [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("db4objects Inc.")] [assembly: AssemblyProduct ("Cecil.FlowAnalysis")] [assembly: AssemblyCopyright ("(C) db4objects Inc.")] [assembly: AssemblyTrademark ("")] [assembly: AssemblyCulture ("")] [assembly: AssemblyVersion("0.1.0.0")] #if KEYFILE [assembly: AssemblyKeyFile("../../../mcs/class/mono.snk")] #endif #endif cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/0000755000175000017500000000000011620326252024763 5ustar laneylaney././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/AbstractInstructionVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/AbstractInstructionVisito0000644000175000017500000007351111620326252032120 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public class AbstractInstructionVisitor : IInstructionVisitor { public virtual void OnNop (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBreak (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarg_0 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarg_1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarg_2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarg_3 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloc_0 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloc_1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloc_2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloc_3 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStloc_0 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStloc_1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStloc_2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStloc_3 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarg (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdarga (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStarg (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloc (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdloca (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStloc (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdnull (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_M1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_0 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_3 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_5 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_6 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_7 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4_8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdc_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnDup (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnPop (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnJmp (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCall (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCalli (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRet (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBr (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBrfalse (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBrtrue (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBeq (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBge (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBgt (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBle (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBlt (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBne_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBge_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBgt_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBle_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBlt_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnSwitch (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_U1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_U2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_U4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdind_Ref (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_Ref (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnAdd (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnSub (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnMul (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnDiv (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnDiv_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRem (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRem_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnAnd (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnOr (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnXor (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnShl (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnShr (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnShr_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnNeg (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnNot (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_U4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_U8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCallvirt (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCpobj (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdobj (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdstr (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnNewobj (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCastclass (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnIsinst (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_R_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnUnbox (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnThrow (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdfld (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdflda (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStfld (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdsfld (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdsflda (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStsfld (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStobj (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I1_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I2_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I4_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I8_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U1_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U2_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U4_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U8_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnBox (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnNewarr (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdlen (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelema (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_U1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_U2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_U4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_Ref (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_R4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_R8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_Ref (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdelem_Any (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStelem_Any (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnUnbox_Any (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U4 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U8 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRefanyval (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCkfinite (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnMkrefany (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdtoken (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_U2 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_U1 (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_Ovf_U (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnAdd_Ovf (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnAdd_Ovf_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnMul_Ovf (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnMul_Ovf_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnSub_Ovf (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnSub_Ovf_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnEndfinally (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLeave (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnStind_I (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnConv_U (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnArglist (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCeq (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCgt (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCgt_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnClt (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnClt_Un (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdftn (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLdvirtftn (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnLocalloc (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnEndfilter (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnUnaligned (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnVolatile (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnTail (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnInitobj (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnCpblk (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnInitblk (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRethrow (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnSizeof (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public virtual void OnRefanytype (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } public void Visit (Instruction instruction) { InstructionDispatcher.Dispatch (instruction, this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/IInstructionVisitor.cs0000644000175000017500000002327211620326252031332 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public interface IInstructionVisitor { void OnNop (Instruction instruction); void OnBreak (Instruction instruction); void OnLdarg_0 (Instruction instruction); void OnLdarg_1 (Instruction instruction); void OnLdarg_2 (Instruction instruction); void OnLdarg_3 (Instruction instruction); void OnLdloc_0 (Instruction instruction); void OnLdloc_1 (Instruction instruction); void OnLdloc_2 (Instruction instruction); void OnLdloc_3 (Instruction instruction); void OnStloc_0 (Instruction instruction); void OnStloc_1 (Instruction instruction); void OnStloc_2 (Instruction instruction); void OnStloc_3 (Instruction instruction); void OnLdarg (Instruction instruction); void OnLdarga (Instruction instruction); void OnStarg (Instruction instruction); void OnLdloc (Instruction instruction); void OnLdloca (Instruction instruction); void OnStloc (Instruction instruction); void OnLdnull (Instruction instruction); void OnLdc_I4_M1 (Instruction instruction); void OnLdc_I4_0 (Instruction instruction); void OnLdc_I4_1 (Instruction instruction); void OnLdc_I4_2 (Instruction instruction); void OnLdc_I4_3 (Instruction instruction); void OnLdc_I4_4 (Instruction instruction); void OnLdc_I4_5 (Instruction instruction); void OnLdc_I4_6 (Instruction instruction); void OnLdc_I4_7 (Instruction instruction); void OnLdc_I4_8 (Instruction instruction); void OnLdc_I4 (Instruction instruction); void OnLdc_I8 (Instruction instruction); void OnLdc_R4 (Instruction instruction); void OnLdc_R8 (Instruction instruction); void OnDup (Instruction instruction); void OnPop (Instruction instruction); void OnJmp (Instruction instruction); void OnCall (Instruction instruction); void OnCalli (Instruction instruction); void OnRet (Instruction instruction); void OnBr (Instruction instruction); void OnBrfalse (Instruction instruction); void OnBrtrue (Instruction instruction); void OnBeq (Instruction instruction); void OnBge (Instruction instruction); void OnBgt (Instruction instruction); void OnBle (Instruction instruction); void OnBlt (Instruction instruction); void OnBne_Un (Instruction instruction); void OnBge_Un (Instruction instruction); void OnBgt_Un (Instruction instruction); void OnBle_Un (Instruction instruction); void OnBlt_Un (Instruction instruction); void OnSwitch (Instruction instruction); void OnLdind_I1 (Instruction instruction); void OnLdind_U1 (Instruction instruction); void OnLdind_I2 (Instruction instruction); void OnLdind_U2 (Instruction instruction); void OnLdind_I4 (Instruction instruction); void OnLdind_U4 (Instruction instruction); void OnLdind_I8 (Instruction instruction); void OnLdind_I (Instruction instruction); void OnLdind_R4 (Instruction instruction); void OnLdind_R8 (Instruction instruction); void OnLdind_Ref (Instruction instruction); void OnStind_Ref (Instruction instruction); void OnStind_I1 (Instruction instruction); void OnStind_I2 (Instruction instruction); void OnStind_I4 (Instruction instruction); void OnStind_I8 (Instruction instruction); void OnStind_R4 (Instruction instruction); void OnStind_R8 (Instruction instruction); void OnAdd (Instruction instruction); void OnSub (Instruction instruction); void OnMul (Instruction instruction); void OnDiv (Instruction instruction); void OnDiv_Un (Instruction instruction); void OnRem (Instruction instruction); void OnRem_Un (Instruction instruction); void OnAnd (Instruction instruction); void OnOr (Instruction instruction); void OnXor (Instruction instruction); void OnShl (Instruction instruction); void OnShr (Instruction instruction); void OnShr_Un (Instruction instruction); void OnNeg (Instruction instruction); void OnNot (Instruction instruction); void OnConv_I1 (Instruction instruction); void OnConv_I2 (Instruction instruction); void OnConv_I4 (Instruction instruction); void OnConv_I8 (Instruction instruction); void OnConv_R4 (Instruction instruction); void OnConv_R8 (Instruction instruction); void OnConv_U4 (Instruction instruction); void OnConv_U8 (Instruction instruction); void OnCallvirt (Instruction instruction); void OnCpobj (Instruction instruction); void OnLdobj (Instruction instruction); void OnLdstr (Instruction instruction); void OnNewobj (Instruction instruction); void OnCastclass (Instruction instruction); void OnIsinst (Instruction instruction); void OnConv_R_Un (Instruction instruction); void OnUnbox (Instruction instruction); void OnThrow (Instruction instruction); void OnLdfld (Instruction instruction); void OnLdflda (Instruction instruction); void OnStfld (Instruction instruction); void OnLdsfld (Instruction instruction); void OnLdsflda (Instruction instruction); void OnStsfld (Instruction instruction); void OnStobj (Instruction instruction); void OnConv_Ovf_I1_Un (Instruction instruction); void OnConv_Ovf_I2_Un (Instruction instruction); void OnConv_Ovf_I4_Un (Instruction instruction); void OnConv_Ovf_I8_Un (Instruction instruction); void OnConv_Ovf_U1_Un (Instruction instruction); void OnConv_Ovf_U2_Un (Instruction instruction); void OnConv_Ovf_U4_Un (Instruction instruction); void OnConv_Ovf_U8_Un (Instruction instruction); void OnConv_Ovf_I_Un (Instruction instruction); void OnConv_Ovf_U_Un (Instruction instruction); void OnBox (Instruction instruction); void OnNewarr (Instruction instruction); void OnLdlen (Instruction instruction); void OnLdelema (Instruction instruction); void OnLdelem_I1 (Instruction instruction); void OnLdelem_U1 (Instruction instruction); void OnLdelem_I2 (Instruction instruction); void OnLdelem_U2 (Instruction instruction); void OnLdelem_I4 (Instruction instruction); void OnLdelem_U4 (Instruction instruction); void OnLdelem_I8 (Instruction instruction); void OnLdelem_I (Instruction instruction); void OnLdelem_R4 (Instruction instruction); void OnLdelem_R8 (Instruction instruction); void OnLdelem_Ref (Instruction instruction); void OnStelem_I (Instruction instruction); void OnStelem_I1 (Instruction instruction); void OnStelem_I2 (Instruction instruction); void OnStelem_I4 (Instruction instruction); void OnStelem_I8 (Instruction instruction); void OnStelem_R4 (Instruction instruction); void OnStelem_R8 (Instruction instruction); void OnStelem_Ref (Instruction instruction); void OnLdelem_Any (Instruction instruction); void OnStelem_Any (Instruction instruction); void OnUnbox_Any (Instruction instruction); void OnConv_Ovf_I1 (Instruction instruction); void OnConv_Ovf_U1 (Instruction instruction); void OnConv_Ovf_I2 (Instruction instruction); void OnConv_Ovf_U2 (Instruction instruction); void OnConv_Ovf_I4 (Instruction instruction); void OnConv_Ovf_U4 (Instruction instruction); void OnConv_Ovf_I8 (Instruction instruction); void OnConv_Ovf_U8 (Instruction instruction); void OnRefanyval (Instruction instruction); void OnCkfinite (Instruction instruction); void OnMkrefany (Instruction instruction); void OnLdtoken (Instruction instruction); void OnConv_U2 (Instruction instruction); void OnConv_U1 (Instruction instruction); void OnConv_I (Instruction instruction); void OnConv_Ovf_I (Instruction instruction); void OnConv_Ovf_U (Instruction instruction); void OnAdd_Ovf (Instruction instruction); void OnAdd_Ovf_Un (Instruction instruction); void OnMul_Ovf (Instruction instruction); void OnMul_Ovf_Un (Instruction instruction); void OnSub_Ovf (Instruction instruction); void OnSub_Ovf_Un (Instruction instruction); void OnEndfinally (Instruction instruction); void OnLeave (Instruction instruction); void OnStind_I (Instruction instruction); void OnConv_U (Instruction instruction); void OnArglist (Instruction instruction); void OnCeq (Instruction instruction); void OnCgt (Instruction instruction); void OnCgt_Un (Instruction instruction); void OnClt (Instruction instruction); void OnClt_Un (Instruction instruction); void OnLdftn (Instruction instruction); void OnLdvirtftn (Instruction instruction); void OnLocalloc (Instruction instruction); void OnEndfilter (Instruction instruction); void OnUnaligned (Instruction instruction); void OnVolatile (Instruction instruction); void OnTail (Instruction instruction); void OnInitobj (Instruction instruction); void OnCpblk (Instruction instruction); void OnInitblk (Instruction instruction); void OnRethrow (Instruction instruction); void OnSizeof (Instruction instruction); void OnRefanytype (Instruction instruction); } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/Formatter.cs0000644000175000017500000001164111620326252027260 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.IO; using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { /// /// public class Formatter { public static string FormatInstruction (Instruction instruction) { StringWriter writer = new StringWriter (); WriteInstruction (writer, instruction); return writer.ToString (); } public static string FormatMethodBody (MethodDefinition method) { StringWriter writer = new StringWriter (); WriteMethodBody (writer, method); return writer.ToString (); } public static void WriteMethodBody (TextWriter writer, MethodDefinition method) { writer.WriteLine (method); foreach (Instruction instruction in method.Body.Instructions) { writer.Write ('\t'); WriteInstruction (writer, instruction); writer.WriteLine (); } } public static void WriteInstruction (TextWriter writer, Instruction instruction) { writer.Write (FormatLabel (instruction.Offset)); writer.Write (": "); writer.Write (instruction.OpCode.Name); if (null != instruction.Operand) { writer.Write (' '); WriteOperand (writer, instruction.Operand); } } private static string FormatLabel (int offset) { string label = "000" + offset.ToString ("x"); return "IL_" + label.Substring (label.Length - 4); } private static void WriteOperand (TextWriter writer, object operand) { if (null == operand) throw new ArgumentNullException ("operand"); Instruction targetInstruction = operand as Instruction; if (null != targetInstruction) { writer.Write (FormatLabel (targetInstruction.Offset)); return; } Instruction [] targetInstructions = operand as Instruction []; if (null != targetInstructions) { WriteLabelList (writer, targetInstructions); return; } VariableReference variableRef = operand as VariableReference; if (null != variableRef) { writer.Write (variableRef.Index.ToString ()); return; } MethodReference methodRef = operand as MethodReference; if (null != methodRef) { WriteMethodReference (writer, methodRef); return; } string s = operand as string; if (null != s) { writer.Write ("\"" + s + "\""); return; } s = ToInvariantCultureString (operand); writer.Write (s); } static void WriteLabelList (TextWriter writer, Instruction [] instructions) { writer.Write ("("); for (int i = 0; i < instructions.Length; i++) { if (i != 0) writer.Write (", "); writer.Write (FormatLabel (instructions [i].Offset)); } writer.Write (")"); } public static string ToInvariantCultureString (object value) { IConvertible convertible = value as IConvertible; return (null != convertible) ? convertible.ToString (System.Globalization.CultureInfo.InvariantCulture) : value.ToString (); } private static void WriteMethodReference (TextWriter writer, MethodReference method) { writer.Write (FormatTypeReference (method.ReturnType)); writer.Write (' '); writer.Write (FormatTypeReference (method.DeclaringType)); writer.Write ("::"); writer.Write (method.Name); writer.Write ("("); var parameters = method.Parameters; for (int i=0; i < parameters.Count; ++i) { if (i > 0) writer.Write (", "); writer.Write (FormatTypeReference (parameters [i].ParameterType)); } writer.Write (")"); } public static string FormatTypeReference (TypeReference type) { string typeName = type.FullName; switch (typeName) { case "System.Void": return "void"; case "System.String": return "string"; case "System.Int32": return "int32"; case "System.Long": return "int64"; case "System.Boolean": return "bool"; case "System.Single": return "float32"; case "System.Double": return "float64"; } return typeName; } private Formatter () { } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Utilities/InstructionDispatcher.cs0000644000175000017500000012374311620326252031654 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using System.Collections; using System.Collections.Generic; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public class InstructionDispatcher { public static void Dispatch (Instruction instruction, IInstructionVisitor visitor) { InstructionVisitorDelegate handler = (InstructionVisitorDelegate)_handlers[instruction.OpCode.Value]; if (null == handler) throw new ArgumentException (Formatter.FormatInstruction (instruction), "instruction"); handler (visitor, instruction); } delegate void InstructionVisitorDelegate (IInstructionVisitor visitor, Instruction instruction); static IDictionary _handlers = new Dictionary (); static InstructionDispatcher () { Bind (new InstructionVisitorDelegate (DispatchNop), OpCodes.Nop); Bind (new InstructionVisitorDelegate (DispatchBreak), OpCodes.Break); Bind (new InstructionVisitorDelegate (DispatchLdarg_0), OpCodes.Ldarg_0); Bind (new InstructionVisitorDelegate (DispatchLdarg_1), OpCodes.Ldarg_1); Bind (new InstructionVisitorDelegate (DispatchLdarg_2), OpCodes.Ldarg_2); Bind (new InstructionVisitorDelegate (DispatchLdarg_3), OpCodes.Ldarg_3); Bind (new InstructionVisitorDelegate (DispatchLdloc_0), OpCodes.Ldloc_0); Bind (new InstructionVisitorDelegate (DispatchLdloc_1), OpCodes.Ldloc_1); Bind (new InstructionVisitorDelegate (DispatchLdloc_2), OpCodes.Ldloc_2); Bind (new InstructionVisitorDelegate (DispatchLdloc_3), OpCodes.Ldloc_3); Bind (new InstructionVisitorDelegate (DispatchStloc_0), OpCodes.Stloc_0); Bind (new InstructionVisitorDelegate (DispatchStloc_1), OpCodes.Stloc_1); Bind (new InstructionVisitorDelegate (DispatchStloc_2), OpCodes.Stloc_2); Bind (new InstructionVisitorDelegate (DispatchStloc_3), OpCodes.Stloc_3); Bind (new InstructionVisitorDelegate (DispatchLdarg), OpCodes.Ldarg, OpCodes.Ldarg_S); Bind (new InstructionVisitorDelegate (DispatchLdarga), OpCodes.Ldarga, OpCodes.Ldarga_S); Bind (new InstructionVisitorDelegate (DispatchStarg), OpCodes.Starg, OpCodes.Starg_S); Bind (new InstructionVisitorDelegate (DispatchLdloc), OpCodes.Ldloc, OpCodes.Ldloc_S); Bind (new InstructionVisitorDelegate (DispatchLdloca), OpCodes.Ldloca, OpCodes.Ldloca_S); Bind (new InstructionVisitorDelegate (DispatchStloc), OpCodes.Stloc, OpCodes.Stloc_S); Bind (new InstructionVisitorDelegate (DispatchLdnull), OpCodes.Ldnull); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_M1), OpCodes.Ldc_I4_M1); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_0), OpCodes.Ldc_I4_0); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_1), OpCodes.Ldc_I4_1); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_2), OpCodes.Ldc_I4_2); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_3), OpCodes.Ldc_I4_3); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_4), OpCodes.Ldc_I4_4); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_5), OpCodes.Ldc_I4_5); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_6), OpCodes.Ldc_I4_6); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_7), OpCodes.Ldc_I4_7); Bind (new InstructionVisitorDelegate (DispatchLdc_I4_8), OpCodes.Ldc_I4_8); Bind (new InstructionVisitorDelegate (DispatchLdc_I4), OpCodes.Ldc_I4, OpCodes.Ldc_I4_S); Bind (new InstructionVisitorDelegate (DispatchLdc_I8), OpCodes.Ldc_I8); Bind (new InstructionVisitorDelegate (DispatchLdc_R4), OpCodes.Ldc_R4); Bind (new InstructionVisitorDelegate (DispatchLdc_R8), OpCodes.Ldc_R8); Bind (new InstructionVisitorDelegate (DispatchDup), OpCodes.Dup); Bind (new InstructionVisitorDelegate (DispatchPop), OpCodes.Pop); Bind (new InstructionVisitorDelegate (DispatchJmp), OpCodes.Jmp); Bind (new InstructionVisitorDelegate (DispatchCall), OpCodes.Call); Bind (new InstructionVisitorDelegate (DispatchCalli), OpCodes.Calli); Bind (new InstructionVisitorDelegate (DispatchRet), OpCodes.Ret); Bind (new InstructionVisitorDelegate (DispatchBr), OpCodes.Br, OpCodes.Br_S); Bind (new InstructionVisitorDelegate (DispatchBrfalse), OpCodes.Brfalse, OpCodes.Brfalse_S); Bind (new InstructionVisitorDelegate (DispatchBrtrue), OpCodes.Brtrue, OpCodes.Brtrue_S); Bind (new InstructionVisitorDelegate (DispatchBeq), OpCodes.Beq, OpCodes.Beq_S); Bind (new InstructionVisitorDelegate (DispatchBge), OpCodes.Bge, OpCodes.Bge_S); Bind (new InstructionVisitorDelegate (DispatchBgt), OpCodes.Bgt, OpCodes.Bgt_S); Bind (new InstructionVisitorDelegate (DispatchBle), OpCodes.Ble, OpCodes.Ble_S); Bind (new InstructionVisitorDelegate (DispatchBlt), OpCodes.Blt, OpCodes.Blt_S); Bind (new InstructionVisitorDelegate (DispatchBne_Un), OpCodes.Bne_Un, OpCodes.Bne_Un_S); Bind (new InstructionVisitorDelegate (DispatchBge_Un), OpCodes.Bge_Un, OpCodes.Bge_Un_S); Bind (new InstructionVisitorDelegate (DispatchBgt_Un), OpCodes.Bgt_Un, OpCodes.Bgt_Un_S); Bind (new InstructionVisitorDelegate (DispatchBle_Un), OpCodes.Ble_Un, OpCodes.Ble_Un_S); Bind (new InstructionVisitorDelegate (DispatchBlt_Un), OpCodes.Blt_Un, OpCodes.Blt_Un_S); Bind (new InstructionVisitorDelegate (DispatchSwitch), OpCodes.Switch); Bind (new InstructionVisitorDelegate (DispatchLdind_I1), OpCodes.Ldind_I1); Bind (new InstructionVisitorDelegate (DispatchLdind_U1), OpCodes.Ldind_U1); Bind (new InstructionVisitorDelegate (DispatchLdind_I2), OpCodes.Ldind_I2); Bind (new InstructionVisitorDelegate (DispatchLdind_U2), OpCodes.Ldind_U2); Bind (new InstructionVisitorDelegate (DispatchLdind_I4), OpCodes.Ldind_I4); Bind (new InstructionVisitorDelegate (DispatchLdind_U4), OpCodes.Ldind_U4); Bind (new InstructionVisitorDelegate (DispatchLdind_I8), OpCodes.Ldind_I8); Bind (new InstructionVisitorDelegate (DispatchLdind_I), OpCodes.Ldind_I); Bind (new InstructionVisitorDelegate (DispatchLdind_R4), OpCodes.Ldind_R4); Bind (new InstructionVisitorDelegate (DispatchLdind_R8), OpCodes.Ldind_R8); Bind (new InstructionVisitorDelegate (DispatchLdind_Ref), OpCodes.Ldind_Ref); Bind (new InstructionVisitorDelegate (DispatchStind_Ref), OpCodes.Stind_Ref); Bind (new InstructionVisitorDelegate (DispatchStind_I1), OpCodes.Stind_I1); Bind (new InstructionVisitorDelegate (DispatchStind_I2), OpCodes.Stind_I2); Bind (new InstructionVisitorDelegate (DispatchStind_I4), OpCodes.Stind_I4); Bind (new InstructionVisitorDelegate (DispatchStind_I8), OpCodes.Stind_I8); Bind (new InstructionVisitorDelegate (DispatchStind_R4), OpCodes.Stind_R4); Bind (new InstructionVisitorDelegate (DispatchStind_R8), OpCodes.Stind_R8); Bind (new InstructionVisitorDelegate (DispatchAdd), OpCodes.Add); Bind (new InstructionVisitorDelegate (DispatchSub), OpCodes.Sub); Bind (new InstructionVisitorDelegate (DispatchMul), OpCodes.Mul); Bind (new InstructionVisitorDelegate (DispatchDiv), OpCodes.Div); Bind (new InstructionVisitorDelegate (DispatchDiv_Un), OpCodes.Div_Un); Bind (new InstructionVisitorDelegate (DispatchRem), OpCodes.Rem); Bind (new InstructionVisitorDelegate (DispatchRem_Un), OpCodes.Rem_Un); Bind (new InstructionVisitorDelegate (DispatchAnd), OpCodes.And); Bind (new InstructionVisitorDelegate (DispatchOr), OpCodes.Or); Bind (new InstructionVisitorDelegate (DispatchXor), OpCodes.Xor); Bind (new InstructionVisitorDelegate (DispatchShl), OpCodes.Shl); Bind (new InstructionVisitorDelegate (DispatchShr), OpCodes.Shr); Bind (new InstructionVisitorDelegate (DispatchShr_Un), OpCodes.Shr_Un); Bind (new InstructionVisitorDelegate (DispatchNeg), OpCodes.Neg); Bind (new InstructionVisitorDelegate (DispatchNot), OpCodes.Not); Bind (new InstructionVisitorDelegate (DispatchConv_I1), OpCodes.Conv_I1); Bind (new InstructionVisitorDelegate (DispatchConv_I2), OpCodes.Conv_I2); Bind (new InstructionVisitorDelegate (DispatchConv_I4), OpCodes.Conv_I4); Bind (new InstructionVisitorDelegate (DispatchConv_I8), OpCodes.Conv_I8); Bind (new InstructionVisitorDelegate (DispatchConv_R4), OpCodes.Conv_R4); Bind (new InstructionVisitorDelegate (DispatchConv_R8), OpCodes.Conv_R8); Bind (new InstructionVisitorDelegate (DispatchConv_U4), OpCodes.Conv_U4); Bind (new InstructionVisitorDelegate (DispatchConv_U8), OpCodes.Conv_U8); Bind (new InstructionVisitorDelegate (DispatchCallvirt), OpCodes.Callvirt); Bind (new InstructionVisitorDelegate (DispatchCpobj), OpCodes.Cpobj); Bind (new InstructionVisitorDelegate (DispatchLdobj), OpCodes.Ldobj); Bind (new InstructionVisitorDelegate (DispatchLdstr), OpCodes.Ldstr); Bind (new InstructionVisitorDelegate (DispatchNewobj), OpCodes.Newobj); Bind (new InstructionVisitorDelegate (DispatchCastclass), OpCodes.Castclass); Bind (new InstructionVisitorDelegate (DispatchIsinst), OpCodes.Isinst); Bind (new InstructionVisitorDelegate (DispatchConv_R_Un), OpCodes.Conv_R_Un); Bind (new InstructionVisitorDelegate (DispatchUnbox), OpCodes.Unbox); Bind (new InstructionVisitorDelegate (DispatchThrow), OpCodes.Throw); Bind (new InstructionVisitorDelegate (DispatchLdfld), OpCodes.Ldfld); Bind (new InstructionVisitorDelegate (DispatchLdflda), OpCodes.Ldflda); Bind (new InstructionVisitorDelegate (DispatchStfld), OpCodes.Stfld); Bind (new InstructionVisitorDelegate (DispatchLdsfld), OpCodes.Ldsfld); Bind (new InstructionVisitorDelegate (DispatchLdsflda), OpCodes.Ldsflda); Bind (new InstructionVisitorDelegate (DispatchStsfld), OpCodes.Stsfld); Bind (new InstructionVisitorDelegate (DispatchStobj), OpCodes.Stobj); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I1_Un), OpCodes.Conv_Ovf_I1_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I2_Un), OpCodes.Conv_Ovf_I2_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I4_Un), OpCodes.Conv_Ovf_I4_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I8_Un), OpCodes.Conv_Ovf_I8_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U1_Un), OpCodes.Conv_Ovf_U1_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U2_Un), OpCodes.Conv_Ovf_U2_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U4_Un), OpCodes.Conv_Ovf_U4_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U8_Un), OpCodes.Conv_Ovf_U8_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I_Un), OpCodes.Conv_Ovf_I_Un); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U_Un), OpCodes.Conv_Ovf_U_Un); Bind (new InstructionVisitorDelegate (DispatchBox), OpCodes.Box); Bind (new InstructionVisitorDelegate (DispatchNewarr), OpCodes.Newarr); Bind (new InstructionVisitorDelegate (DispatchLdlen), OpCodes.Ldlen); Bind (new InstructionVisitorDelegate (DispatchLdelema), OpCodes.Ldelema); Bind (new InstructionVisitorDelegate (DispatchLdelem_I1), OpCodes.Ldelem_I1); Bind (new InstructionVisitorDelegate (DispatchLdelem_U1), OpCodes.Ldelem_U1); Bind (new InstructionVisitorDelegate (DispatchLdelem_I2), OpCodes.Ldelem_I2); Bind (new InstructionVisitorDelegate (DispatchLdelem_U2), OpCodes.Ldelem_U2); Bind (new InstructionVisitorDelegate (DispatchLdelem_I4), OpCodes.Ldelem_I4); Bind (new InstructionVisitorDelegate (DispatchLdelem_U4), OpCodes.Ldelem_U4); Bind (new InstructionVisitorDelegate (DispatchLdelem_I8), OpCodes.Ldelem_I8); Bind (new InstructionVisitorDelegate (DispatchLdelem_I), OpCodes.Ldelem_I); Bind (new InstructionVisitorDelegate (DispatchLdelem_R4), OpCodes.Ldelem_R4); Bind (new InstructionVisitorDelegate (DispatchLdelem_R8), OpCodes.Ldelem_R8); Bind (new InstructionVisitorDelegate (DispatchLdelem_Ref), OpCodes.Ldelem_Ref); Bind (new InstructionVisitorDelegate (DispatchStelem_I), OpCodes.Stelem_I); Bind (new InstructionVisitorDelegate (DispatchStelem_I1), OpCodes.Stelem_I1); Bind (new InstructionVisitorDelegate (DispatchStelem_I2), OpCodes.Stelem_I2); Bind (new InstructionVisitorDelegate (DispatchStelem_I4), OpCodes.Stelem_I4); Bind (new InstructionVisitorDelegate (DispatchStelem_I8), OpCodes.Stelem_I8); Bind (new InstructionVisitorDelegate (DispatchStelem_R4), OpCodes.Stelem_R4); Bind (new InstructionVisitorDelegate (DispatchStelem_R8), OpCodes.Stelem_R8); Bind (new InstructionVisitorDelegate (DispatchStelem_Ref), OpCodes.Stelem_Ref); Bind (new InstructionVisitorDelegate (DispatchLdelem_Any), OpCodes.Ldelem_Any); Bind (new InstructionVisitorDelegate (DispatchStelem_Any), OpCodes.Stelem_Any); Bind (new InstructionVisitorDelegate (DispatchUnbox_Any), OpCodes.Unbox_Any); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I1), OpCodes.Conv_Ovf_I1); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U1), OpCodes.Conv_Ovf_U1); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I2), OpCodes.Conv_Ovf_I2); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U2), OpCodes.Conv_Ovf_U2); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I4), OpCodes.Conv_Ovf_I4); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U4), OpCodes.Conv_Ovf_U4); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I8), OpCodes.Conv_Ovf_I8); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U8), OpCodes.Conv_Ovf_U8); Bind (new InstructionVisitorDelegate (DispatchRefanyval), OpCodes.Refanyval); Bind (new InstructionVisitorDelegate (DispatchCkfinite), OpCodes.Ckfinite); Bind (new InstructionVisitorDelegate (DispatchMkrefany), OpCodes.Mkrefany); Bind (new InstructionVisitorDelegate (DispatchLdtoken), OpCodes.Ldtoken); Bind (new InstructionVisitorDelegate (DispatchConv_U2), OpCodes.Conv_U2); Bind (new InstructionVisitorDelegate (DispatchConv_U1), OpCodes.Conv_U1); Bind (new InstructionVisitorDelegate (DispatchConv_I), OpCodes.Conv_I); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_I), OpCodes.Conv_Ovf_I); Bind (new InstructionVisitorDelegate (DispatchConv_Ovf_U), OpCodes.Conv_Ovf_U); Bind (new InstructionVisitorDelegate (DispatchAdd_Ovf), OpCodes.Add_Ovf); Bind (new InstructionVisitorDelegate (DispatchAdd_Ovf_Un), OpCodes.Add_Ovf_Un); Bind (new InstructionVisitorDelegate (DispatchMul_Ovf), OpCodes.Mul_Ovf); Bind (new InstructionVisitorDelegate (DispatchMul_Ovf_Un), OpCodes.Mul_Ovf_Un); Bind (new InstructionVisitorDelegate (DispatchSub_Ovf), OpCodes.Sub_Ovf); Bind (new InstructionVisitorDelegate (DispatchSub_Ovf_Un), OpCodes.Sub_Ovf_Un); Bind (new InstructionVisitorDelegate (DispatchEndfinally), OpCodes.Endfinally); Bind (new InstructionVisitorDelegate (DispatchLeave), OpCodes.Leave, OpCodes.Leave_S); Bind (new InstructionVisitorDelegate (DispatchStind_I), OpCodes.Stind_I); Bind (new InstructionVisitorDelegate (DispatchConv_U), OpCodes.Conv_U); Bind (new InstructionVisitorDelegate (DispatchArglist), OpCodes.Arglist); Bind (new InstructionVisitorDelegate (DispatchCeq), OpCodes.Ceq); Bind (new InstructionVisitorDelegate (DispatchCgt), OpCodes.Cgt); Bind (new InstructionVisitorDelegate (DispatchCgt_Un), OpCodes.Cgt_Un); Bind (new InstructionVisitorDelegate (DispatchClt), OpCodes.Clt); Bind (new InstructionVisitorDelegate (DispatchClt_Un), OpCodes.Clt_Un); Bind (new InstructionVisitorDelegate (DispatchLdftn), OpCodes.Ldftn); Bind (new InstructionVisitorDelegate (DispatchLdvirtftn), OpCodes.Ldvirtftn); Bind (new InstructionVisitorDelegate (DispatchLocalloc), OpCodes.Localloc); Bind (new InstructionVisitorDelegate (DispatchEndfilter), OpCodes.Endfilter); Bind (new InstructionVisitorDelegate (DispatchUnaligned), OpCodes.Unaligned); Bind (new InstructionVisitorDelegate (DispatchVolatile), OpCodes.Volatile); Bind (new InstructionVisitorDelegate (DispatchTail), OpCodes.Tail); Bind (new InstructionVisitorDelegate (DispatchInitobj), OpCodes.Initobj); Bind (new InstructionVisitorDelegate (DispatchCpblk), OpCodes.Cpblk); Bind (new InstructionVisitorDelegate (DispatchInitblk), OpCodes.Initblk); Bind (new InstructionVisitorDelegate (DispatchRethrow), OpCodes.Rethrow); Bind (new InstructionVisitorDelegate (DispatchSizeof), OpCodes.Sizeof); Bind (new InstructionVisitorDelegate (DispatchRefanytype), OpCodes.Refanytype); } static void Bind (InstructionVisitorDelegate handler, params OpCode[] opcodes) { foreach (OpCode op in opcodes) { _handlers.Add (op.Value, handler); } } static void DispatchNop (IInstructionVisitor visitor, Instruction instruction) { visitor.OnNop (instruction); } static void DispatchBreak (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBreak (instruction); } static void DispatchLdarg_0 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarg_0 (instruction); } static void DispatchLdarg_1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarg_1 (instruction); } static void DispatchLdarg_2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarg_2 (instruction); } static void DispatchLdarg_3 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarg_3 (instruction); } static void DispatchLdloc_0 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloc_0 (instruction); } static void DispatchLdloc_1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloc_1 (instruction); } static void DispatchLdloc_2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloc_2 (instruction); } static void DispatchLdloc_3 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloc_3 (instruction); } static void DispatchStloc_0 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStloc_0 (instruction); } static void DispatchStloc_1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStloc_1 (instruction); } static void DispatchStloc_2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStloc_2 (instruction); } static void DispatchStloc_3 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStloc_3 (instruction); } static void DispatchLdarg (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarg (instruction); } static void DispatchLdarga (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdarga (instruction); } static void DispatchStarg (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStarg (instruction); } static void DispatchLdloc (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloc (instruction); } static void DispatchLdloca (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdloca (instruction); } static void DispatchStloc (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStloc (instruction); } static void DispatchLdnull (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdnull (instruction); } static void DispatchLdc_I4_M1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_M1 (instruction); } static void DispatchLdc_I4_0 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_0 (instruction); } static void DispatchLdc_I4_1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_1 (instruction); } static void DispatchLdc_I4_2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_2 (instruction); } static void DispatchLdc_I4_3 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_3 (instruction); } static void DispatchLdc_I4_4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_4 (instruction); } static void DispatchLdc_I4_5 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_5 (instruction); } static void DispatchLdc_I4_6 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_6 (instruction); } static void DispatchLdc_I4_7 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_7 (instruction); } static void DispatchLdc_I4_8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4_8 (instruction); } static void DispatchLdc_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I4 (instruction); } static void DispatchLdc_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_I8 (instruction); } static void DispatchLdc_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_R4 (instruction); } static void DispatchLdc_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdc_R8 (instruction); } static void DispatchDup (IInstructionVisitor visitor, Instruction instruction) { visitor.OnDup (instruction); } static void DispatchPop (IInstructionVisitor visitor, Instruction instruction) { visitor.OnPop (instruction); } static void DispatchJmp (IInstructionVisitor visitor, Instruction instruction) { visitor.OnJmp (instruction); } static void DispatchCall (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCall (instruction); } static void DispatchCalli (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCalli (instruction); } static void DispatchRet (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRet (instruction); } static void DispatchBr (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBr (instruction); } static void DispatchBrfalse (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBrfalse (instruction); } static void DispatchBrtrue (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBrtrue (instruction); } static void DispatchBeq (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBeq (instruction); } static void DispatchBge (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBge (instruction); } static void DispatchBgt (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBgt (instruction); } static void DispatchBle (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBle (instruction); } static void DispatchBlt (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBlt (instruction); } static void DispatchBne_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBne_Un (instruction); } static void DispatchBge_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBge_Un (instruction); } static void DispatchBgt_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBgt_Un (instruction); } static void DispatchBle_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBle_Un (instruction); } static void DispatchBlt_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBlt_Un (instruction); } static void DispatchSwitch (IInstructionVisitor visitor, Instruction instruction) { visitor.OnSwitch (instruction); } static void DispatchLdind_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_I1 (instruction); } static void DispatchLdind_U1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_U1 (instruction); } static void DispatchLdind_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_I2 (instruction); } static void DispatchLdind_U2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_U2 (instruction); } static void DispatchLdind_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_I4 (instruction); } static void DispatchLdind_U4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_U4 (instruction); } static void DispatchLdind_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_I8 (instruction); } static void DispatchLdind_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_I (instruction); } static void DispatchLdind_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_R4 (instruction); } static void DispatchLdind_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_R8 (instruction); } static void DispatchLdind_Ref (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdind_Ref (instruction); } static void DispatchStind_Ref (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_Ref (instruction); } static void DispatchStind_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_I1 (instruction); } static void DispatchStind_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_I2 (instruction); } static void DispatchStind_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_I4 (instruction); } static void DispatchStind_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_I8 (instruction); } static void DispatchStind_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_R4 (instruction); } static void DispatchStind_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_R8 (instruction); } static void DispatchAdd (IInstructionVisitor visitor, Instruction instruction) { visitor.OnAdd (instruction); } static void DispatchSub (IInstructionVisitor visitor, Instruction instruction) { visitor.OnSub (instruction); } static void DispatchMul (IInstructionVisitor visitor, Instruction instruction) { visitor.OnMul (instruction); } static void DispatchDiv (IInstructionVisitor visitor, Instruction instruction) { visitor.OnDiv (instruction); } static void DispatchDiv_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnDiv_Un (instruction); } static void DispatchRem (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRem (instruction); } static void DispatchRem_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRem_Un (instruction); } static void DispatchAnd (IInstructionVisitor visitor, Instruction instruction) { visitor.OnAnd (instruction); } static void DispatchOr (IInstructionVisitor visitor, Instruction instruction) { visitor.OnOr (instruction); } static void DispatchXor (IInstructionVisitor visitor, Instruction instruction) { visitor.OnXor (instruction); } static void DispatchShl (IInstructionVisitor visitor, Instruction instruction) { visitor.OnShl (instruction); } static void DispatchShr (IInstructionVisitor visitor, Instruction instruction) { visitor.OnShr (instruction); } static void DispatchShr_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnShr_Un (instruction); } static void DispatchNeg (IInstructionVisitor visitor, Instruction instruction) { visitor.OnNeg (instruction); } static void DispatchNot (IInstructionVisitor visitor, Instruction instruction) { visitor.OnNot (instruction); } static void DispatchConv_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_I1 (instruction); } static void DispatchConv_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_I2 (instruction); } static void DispatchConv_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_I4 (instruction); } static void DispatchConv_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_I8 (instruction); } static void DispatchConv_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_R4 (instruction); } static void DispatchConv_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_R8 (instruction); } static void DispatchConv_U4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_U4 (instruction); } static void DispatchConv_U8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_U8 (instruction); } static void DispatchCallvirt (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCallvirt (instruction); } static void DispatchCpobj (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCpobj (instruction); } static void DispatchLdobj (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdobj (instruction); } static void DispatchLdstr (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdstr (instruction); } static void DispatchNewobj (IInstructionVisitor visitor, Instruction instruction) { visitor.OnNewobj (instruction); } static void DispatchCastclass (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCastclass (instruction); } static void DispatchIsinst (IInstructionVisitor visitor, Instruction instruction) { visitor.OnIsinst (instruction); } static void DispatchConv_R_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_R_Un (instruction); } static void DispatchUnbox (IInstructionVisitor visitor, Instruction instruction) { visitor.OnUnbox (instruction); } static void DispatchThrow (IInstructionVisitor visitor, Instruction instruction) { visitor.OnThrow (instruction); } static void DispatchLdfld (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdfld (instruction); } static void DispatchLdflda (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdflda (instruction); } static void DispatchStfld (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStfld (instruction); } static void DispatchLdsfld (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdsfld (instruction); } static void DispatchLdsflda (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdsflda (instruction); } static void DispatchStsfld (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStsfld (instruction); } static void DispatchStobj (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStobj (instruction); } static void DispatchConv_Ovf_I1_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I1_Un (instruction); } static void DispatchConv_Ovf_I2_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I2_Un (instruction); } static void DispatchConv_Ovf_I4_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I4_Un (instruction); } static void DispatchConv_Ovf_I8_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I8_Un (instruction); } static void DispatchConv_Ovf_U1_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U1_Un (instruction); } static void DispatchConv_Ovf_U2_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U2_Un (instruction); } static void DispatchConv_Ovf_U4_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U4_Un (instruction); } static void DispatchConv_Ovf_U8_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U8_Un (instruction); } static void DispatchConv_Ovf_I_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I_Un (instruction); } static void DispatchConv_Ovf_U_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U_Un (instruction); } static void DispatchBox (IInstructionVisitor visitor, Instruction instruction) { visitor.OnBox (instruction); } static void DispatchNewarr (IInstructionVisitor visitor, Instruction instruction) { visitor.OnNewarr (instruction); } static void DispatchLdlen (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdlen (instruction); } static void DispatchLdelema (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelema (instruction); } static void DispatchLdelem_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_I1 (instruction); } static void DispatchLdelem_U1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_U1 (instruction); } static void DispatchLdelem_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_I2 (instruction); } static void DispatchLdelem_U2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_U2 (instruction); } static void DispatchLdelem_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_I4 (instruction); } static void DispatchLdelem_U4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_U4 (instruction); } static void DispatchLdelem_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_I8 (instruction); } static void DispatchLdelem_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_I (instruction); } static void DispatchLdelem_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_R4 (instruction); } static void DispatchLdelem_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_R8 (instruction); } static void DispatchLdelem_Ref (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_Ref (instruction); } static void DispatchStelem_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_I (instruction); } static void DispatchStelem_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_I1 (instruction); } static void DispatchStelem_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_I2 (instruction); } static void DispatchStelem_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_I4 (instruction); } static void DispatchStelem_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_I8 (instruction); } static void DispatchStelem_R4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_R4 (instruction); } static void DispatchStelem_R8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_R8 (instruction); } static void DispatchStelem_Ref (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_Ref (instruction); } static void DispatchLdelem_Any (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdelem_Any (instruction); } static void DispatchStelem_Any (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStelem_Any (instruction); } static void DispatchUnbox_Any (IInstructionVisitor visitor, Instruction instruction) { visitor.OnUnbox_Any (instruction); } static void DispatchConv_Ovf_I1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I1 (instruction); } static void DispatchConv_Ovf_U1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U1 (instruction); } static void DispatchConv_Ovf_I2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I2 (instruction); } static void DispatchConv_Ovf_U2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U2 (instruction); } static void DispatchConv_Ovf_I4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I4 (instruction); } static void DispatchConv_Ovf_U4 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U4 (instruction); } static void DispatchConv_Ovf_I8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I8 (instruction); } static void DispatchConv_Ovf_U8 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U8 (instruction); } static void DispatchRefanyval (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRefanyval (instruction); } static void DispatchCkfinite (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCkfinite (instruction); } static void DispatchMkrefany (IInstructionVisitor visitor, Instruction instruction) { visitor.OnMkrefany (instruction); } static void DispatchLdtoken (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdtoken (instruction); } static void DispatchConv_U2 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_U2 (instruction); } static void DispatchConv_U1 (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_U1 (instruction); } static void DispatchConv_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_I (instruction); } static void DispatchConv_Ovf_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_I (instruction); } static void DispatchConv_Ovf_U (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_Ovf_U (instruction); } static void DispatchAdd_Ovf (IInstructionVisitor visitor, Instruction instruction) { visitor.OnAdd_Ovf (instruction); } static void DispatchAdd_Ovf_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnAdd_Ovf_Un (instruction); } static void DispatchMul_Ovf (IInstructionVisitor visitor, Instruction instruction) { visitor.OnMul_Ovf (instruction); } static void DispatchMul_Ovf_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnMul_Ovf_Un (instruction); } static void DispatchSub_Ovf (IInstructionVisitor visitor, Instruction instruction) { visitor.OnSub_Ovf (instruction); } static void DispatchSub_Ovf_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnSub_Ovf_Un (instruction); } static void DispatchEndfinally (IInstructionVisitor visitor, Instruction instruction) { visitor.OnEndfinally (instruction); } static void DispatchLeave (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLeave (instruction); } static void DispatchStind_I (IInstructionVisitor visitor, Instruction instruction) { visitor.OnStind_I (instruction); } static void DispatchConv_U (IInstructionVisitor visitor, Instruction instruction) { visitor.OnConv_U (instruction); } static void DispatchArglist (IInstructionVisitor visitor, Instruction instruction) { visitor.OnArglist (instruction); } static void DispatchCeq (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCeq (instruction); } static void DispatchCgt (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCgt (instruction); } static void DispatchCgt_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCgt_Un (instruction); } static void DispatchClt (IInstructionVisitor visitor, Instruction instruction) { visitor.OnClt (instruction); } static void DispatchClt_Un (IInstructionVisitor visitor, Instruction instruction) { visitor.OnClt_Un (instruction); } static void DispatchLdftn (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdftn (instruction); } static void DispatchLdvirtftn (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLdvirtftn (instruction); } static void DispatchLocalloc (IInstructionVisitor visitor, Instruction instruction) { visitor.OnLocalloc (instruction); } static void DispatchEndfilter (IInstructionVisitor visitor, Instruction instruction) { visitor.OnEndfilter (instruction); } static void DispatchUnaligned (IInstructionVisitor visitor, Instruction instruction) { visitor.OnUnaligned (instruction); } static void DispatchVolatile (IInstructionVisitor visitor, Instruction instruction) { visitor.OnVolatile (instruction); } static void DispatchTail (IInstructionVisitor visitor, Instruction instruction) { visitor.OnTail (instruction); } static void DispatchInitobj (IInstructionVisitor visitor, Instruction instruction) { visitor.OnInitobj (instruction); } static void DispatchCpblk (IInstructionVisitor visitor, Instruction instruction) { visitor.OnCpblk (instruction); } static void DispatchInitblk (IInstructionVisitor visitor, Instruction instruction) { visitor.OnInitblk (instruction); } static void DispatchRethrow (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRethrow (instruction); } static void DispatchSizeof (IInstructionVisitor visitor, Instruction instruction) { visitor.OnSizeof (instruction); } static void DispatchRefanytype (IInstructionVisitor visitor, Instruction instruction) { visitor.OnRefanytype (instruction); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/0000755000175000017500000000000011620326252025260 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/InstructionData.cs0000644000175000017500000000271011620326252030722 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion namespace Cecil.FlowAnalysis.ControlFlow { public class InstructionData { int _before; int _after; public int StackBefore { get { return _before; } } public int StackAfter { get { return _after; } } public InstructionData (int before, int after) { _before = before; _after = after; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/ControlFlowGraph.cs0000644000175000017500000000344611620326252031050 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System.Collections; using Cecil.FlowAnalysis.ControlFlow; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ControlFlow { public class ControlFlowGraph { InstructionBlock [] _blocks; MethodBody _body; IDictionary _data; public MethodBody MethodBody { get { return _body; } } public InstructionBlock [] Blocks { get { return _blocks; } } public ControlFlowGraph (MethodBody body, InstructionBlock [] blocks, IDictionary instructionData) { _body = body; _blocks = blocks; _data = instructionData; } public InstructionData GetData (Instruction instruction) { return (InstructionData) _data [instruction.Offset]; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/InstructionBlock.cs0000644000175000017500000000517411620326252031112 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.Collections; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ControlFlow { public class InstructionBlock : IComparable, IEnumerable { public static readonly InstructionBlock [] NoSuccessors = new InstructionBlock [0]; Instruction _firstInstruction; Instruction _lastInstruction; InstructionBlock [] _successors = NoSuccessors; public Instruction FirstInstruction { get { return _firstInstruction; } } public Instruction LastInstruction { get { return _lastInstruction; } } public InstructionBlock [] Successors { get { return _successors; } } internal InstructionBlock (Instruction first) { if (null == first) throw new ArgumentNullException ("first"); _firstInstruction = first; } internal void SetLastInstruction (Instruction last) { if (null == last) throw new ArgumentNullException ("last"); _lastInstruction = last; } internal void SetSuccessors (InstructionBlock [] successors) { _successors = successors; } public int CompareTo (object obj) { return _firstInstruction.Offset.CompareTo (((InstructionBlock)obj).FirstInstruction.Offset); } public IEnumerator GetEnumerator () { var instructions = new Collection (); Instruction instruction = _firstInstruction; while (true) { instructions.Add (instruction); if (instruction == _lastInstruction) break; instruction = instruction.Next; } return instructions.GetEnumerator (); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/ControlFlowGraphBuilder.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ControlFlow/ControlFlowGraphBuilder0000644000175000017500000002447611620326252031761 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.Collections; using System.Collections.Generic; using Cecil.FlowAnalysis.Utilities; using Cecil.FlowAnalysis.ControlFlow; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ControlFlow { /// /// class ControlFlowGraphBuilder { MethodBody _body; Dictionary _instructionData; Dictionary _blocks = new Dictionary (); InstructionBlock [] RegisteredBlocks { get { return ToArray (new InstructionBlock [BlockCount]); } } int BlockCount { get { return _blocks.Count; } } internal ControlFlowGraphBuilder (MethodDefinition method) { _body = method.Body; } public ControlFlowGraph BuildGraph () { DelimitBlocks (); ConnectBlocks (); ComputeInstructionData (); return new ControlFlowGraph (_body, RegisteredBlocks, _instructionData); } void DelimitBlocks () { var instructions = _body.Instructions; MarkBlockStarts (instructions); MarkBlockEnds (instructions); } void MarkBlockStarts (Collection instructions) { Instruction instruction = instructions [0]; // the first instruction starts a block MarkBlockStart (instruction); for (int i = 1; i < instructions.Count; ++i) { instruction = instructions [i]; if (!IsBlockDelimiter (instruction)) continue; if (HasMultipleBranches (instruction)) { // each switch case first instruction starts a block foreach (Instruction target in GetBranchTargets (instruction)) if (target != null) MarkBlockStart (target); } else { // the target of a branch starts a block Instruction target = GetBranchTarget (instruction); if (null != target) MarkBlockStart (target); } // the next instruction after a branch starts a block if (null != instruction.Next) MarkBlockStart (instruction.Next); } } void MarkBlockEnds (Collection instructions) { InstructionBlock [] blocks = this.RegisteredBlocks; InstructionBlock current = blocks [0]; for (int i = 1; i < blocks.Length; ++i) { InstructionBlock block = blocks [i]; current.SetLastInstruction (block.FirstInstruction.Previous); current = block; } current.SetLastInstruction (instructions [instructions.Count - 1]); } static bool IsBlockDelimiter (Instruction instruction) { FlowControl control = instruction.OpCode.FlowControl; switch (control) { case FlowControl.Break: case FlowControl.Branch: case FlowControl.Return: case FlowControl.Cond_Branch: return true; } return false; } void MarkBlockStart (Instruction instruction) { InstructionBlock block = GetBlock (instruction); if (null != block) return; block = new InstructionBlock (instruction); RegisterBlock (block); } void ComputeInstructionData () { _instructionData = new Dictionary (); var visited = new HashSet (); ComputeInstructionData (visited, 0, GetFirstBlock ()); } InstructionBlock GetFirstBlock () { return GetBlock (_body.Instructions [0]); } void ComputeInstructionData (HashSet visited, int stackHeight, InstructionBlock block) { if (visited.Contains (block)) return; visited.Add (block); foreach (Instruction instruction in block) { stackHeight = ComputeInstructionData (stackHeight, instruction); } foreach (InstructionBlock successor in block.Successors) { ComputeInstructionData (visited, stackHeight, successor); } } int ComputeInstructionData (int stackHeight, Instruction instruction) { int before = stackHeight; int after = ComputeNewStackHeight (stackHeight, instruction); _instructionData.Add (instruction.Offset, new InstructionData (before, after)); return after; } int ComputeNewStackHeight (int stackHeight, Instruction instruction) { return stackHeight + GetPushDelta (instruction) - GetPopDelta (stackHeight, instruction); } static int GetPushDelta (Instruction instruction) { OpCode code = instruction.OpCode; switch (code.StackBehaviourPush) { case StackBehaviour.Push0: return 0; case StackBehaviour.Push1: case StackBehaviour.Pushi: case StackBehaviour.Pushi8: case StackBehaviour.Pushr4: case StackBehaviour.Pushr8: case StackBehaviour.Pushref: return 1; case StackBehaviour.Push1_push1: return 2; case StackBehaviour.Varpush: if (code.FlowControl == FlowControl.Call) { MethodReference method = (MethodReference)instruction.Operand; return IsVoid (method.ReturnType) ? 0 : 1; } break; } throw new ArgumentException (Formatter.FormatInstruction (instruction)); } int GetPopDelta (int stackHeight, Instruction instruction) { OpCode code = instruction.OpCode; switch (code.StackBehaviourPop) { case StackBehaviour.Pop0: return 0; case StackBehaviour.Popi: case StackBehaviour.Popref: case StackBehaviour.Pop1: return 1; case StackBehaviour.Pop1_pop1: case StackBehaviour.Popi_pop1: case StackBehaviour.Popi_popi: case StackBehaviour.Popi_popi8: case StackBehaviour.Popi_popr4: case StackBehaviour.Popi_popr8: case StackBehaviour.Popref_pop1: case StackBehaviour.Popref_popi: return 2; case StackBehaviour.Popi_popi_popi: case StackBehaviour.Popref_popi_popi: case StackBehaviour.Popref_popi_popi8: case StackBehaviour.Popref_popi_popr4: case StackBehaviour.Popref_popi_popr8: case StackBehaviour.Popref_popi_popref: return 3; case StackBehaviour.PopAll: return stackHeight; case StackBehaviour.Varpop: if (code.FlowControl == FlowControl.Call) { MethodReference method = (MethodReference)instruction.Operand; int count = method.Parameters.Count; if (method.HasThis && OpCodes.Newobj.Value != code.Value) ++count; return count; } if (code.Value == OpCodes.Ret.Value) return IsVoidMethod () ? 0 : 1; break; } throw new ArgumentException (Formatter.FormatInstruction (instruction)); } bool IsVoidMethod () { return IsVoid (_body.Method.ReturnType); } static bool IsVoid (TypeReference type) { return type.MetadataType == MetadataType.Void; } InstructionBlock [] ToArray (InstructionBlock [] blocks) { _blocks.Values.CopyTo (blocks, 0); Array.Sort (blocks); return blocks; } void ConnectBlocks () { foreach (InstructionBlock block in _blocks.Values) ConnectBlock (block); } void ConnectBlock (InstructionBlock block) { if (block.LastInstruction == null) throw new ArgumentException ("Undelimited block at offset " + block.FirstInstruction.Offset); Instruction instruction = block.LastInstruction; switch (instruction.OpCode.FlowControl) { case FlowControl.Branch: case FlowControl.Cond_Branch: { if (HasMultipleBranches (instruction)) { InstructionBlock [] blocks = GetBranchTargetsBlocks (instruction); if (instruction.Next != null) blocks = AddBlock (GetBlock (instruction.Next), blocks); block.SetSuccessors (blocks); break; } InstructionBlock target = GetBranchTargetBlock (instruction); if (instruction.OpCode.FlowControl == FlowControl.Cond_Branch && instruction.Next != null) block.SetSuccessors (new InstructionBlock [] { target, GetBlock (instruction.Next) }); else block.SetSuccessors (new InstructionBlock [] { target }); break; } case FlowControl.Call: case FlowControl.Next: if (null != instruction.Next) block.SetSuccessors (new InstructionBlock [] { GetBlock (instruction.Next) }); break; case FlowControl.Return: break; default: throw new ArgumentException ( string.Format ("Unhandled instruction flow behavior {0}: {1}", instruction.OpCode.FlowControl, Formatter.FormatInstruction (instruction))); } } static InstructionBlock [] AddBlock (InstructionBlock block, InstructionBlock [] blocks) { InstructionBlock [] result = new InstructionBlock [blocks.Length + 1]; Array.Copy (blocks, result, blocks.Length); result [result.Length - 1] = block; return result; } static bool HasMultipleBranches (Instruction instruction) { return instruction.OpCode.Code == Code.Switch; } InstructionBlock [] GetBranchTargetsBlocks (Instruction instruction) { Instruction [] targets = GetBranchTargets (instruction); InstructionBlock [] blocks = new InstructionBlock [targets.Length]; for (int i = 0; i < targets.Length; i++) blocks [i] = GetBlock (targets [i]); return blocks; } static Instruction [] GetBranchTargets (Instruction instruction) { return (Instruction []) instruction.Operand; } InstructionBlock GetBranchTargetBlock (Instruction instruction) { return GetBlock (GetBranchTarget (instruction)); } static Instruction GetBranchTarget (Instruction instruction) { return (Instruction) instruction.Operand; } void RegisterBlock (InstructionBlock block) { _blocks.Add (block.FirstInstruction.Offset, block); } InstructionBlock GetBlock (Instruction firstInstruction) { InstructionBlock block; _blocks.TryGetValue (firstInstruction.Offset, out block); return block; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/0000755000175000017500000000000011620326252025603 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/BinaryOperator.cs0000644000175000017500000000272511620326252031100 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion namespace Cecil.FlowAnalysis.CodeStructure { public enum BinaryOperator { None, Add, Subtract, Multiply, Divide, ValueEquality, ValueInequality, LogicalOr, LogicalAnd, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, LeftShift, RightShift, BitwiseOr, BitwiseAnd, BitwiseXor, Modulo, } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ICodeElement.cs0000644000175000017500000000246311620326252030434 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion namespace Cecil.FlowAnalysis.CodeStructure { public interface ICodeElement { CodeElementType CodeElementType { get; } void Accept (ICodeStructureVisitor visitor); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ICodeStructureVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ICodeStructureVisitor0000644000175000017500000000357411620326252032023 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit namespace Cecil.FlowAnalysis.CodeStructure { public interface ICodeStructureVisitor { void Visit (MethodInvocationExpression node); void Visit (MethodReferenceExpression node); void Visit (LiteralExpression node); void Visit (UnaryExpression node); void Visit (BinaryExpression node); void Visit (AssignExpression node); void Visit (ArgumentReferenceExpression node); void Visit (VariableReferenceExpression node); void Visit (ThisReferenceExpression node); void Visit (FieldReferenceExpression node); void Visit (PropertyReferenceExpression node); void Visit (BlockStatement node); void Visit (ReturnStatement node); void Visit (CastExpression node); void Visit (TryCastExpression node); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/AbstractCodeStructureVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/AbstractCodeStructure0000644000175000017500000000553411620326252032014 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System.Collections; namespace Cecil.FlowAnalysis.CodeStructure { public class AbstractCodeStructureVisitor : ICodeStructureVisitor { public virtual void Visit (ICodeElement node) { if (null == node) return; node.Accept (this); } public virtual void Visit (ICollection collection) { foreach (ICodeElement node in collection) { Visit (node); } } public virtual void Visit (MethodInvocationExpression node) { Visit (node.Target); Visit (node.Arguments); } public virtual void Visit (MethodReferenceExpression node) { Visit (node.Target); } public virtual void Visit (LiteralExpression node) { } public virtual void Visit (UnaryExpression node) { Visit (node.Operand); } public virtual void Visit (BinaryExpression node) { Visit (node.Left); Visit (node.Right); } public virtual void Visit (AssignExpression node) { Visit (node.Target); Visit (node.Expression); } public virtual void Visit (ArgumentReferenceExpression node) { } public virtual void Visit (VariableReferenceExpression node) { } public virtual void Visit (ThisReferenceExpression node) { } public virtual void Visit (FieldReferenceExpression node) { Visit (node.Target); } public virtual void Visit (PropertyReferenceExpression node) { Visit (node.Target); } public virtual void Visit (BlockStatement node) { Visit (node.Statements); } public virtual void Visit (ReturnStatement node) { Visit (node.Expression); } public virtual void Visit (CastExpression node) { Visit (node.Target); } public virtual void Visit (TryCastExpression node) { Visit (node.Target); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/PropertyReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/PropertyReferenceExpr0000644000175000017500000000353711620326252032040 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class PropertyReferenceExpression : Expression { Expression _target; PropertyReference _property; public PropertyReferenceExpression (Expression target, PropertyReference property) { _target = target; _property = property; } public Expression Target { get { return _target; } } public PropertyReference Property { get { return _property; } } public override CodeElementType CodeElementType { get { return CodeElementType.PropertyReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/BlockStatement.cs0000644000175000017500000000336311620326252031056 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.CodeStructure { public class BlockStatement : Statement { Collection _statements; public BlockStatement (Collection statements) { _statements = statements; } public Collection Statements { get { return _statements; } } public override CodeElementType CodeElementType { get { return CodeElementType.BlockStatement; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/CastExpression.cs0000644000175000017500000000344011620326252031105 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class CastExpression : Expression { Expression _target; TypeReference _toType; public CastExpression (Expression target, TypeReference toType) { _target = target; _toType = toType; } public Expression Target { get { return _target; } } public TypeReference ToType { get { return _toType; } } public override CodeElementType CodeElementType { get { return CodeElementType.CastExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/Expression.cs0000644000175000017500000000272611620326252030300 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public abstract class Expression : ICodeElement { public Expression () { } public abstract CodeElementType CodeElementType { get; } public abstract void Accept (ICodeStructureVisitor visitor); } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/UnaryExpression.cs0000644000175000017500000000346711620326252031322 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class UnaryExpression : Expression { UnaryOperator _operator; Expression _operand; public UnaryExpression (UnaryOperator operator_, Expression operand) { _operator = operator_; _operand = operand; } public UnaryOperator Operator { get { return _operator; } } public Expression Operand { get { return _operand; } } public override CodeElementType CodeElementType { get { return CodeElementType.UnaryExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/MethodReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/MethodReferenceExpres0000644000175000017500000000350711620326252031761 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class MethodReferenceExpression : Expression { Expression _target; MethodReference _method; public MethodReferenceExpression (Expression target, MethodReference method) { _target = target; _method = method; } public Expression Target { get { return _target; } } public MethodReference Method { get { return _method; } } public override CodeElementType CodeElementType { get { return CodeElementType.MethodReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/FieldReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/FieldReferenceExpress0000644000175000017500000000347311620326252031751 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class FieldReferenceExpression : Expression { Expression _target; FieldReference _field; public FieldReferenceExpression (Expression target, FieldReference field) { _target = target; _field = field; } public Expression Target { get { return _target; } } public FieldReference Field { get { return _field; } } public override CodeElementType CodeElementType { get { return CodeElementType.FieldReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/AssignExpression.cs0000644000175000017500000000346511620326252031446 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class AssignExpression : Expression { Expression _target; Expression _expression; public AssignExpression (Expression target, Expression expression) { _target = target; _expression = expression; } public Expression Target { get { return _target; } } public Expression Expression { get { return _expression; } } public override CodeElementType CodeElementType { get { return CodeElementType.AssignExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/UnaryOperator.cs0000644000175000017500000000236711620326252030754 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion namespace Cecil.FlowAnalysis.CodeStructure { public enum UnaryOperator { None, BitwiseComplement, Not, } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ReturnStatement.cs0000644000175000017500000000326411620326252031303 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class ReturnStatement : Statement { Expression _expression; public ReturnStatement (Expression expression) { _expression = expression; } public Expression Expression { get { return _expression; } } public override CodeElementType CodeElementType { get { return CodeElementType.ReturnStatement; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ArgumentReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ArgumentReferenceExpr0000644000175000017500000000335311620326252031772 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class ArgumentReferenceExpression : Expression { ParameterReference _parameter; public ArgumentReferenceExpression (ParameterReference parameter) { _parameter = parameter; } public ParameterReference Parameter { get { return _parameter; } } public override CodeElementType CodeElementType { get { return CodeElementType.ArgumentReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/CodeElementType.cs0000644000175000017500000000314311620326252031161 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit namespace Cecil.FlowAnalysis.CodeStructure { public enum CodeElementType { MethodInvocationExpression, MethodReferenceExpression, LiteralExpression, UnaryExpression, BinaryExpression, AssignExpression, ArgumentReferenceExpression, VariableReferenceExpression, ThisReferenceExpression, FieldReferenceExpression, PropertyReferenceExpression, BlockStatement, ReturnStatement, CastExpression, TryCastExpression } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/Statement.cs0000644000175000017500000000272411620326252030103 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public abstract class Statement : ICodeElement { public Statement () { } public abstract CodeElementType CodeElementType { get; } public abstract void Accept (ICodeStructureVisitor visitor); } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ExpressionPrinter.cs0000644000175000017500000001247111620326252031642 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.IO; using Cecil.FlowAnalysis.Utilities; using Mono.Cecil; namespace Cecil.FlowAnalysis.CodeStructure { /// /// public class ExpressionPrinter : AbstractCodeStructureVisitor { public static string ToString (Expression expression) { ExpressionPrinter printer = new ExpressionPrinter (); expression.Accept (printer); return printer.Writer.ToString (); } private TextWriter _writer; public ExpressionPrinter () { _writer = new StringWriter (); } public ExpressionPrinter (TextWriter writer) { if (null == writer) throw new ArgumentNullException ("writer"); _writer = writer; } public TextWriter Writer { get { return _writer; } } public override void Visit (AssignExpression node) { Visit (node.Target); Write (" = "); Visit (node.Expression); } public override void Visit (BinaryExpression node) { Write ("("); Visit (node.Left); Write (" {0} ", ToString (node.Operator)); Visit (node.Right); Write (")"); } public override void Visit (CastExpression node) { Write ("(("); Write (node.ToType.FullName); Write (")"); Visit (node.Target); Write (")"); } public override void Visit (TryCastExpression node) { Write ("("); Visit (node.Target); Write (" as "); Write (node.ToType.FullName); Write (")"); } public override void Visit (ArgumentReferenceExpression node) { Write (node.Parameter.Name); } public override void Visit (ThisReferenceExpression node) { Write ("this"); } public override void Visit (FieldReferenceExpression node) { if (node.Target != null) { Visit(node.Target); Write(".{0}", node.Field.Name); } else { Write("{0}.{1}", node.Field.DeclaringType.FullName, node.Field.Name); } } public override void Visit (MethodReferenceExpression node) { MethodReference method = node.Method; if (null == node.Target) { Write (Formatter.FormatTypeReference (method.DeclaringType)); } else { Visit (node.Target); } Write (".{0}", method.Name); } public override void Visit (MethodInvocationExpression node) { Visit (node.Target); Write ("("); for (int i=0; i < node.Arguments.Count; ++i) { if (i > 0) Write (", "); Visit (node.Arguments [i]); } Write (")"); } public override void Visit (VariableReferenceExpression node) { string name = "local" + node.Variable.Index; Write (name); } public override void Visit (LiteralExpression node) { object value = node.Value; if (value is string) { Write ("\"{0}\"", value); return; } Write (value == null ? "null" : Formatter.ToInvariantCultureString (value).ToLower ()); } public override void Visit (UnaryExpression node) { Write ("("); Write (ToString (node.Operator)); Visit (node.Operand); Write (")"); } static string ToString (UnaryOperator op) { switch (op) { case UnaryOperator.BitwiseComplement: return "~"; case UnaryOperator.Not: return "!"; } throw new ArgumentException (op.ToString (), "op"); } static string ToString (BinaryOperator op) { switch (op) { case BinaryOperator.LogicalAnd: return "&&"; case BinaryOperator.LogicalOr: return "||"; case BinaryOperator.Add: return "+"; case BinaryOperator.Subtract: return "-"; case BinaryOperator.Multiply: return "*"; case BinaryOperator.Divide: return "/"; case BinaryOperator.ValueEquality: return "=="; case BinaryOperator.ValueInequality: return "!="; case BinaryOperator.LessThan: return "<"; case BinaryOperator.LessThanOrEqual: return "<="; case BinaryOperator.GreaterThan: return ">"; case BinaryOperator.GreaterThanOrEqual: return ">="; case BinaryOperator.RightShift: return ">>"; case BinaryOperator.LeftShift: return "<<"; case BinaryOperator.BitwiseAnd: return "&"; case BinaryOperator.BitwiseOr: return "|"; case BinaryOperator.BitwiseXor: return "^"; case BinaryOperator.Modulo: return "%"; } throw new ArgumentException (op.ToString (), "op"); } void Write (string text) { _writer.Write (text); } void Write (string format, params object [] args) { _writer.Write (format, args); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/TryCastExpression.cs0000644000175000017500000000345111620326252031606 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class TryCastExpression : Expression { Expression _target; TypeReference _toType; public TryCastExpression (Expression target, TypeReference toType) { _target = target; _toType = toType; } public Expression Target { get { return _target; } } public TypeReference ToType { get { return _toType; } } public override CodeElementType CodeElementType { get { return CodeElementType.TryCastExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/MethodInvocationExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/MethodInvocationExpre0000644000175000017500000000362211620326252032007 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.CodeStructure { public class MethodInvocationExpression : Expression { Expression _target; Collection _arguments; public MethodInvocationExpression (Expression target, Collection arguments) { _target = target; _arguments = arguments; } public Expression Target { get { return _target; } } public Collection Arguments { get { return _arguments; } } public override CodeElementType CodeElementType { get { return CodeElementType.MethodInvocationExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/LiteralExpression.cs0000644000175000017500000000322111620326252031604 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class LiteralExpression : Expression { object _value; public LiteralExpression (object value) { _value = value; } public object Value { get { return _value; } } public override CodeElementType CodeElementType { get { return CodeElementType.LiteralExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ThisReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/ThisReferenceExpressi0000644000175000017500000000307211620326252032001 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class ThisReferenceExpression : Expression { public ThisReferenceExpression () { } public override CodeElementType CodeElementType { get { return CodeElementType.ThisReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/VariableReferenceExpression.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/VariableReferenceExpr0000644000175000017500000000334211620326252031733 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class VariableReferenceExpression : Expression { VariableReference _variable; public VariableReferenceExpression (VariableReference variable) { _variable = variable; } public VariableReference Variable { get { return _variable; } } public override CodeElementType CodeElementType { get { return CodeElementType.VariableReferenceExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CodeStructure/BinaryExpression.cs0000644000175000017500000000364211620326252031443 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class BinaryExpression : Expression { BinaryOperator _operator; Expression _left; Expression _right; public BinaryExpression (BinaryOperator operator_, Expression left, Expression right) { _operator = operator_; _left = left; _right = right; } public BinaryOperator Operator { get { return _operator; } } public Expression Left { get { return _left; } } public Expression Right { get { return _right; } } public override CodeElementType CodeElementType { get { return CodeElementType.BinaryExpression; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/0000755000175000017500000000000011620326252025055 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ActionType.cs0000644000175000017500000000241011620326252027460 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion namespace Cecil.FlowAnalysis.ActionFlow { public enum ActionType { Assign, Invoke, Branch, ConditionalBranch, Return } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/BranchActionBlock.cs0000644000175000017500000000401011620326252030705 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Cecil.FlowAnalysis.ActionFlow; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { public class BranchActionBlock : ActionBlock { ActionBlock _target; public ActionBlock Target { get { return _target; } } public override ActionType ActionType { get { return ActionType.Branch; } } public override ActionBlock [] Successors { get { return new ActionBlock [] { _target }; } } public BranchActionBlock (Instruction sourceInstruction) : base (sourceInstruction) { } internal void SetTarget (ActionBlock target) { if (null == target) throw new ArgumentNullException ("target"); _target = target; AddAsPredecessorOf (target); } internal override void ReplaceSuccessor (ActionBlock existing, ActionBlock newBlock) { if (_target != existing) throw new ArgumentException ("existing"); _target = newBlock; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ActionFlowGraph.cs0000644000175000017500000000553711620326252030445 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.ControlFlow; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ActionFlow { public class ActionFlowGraph { Collection _blocks; ControlFlowGraph _cfg; public ActionFlowGraph (ControlFlowGraph cfg, Collection blocks) { if (null == cfg) throw new ArgumentNullException ("cfg"); if (null == blocks) throw new ArgumentNullException ("blocks"); _cfg = cfg; _blocks = blocks; } public ControlFlowGraph ControlFlowGraph { get { return _cfg; } } public Collection Blocks { get { return _blocks; } } public bool IsBranchTarget (ActionBlock block) { if (null == block) throw new ArgumentNullException ("block"); foreach (ActionBlock p in block.Predecessors) { switch (p.ActionType) { case ActionType.Branch: BranchActionBlock br = (BranchActionBlock) p; if (br.Target == block) return true; break; case ActionType.ConditionalBranch: ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock) p; if (cbr.Then == block) return true; break; } } return false; } internal void ReplaceAt (int index, ActionBlock block) { if (null == block) throw new ArgumentNullException ("block"); ActionBlock existing = _blocks [index]; foreach (ActionBlock p in existing.Predecessors.ToArray ()) { p.ReplaceSuccessor (existing, block); } Remove (existing); _blocks.Insert (index, block); } void Remove (ActionBlock block) { foreach (ActionBlock s in block.Successors) { s.RemovePredecessor (block); if (0 == s.Predecessors.Count) { Remove (s); } } _blocks.Remove (block); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ReturnActionBlock.cs0000644000175000017500000000353711620326252031004 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { public class ReturnActionBlock : ActionBlock { Expression _expression; public override ActionType ActionType { get { return ActionType.Return; } } public Expression Expression { get { return _expression; } } public override ActionBlock [] Successors { get { return new ActionBlock [0]; } } public ReturnActionBlock (Instruction sourceInstruction, Expression expression) : base (sourceInstruction) { _expression = expression; } internal override void ReplaceSuccessor (ActionBlock existing, ActionBlock newBlock) { throw new InvalidOperationException (); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ActionBlock.cs0000644000175000017500000000425511620326252027602 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ActionFlow { /// /// public abstract class ActionBlock { Collection _predecessors = new Collection (); Instruction _sourceInstruction; public Instruction SourceInstruction { get { return _sourceInstruction; } } public virtual Collection Predecessors { get { return _predecessors; } } public abstract ActionType ActionType { get; } public abstract ActionBlock [] Successors { get; } internal ActionBlock (Instruction sourceInstruction) { if (null == sourceInstruction) throw new ArgumentNullException ("sourceInstruction"); _sourceInstruction = sourceInstruction; } protected void AddAsPredecessorOf (ActionBlock block) { block.Predecessors.Add (this); } internal void RemovePredecessor (ActionBlock block) { _predecessors.Remove (block); } internal abstract void ReplaceSuccessor (ActionBlock existing, ActionBlock newBlock); } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/AssignActionBlock.cs0000644000175000017500000000330611620326252030743 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { public class AssignActionBlock : AbstractFallThroughActionBlock { AssignExpression _assignExpression; public override ActionType ActionType { get { return ActionType.Assign; } } public AssignExpression AssignExpression { get { return _assignExpression; } } public AssignActionBlock (Instruction sourceInstruction, AssignExpression assign) : base (sourceInstruction) { _assignExpression = assign; } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/AbstractFallThroughActionBlock.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/AbstractFallThroughActio0000644000175000017500000000360111620326252031663 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { public abstract class AbstractFallThroughActionBlock : ActionBlock { protected ActionBlock _next; public ActionBlock Next { get { return _next; } } public override ActionBlock [] Successors { get { return new ActionBlock [] { _next }; } } public AbstractFallThroughActionBlock (Instruction sourceInstruction) : base (sourceInstruction) { } internal void SetNext (ActionBlock next) { if (null == next) return; _next = next; AddAsPredecessorOf (_next); } internal override void ReplaceSuccessor (ActionBlock existing, ActionBlock newBlock) { if (_next != existing) throw new ArgumentException ("existing"); _next = newBlock; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/InvokeActionBlock.cs0000644000175000017500000000334211620326252030752 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { public class InvokeActionBlock : AbstractFallThroughActionBlock { MethodInvocationExpression _expression; public override ActionType ActionType { get { return ActionType.Invoke; } } public MethodInvocationExpression Expression { get { return _expression; } } public InvokeActionBlock (Instruction sourceInstruction, MethodInvocationExpression expression) : base (sourceInstruction) { _expression = expression; } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ConditionalBranchActionBlock.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ConditionalBranchActionB0000644000175000017500000000507411620326252031627 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.ActionFlow { /// /// public class ConditionalBranchActionBlock : ActionBlock { Expression _condition; ActionBlock _then; ActionBlock _else; public override ActionType ActionType { get { return ActionType.ConditionalBranch; } } public Expression Condition { get { return _condition; } } public ActionBlock Then { get { return _then; } } public ActionBlock Else { get { return _else; } } public override ActionBlock [] Successors { get { return _else != null ? new ActionBlock [] { _then, _else } : new ActionBlock [] { _then }; } } public ConditionalBranchActionBlock (Instruction sourceInstruction, Expression condition) : base (sourceInstruction) { if (null == condition) throw new ArgumentNullException ("condition"); _condition = condition; } internal void SetTargets (ActionBlock then, ActionBlock else_) { if (null == then) throw new ArgumentNullException ("then"); AddAsPredecessorOf (then); if (null != else_) AddAsPredecessorOf (else_); _then = then; _else = else_; } internal override void ReplaceSuccessor (ActionBlock existing, ActionBlock newBlock) { if (existing == _then) _then = newBlock; else if (existing == _else) _else = newBlock; else throw new ArgumentException ("existing"); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ActionFlowGraphBuilder.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ActionFlowGraphBuilder.c0000644000175000017500000003171211620326252031563 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.Collections; using System.Collections.Generic; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.ControlFlow; using Cecil.FlowAnalysis.CodeStructure; using Cecil.FlowAnalysis.Utilities; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ActionFlow { /// /// internal class ActionFlowGraphBuilder : AbstractInstructionVisitor { Collection _blocks = new Collection (); Dictionary _instruction2block = new Dictionary (); HashSet _processed = new HashSet (); ExpressionDecompiler _expressionDecompiler; MethodDefinition _method; ControlFlowGraph _cfg; Instruction _current; ActionFlowGraph _graph; internal ActionFlowGraphBuilder (ControlFlowGraph cfg) { _method = cfg.MethodBody.Method; _cfg = cfg; _expressionDecompiler = new ExpressionDecompiler (_method); _graph = new ActionFlowGraph (_cfg, _blocks); } public ActionFlowGraph BuildGraph () { Run (); return _graph; } void Run () { ProcessBlocks (); ConnectActionBlocks (); SimplifyActionBlocks (); } void SimplifyActionBlocks () { int index = 0; while (index < _blocks.Count) { ActionBlock block = _blocks [index]; switch (block.ActionType) { case ActionType.ConditionalBranch: /// if condition goto label /// return expression /// label: return true /// | /// V /// return (condition || expression) /// /// label: return false /// | /// V /// return (!condition || expression) ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock)block; if (IsReturnTrueOrFalse (cbr.Then) && IsReturn (cbr.Else) && 1 == cbr.Then.Predecessors.Count && 1 == cbr.Else.Predecessors.Count) { BinaryOperator op = BinaryOperator.LogicalOr; Expression lhs = cbr.Condition; Expression rhs = ((ReturnActionBlock) cbr.Else).Expression; if (((LiteralExpression) ((ReturnActionBlock) cbr.Then).Expression).Value.Equals (0)) { op = BinaryOperator.LogicalAnd; _expressionDecompiler.Negate (lhs); lhs = _expressionDecompiler.Pop (); } ActionBlock newBlock = new ReturnActionBlock ( block.SourceInstruction, new BinaryExpression (op, lhs, rhs)); _graph.ReplaceAt (index, newBlock); index = 0; continue; } break; } ++index; } } static bool IsReturnTrueOrFalse (ActionBlock block) { ReturnActionBlock ret = block as ReturnActionBlock; return ret != null && IsTrueOrFalse (ret.Expression); } static bool IsTrueOrFalse (Expression expression) { LiteralExpression literal = expression as LiteralExpression; return literal != null && literal.Value != null && (literal.Value.Equals (1) || literal.Value.Equals (0)); } static bool IsReturn (ActionBlock block) { return block.ActionType == ActionType.Return; } void ConnectActionBlocks () { for (int i=0; i < _blocks.Count; ++i) { ActionBlock block = _blocks [i]; switch (block.ActionType) { case ActionType.Branch: BranchActionBlock br = (BranchActionBlock) block; br.SetTarget (GetBranchTarget (br.SourceInstruction)); break; case ActionType.ConditionalBranch: ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock) block; cbr.SetTargets (GetBranchTarget (cbr.SourceInstruction), GetBlockAtOrNull (i + 1)); break; case ActionType.Return: break; default: AbstractFallThroughActionBlock ftb = (AbstractFallThroughActionBlock) block; ftb.SetNext (GetBlockAtOrNull (i + 1)); break; } } } ActionBlock GetBlockAtOrNull (int index) { return index >= _blocks.Count ? null : _blocks [index]; } ActionBlock GetBranchTarget (Instruction instruction) { return GetActionBlock ((Instruction) instruction.Operand); } void ProcessBlocks () { foreach (InstructionBlock block in _cfg.Blocks) { if (WasProcessed (block)) continue; _current = block.FirstInstruction; ProcessBlock (block); } } void ProcessBlock (InstructionBlock block) { switch (block.Successors.Length) { case 0: case 1: ProcessSimpleBlock (block); break; case 2: ProcessTwoWayBlock (block); break; default: throw new ArgumentException ("n-way block not supported", "block"); } MarkProcessed (block); } void ProcessTwoWayBlock (InstructionBlock block) { if (IsLogicalExpression (block)) { ProcessLogicalExpressionBlock (block); } else { ProcessSimpleBlock (block); } } /// /// Checks if the subgraph starting at block represents /// a logical expression. /// /// /// bool IsLogicalExpression (InstructionBlock block) { return IsLogicalExpression (new HashSet (), block); } bool IsLogicalExpression (HashSet visited, InstructionBlock block) { if (visited.Contains (block)) return false; visited.Add (block); foreach (InstructionBlock successor in block.Successors) { if (GetStackAfter (successor.LastInstruction) > 0) return true; if (IsLogicalExpression (visited, successor)) return true; } return false; } void ProcessSimpleBlock (InstructionBlock block) { foreach (Instruction instruction in block) { _expressionDecompiler.Visit (instruction); if (0 == GetStackAfter (instruction)) { CreateActionBlock (instruction); _current = instruction.Next; } } } void ProcessLogicalExpressionBlock (InstructionBlock block) { switch (DetectExpressionPattern (block)) { case ExpressionPattern.SimpleOr: ProcessOr (block); break; case ExpressionPattern.SimpleNotAnd: ProcessNotAnd (block); break; case ExpressionPattern.NestedNotAnd: ProcessNestedNotAnd (block); break; default: throw new ArgumentException ("Unknown expression pattern starting at " + Formatter.FormatInstruction (block.FirstInstruction), "block"); } MarkProcessed (block.Successors); } enum ExpressionPattern { Unknown, SimpleOr, SimpleNotAnd, NestedNotAnd } static ExpressionPattern DetectExpressionPattern (InstructionBlock block) { InstructionBlock then = GetThen (block); if (IsTrue (then)) return ExpressionPattern.SimpleOr; if (IsFalse (then)) return ExpressionPattern.SimpleNotAnd; // the following flow graph patterns are described in // Decompilation of .NET Bytecode, Computer Science Tripos Part II // Trinity Hall, May 13, 2004 // Fig. 3.10 on pg. 43 // pattern 4: !x && y if (GetElse (GetElse (block)) == then) return ExpressionPattern.NestedNotAnd; return ExpressionPattern.Unknown; } void ProcessNestedNotAnd (InstructionBlock block) { BuildNegateExpression (block); InstructionBlock y = GetElse (block); BuildExpression (y); _expressionDecompiler.PushBinaryExpression (BinaryOperator.LogicalAnd); ProcessNestedExpression (y); } void ProcessOr (InstructionBlock block) { BuildExpression (block); ProcessNestedExpression (GetElse (block)); _expressionDecompiler.PushBinaryExpression (BinaryOperator.LogicalOr); } void ProcessNotAnd (InstructionBlock block) { BuildNegateExpression (block); ProcessNestedExpression (GetElse (block)); _expressionDecompiler.PushBinaryExpression (BinaryOperator.LogicalAnd); } void BuildNegateExpression (InstructionBlock block) { BuildExpression (block); _expressionDecompiler.Negate (); } void ProcessNestedExpression (InstructionBlock block) { switch (block.Successors.Length) { case 1: BuildExpression (block); break; case 2: ProcessLogicalExpressionBlock (block); break; default: throw new ArgumentException ("block"); } } void BuildExpression (InstructionBlock block) { if (WasProcessed (block)) return; foreach (Instruction instruction in block) { _expressionDecompiler.Visit (instruction); } MarkProcessed (block); } static bool IsTrue (InstructionBlock block) { return block.FirstInstruction == block.LastInstruction && block.FirstInstruction.OpCode.Value == OpCodes.Ldc_I4_1.Value; } static bool IsFalse (InstructionBlock block) { return block.FirstInstruction == block.LastInstruction && block.FirstInstruction.OpCode.Value == OpCodes.Ldc_I4_0.Value; } void AssertStackIsEmpty () { if (0 == _expressionDecompiler.Count) return; throw new InvalidOperationException ("stack should be empty after a statement"); } void CreateActionBlock (Instruction instruction) { Visit (instruction); AssertStackIsEmpty (); } public override void OnBrfalse (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBrtrue (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBle (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBlt (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBeq (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBne_Un (Instruction instruction) { AddConditionalBranch (instruction); } public override void OnBge (Instruction instruction) { AddConditionalBranch (instruction); } void AddConditionalBranch (Instruction instruction) { Add (new ConditionalBranchActionBlock (instruction, Pop ())); } public override void OnNop (Instruction instruction) { } public override void OnRet (Instruction instruction) { Expression expression = null; if (1 == GetStackBefore (instruction)) expression = Pop (); Add (new ReturnActionBlock (instruction, expression)); } public override void OnCall (Instruction instruction) { Add (new InvokeActionBlock (instruction, (MethodInvocationExpression) Pop ())); } public override void OnCallvirt (Instruction instruction) { OnCall (instruction); } public override void OnPop (Instruction instruction) { Visit (instruction.Previous); } public override void OnBr (Instruction instruction) { Add (new BranchActionBlock (instruction)); } public override void OnStloc_0 (Instruction instruction) { Add (new AssignActionBlock (instruction, (AssignExpression) Pop ())); } public override void OnStfld (Instruction instruction) { Add (new AssignActionBlock (instruction, (AssignExpression) Pop ())); } public override void OnStsfld (Instruction instruction) { OnStfld (instruction); } int GetStackBefore (Instruction instruction) { return GetInstructionData (instruction).StackBefore; } int GetStackAfter (Instruction instruction) { return GetInstructionData (instruction).StackAfter; } InstructionData GetInstructionData (Instruction instruction) { return _cfg.GetData (instruction); } void Add (ActionBlock block) { if (null == block) throw new ArgumentNullException ("block"); _blocks.Add (block); _instruction2block.Add (_current, block); } ActionBlock GetActionBlock (Instruction block) { return _instruction2block [block]; } Expression Pop () { return _expressionDecompiler.Pop (); } void MarkProcessed (InstructionBlock [] blocks) { foreach (InstructionBlock block in blocks) { MarkProcessed (block); } } void MarkProcessed (InstructionBlock block) { _processed.Add (block); } bool WasProcessed (InstructionBlock block) { return _processed.Contains (block); } static InstructionBlock GetThen (InstructionBlock block) { return block.Successors [0]; } static InstructionBlock GetElse (InstructionBlock block) { return block.Successors [1]; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/ActionFlow/ExpressionDecompiler.cs0000755000175000017500000003743511620326252031566 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.Collections; using System.Collections.Generic; using Cecil.FlowAnalysis.Utilities; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; namespace Cecil.FlowAnalysis.ActionFlow { internal class Stack : IEnumerable { readonly Collection collection = new Collection (); public int Count { get { return collection.Count; } } public T Peek () { if (collection.Count == 0) throw new InvalidOperationException (); return collection [collection.Count - 1]; } public void Push (T value) { collection.Add (value); } public T Pop () { if (collection.Count == 0) throw new InvalidOperationException (); var top = collection.Count - 1; var value = collection [top]; collection.RemoveAt (top); return value; } public IEnumerator GetEnumerator () { return collection.GetEnumerator (); } IEnumerator IEnumerable.GetEnumerator () { return GetEnumerator (); } } internal class ExpressionDecompiler : AbstractInstructionVisitor { Stack _expressionStack; MethodDefinition _method; public int Count { get { return _expressionStack.Count; } } public ExpressionDecompiler (MethodDefinition method) { _method = method; _expressionStack = new Stack (); } public override void OnNop (Instruction instruction) { } public override void OnRet (Instruction instruction) { } public override void OnBr (Instruction instruction) { } public override void OnStloc_0 (Instruction instruction) { PushVariableAssignement (0); } public override void OnStloc_1 (Instruction instruction) { PushVariableAssignement (1); } public override void OnStloc_2 (Instruction instruction) { PushVariableAssignement (2); } public override void OnStloc_3 (Instruction instruction) { PushVariableAssignement (3); } public override void OnStloc (Instruction instruction) { PushVariableAssignement ((VariableReference) instruction.Operand); } private void PushVariableAssignement (VariableReference variable) { PushVariableAssignement (variable.Index); } private void PushVariableAssignement (int index) { PushVariableReference (index); PushAssignment (Pop (), Pop ()); } public override void OnStsfld (Instruction instruction) { FieldReference field = (FieldReference) instruction.Operand; PushAssignment (new FieldReferenceExpression (null, field), Pop()); } public override void OnStfld (Instruction instruction) { FieldReference field = (FieldReference) instruction.Operand; Expression expression = Pop (); Expression target = Pop (); PushAssignment(new FieldReferenceExpression (target, field), expression); } private void PushAssignment (Expression lvalue, Expression rvalue) { Push ( new AssignExpression ( lvalue, rvalue)); } public override void OnCallvirt (Instruction instruction) { OnCall (instruction); } public override void OnBox (Instruction instruction) { Push( new CastExpression ( Pop (), (TypeReference) instruction.Operand)); } public override void OnCastclass (Instruction instruction) { Push ( new CastExpression ( Pop (), (TypeReference) instruction.Operand)); } public override void OnIsinst (Instruction instruction) { Push ( new TryCastExpression ( Pop (), (TypeReference) instruction.Operand)); } public override void OnCall (Instruction instruction) { MethodReference method = (MethodReference) instruction.Operand; Collection args = PopRange (method.Parameters.Count); Expression target = method.HasThis ? Pop () : null; Push ( new MethodInvocationExpression ( new MethodReferenceExpression (target, method), args)); } public override void OnDup (Instruction instruction) { Expression expression = Pop (); Push (expression); Push (expression); } public override void OnPop (Instruction instruction) { } public override void OnAdd (Instruction instruction) { PushBinaryExpression (BinaryOperator.Add); } public override void OnSub (Instruction instruction) { PushBinaryExpression (BinaryOperator.Subtract); } public override void OnMul (Instruction instruction) { PushBinaryExpression (BinaryOperator.Multiply); } public override void OnDiv (Instruction instruction) { PushBinaryExpression (BinaryOperator.Divide); } public void PushBinaryExpression (BinaryOperator op) { Expression rhs = Pop (); Expression lhs = Pop (); Push (new BinaryExpression (op, lhs, rhs)); } public override void OnLdstr (Instruction instruction) { PushLiteral (instruction.Operand); } public override void OnLdc_R4 (Instruction instruction) { PushLiteral (instruction.Operand); } public override void OnLdc_R8 (Instruction instruction) { PushLiteral (instruction.Operand); } public override void OnLdc_I8 (Instruction instruction) { PushLiteral (instruction.Operand); } public override void OnLdc_I4 (Instruction instruction) { PushLiteral (instruction.Operand); } public override void OnLdc_I4_M1 (Instruction instruction) { PushLiteral (-1); } public override void OnLdc_I4_0 (Instruction instruction) { PushLiteral (0); } public override void OnLdc_I4_1 (Instruction instruction) { PushLiteral (1); } public override void OnLdc_I4_2 (Instruction instruction) { PushLiteral (2); } public override void OnLdc_I4_3 (Instruction instruction) { PushLiteral (3); } public override void OnLdc_I4_4 (Instruction instruction) { PushLiteral (4); } public override void OnLdc_I4_5 (Instruction instruction) { PushLiteral (5); } public override void OnLdc_I4_6 (Instruction instruction) { PushLiteral (6); } public override void OnLdc_I4_7 (Instruction instruction) { PushLiteral (7); } public override void OnLdc_I4_8 (Instruction instruction) { PushLiteral (8); } public override void OnLdloc_0 (Instruction instruction) { PushVariableReference (0); } public override void OnLdloc_1 (Instruction instruction) { PushVariableReference (1); } public override void OnLdloc_2 (Instruction instruction) { PushVariableReference (2); } public override void OnLdloc_3 (Instruction instruction) { PushVariableReference (3); } public override void OnLdloc (Instruction instruction) { PushVariableReference ((VariableReference) instruction.Operand); } public override void OnCeq (Instruction instruction) { // XXX: ceq might be used for reference equality as well Expression rhs = Pop (); Expression lhs = Pop (); // simplify common expression patterns // ((x < y) == 0) => x >= y // ((x > y) == 0) => x <= y // ((x == y) == 0) => x != y // (BooleanMethod(x) == 0) => !BooleanMethod(x) if (IsBooleanExpression (lhs) && IsFalse (rhs)) { Negate (lhs); } else { Push (new BinaryExpression (BinaryOperator.ValueEquality, lhs, rhs)); } } static bool IsFalse (Expression expression) { LiteralExpression literal = expression as LiteralExpression; return literal != null && literal.Value.Equals (0); } bool IsBooleanExpression (Expression expression) { switch (expression.CodeElementType) { case CodeElementType.BinaryExpression: return IsComparisonOperator (((BinaryExpression) expression).Operator); case CodeElementType.MethodInvocationExpression: MethodReferenceExpression mre = ((MethodInvocationExpression) expression).Target as MethodReferenceExpression; if (null != mre) return mre.Method.ReturnType.MetadataType == MetadataType.Boolean; break; } return false; } static bool IsComparisonOperator (BinaryOperator op) { switch (op) { case BinaryOperator.GreaterThan: case BinaryOperator.LessThan: case BinaryOperator.GreaterThanOrEqual: case BinaryOperator.LessThanOrEqual: case BinaryOperator.ValueEquality: case BinaryOperator.ValueInequality: return true; } return false; } public override void OnClt (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThan); } public override void OnClt_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThan); } public override void OnCgt (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThan); } public override void OnCgt_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThan); } public override void OnBeq (Instruction instruction) { PushBinaryExpression (BinaryOperator.ValueEquality); } public override void OnBne_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.ValueInequality); } public override void OnBle (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThanOrEqual); } public override void OnBle_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThanOrEqual); } public override void OnBgt (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThan); } public override void OnBgt_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThan); } public override void OnBge (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThanOrEqual); } public override void OnBge_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.GreaterThanOrEqual); } public override void OnBlt (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThan); } public override void OnBlt_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.LessThan); } public override void OnShr (Instruction instruction) { PushBinaryExpression (BinaryOperator.RightShift); } public override void OnShr_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.RightShift); } public override void OnShl (Instruction instruction) { PushBinaryExpression (BinaryOperator.LeftShift); } public override void OnOr (Instruction instruction) { PushBinaryExpression (BinaryOperator.BitwiseOr); } public override void OnAnd (Instruction instruction) { PushBinaryExpression (BinaryOperator.BitwiseAnd); } public override void OnXor (Instruction instruction) { PushBinaryExpression (BinaryOperator.BitwiseXor); } public override void OnRem (Instruction instruction) { PushBinaryExpression (BinaryOperator.Modulo); } public override void OnRem_Un (Instruction instruction) { PushBinaryExpression (BinaryOperator.Modulo); } public override void OnNot (Instruction instruction) { PushUnaryExpression (UnaryOperator.BitwiseComplement, Pop ()); } public override void OnBrtrue (Instruction instruction) { } public override void OnBrfalse (Instruction instruction) { Negate (); } private void PushVariableReference (int index) { PushVariableReference (_method.Body.Variables [index]); } private void PushVariableReference (VariableReference variable) { Push (new VariableReferenceExpression (variable)); } public override void OnLdfld (Instruction instruction) { Push (new FieldReferenceExpression (Pop (), (FieldReference) instruction.Operand)); } public override void OnLdsfld (Instruction instruction) { Push (new FieldReferenceExpression (null, (FieldReference) instruction.Operand)); } public override void OnLdnull (Instruction instruction) { PushLiteral (null); } public override void OnLdarg_0 (Instruction instruction) { PushArgumentReference (0); } public override void OnLdarg_1 (Instruction instruction) { PushArgumentReference (1); } public override void OnLdarg_2 (Instruction instruction) { PushArgumentReference (2); } public override void OnLdarg_3 (Instruction instruction) { PushArgumentReference (3); } public override void OnLdarg (Instruction instruction) { PushArgumentReference (((VariableDefinition)instruction.Operand).Index); } public void Negate () { Negate (Pop ()); } public void Negate (Expression expression) { switch (expression.CodeElementType) { case CodeElementType.BinaryExpression: BinaryExpression be = (BinaryExpression) expression; BinaryOperator op = GetInverseOperator (be.Operator); if (BinaryOperator.None != op) { Push (new BinaryExpression (op, be.Left, be.Right)); } else { if (BinaryOperator.LogicalAnd == be.Operator) { Negate (be.Left); Negate (be.Right); PushBinaryExpression (BinaryOperator.LogicalOr); } else { PushNotExpression (expression); } } break; case CodeElementType.UnaryExpression: UnaryExpression ue = (UnaryExpression) expression; switch (ue.Operator) { case UnaryOperator.Not: Push (ue.Operand); break; default: throw new ArgumentException ("expression"); } break; default: PushNotExpression (expression); break; } } void PushNotExpression (Expression expression) { PushUnaryExpression (UnaryOperator.Not, expression); } void PushUnaryExpression (UnaryOperator op, Expression expression) { Push (new UnaryExpression (op, expression)); } static BinaryOperator GetInverseOperator (BinaryOperator op) { switch (op) { case BinaryOperator.ValueEquality: return BinaryOperator.ValueInequality; case BinaryOperator.ValueInequality: return BinaryOperator.ValueEquality; case BinaryOperator.LessThan: return BinaryOperator.GreaterThanOrEqual; case BinaryOperator.LessThanOrEqual: return BinaryOperator.GreaterThan; case BinaryOperator.GreaterThan: return BinaryOperator.LessThanOrEqual; case BinaryOperator.GreaterThanOrEqual: return BinaryOperator.LessThan; } return BinaryOperator.None; } void PushArgumentReference (int index) { if (_method.HasThis) { if (index == 0) { Push (new ThisReferenceExpression ()); return; } index -= 1; // the Parameters collection dos not contain the implict this argument } Push (new ArgumentReferenceExpression (_method.Parameters [index])); } void PushLiteral (object value) { Push (new LiteralExpression (value)); } void Push (Expression expression) { if (null == expression) throw new ArgumentNullException ("expression"); _expressionStack.Push (expression); } public Expression Pop () { return (Expression) _expressionStack.Pop (); } Collection PopRange (int count) { Collection range = new Collection (); for (int i=0; i < count; ++i) { range.Insert (0, Pop ()); } return range; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/FlowGraphFactory.cs0000644000175000017500000000407411620326252026565 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.ControlFlow; using Mono.Cecil; namespace Cecil.FlowAnalysis { /// /// Creates the specific graphs. /// public class FlowGraphFactory { public static ControlFlowGraph CreateControlFlowGraph (MethodDefinition method) { if (null == method) throw new ArgumentNullException ("method"); ControlFlowGraphBuilder builder = new ControlFlowGraphBuilder (method); return builder.BuildGraph (); } public static ActionFlowGraph CreateActionFlowGraph (ControlFlowGraph cfg) { if (null == cfg) throw new ArgumentNullException ("cfg"); ActionFlowGraphBuilder builder = new ActionFlowGraphBuilder (cfg); return builder.BuildGraph (); } public static ActionFlowGraph CreateActionFlowGraph (MethodDefinition method) { return CreateActionFlowGraph (CreateControlFlowGraph (method)); } private FlowGraphFactory () { } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/CompactFrameworkCompatibility.cs0000644000175000017500000000261511620326252031341 0ustar laneylaney// // FrameworkCompatibility.cs // // Author: // Rodrigo B. de Oliveira (rodrigobamboo@gmail.com) // // (C) 2005 Jb Evain // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #if CF_1_0 namespace System { class NotImplementedException : System.Exception { public NotImplementedException (string message) : base (message) { } public NotImplementedException () { } } } #endif cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis/Cecil.FlowAnalysis.csproj0000644000175000017500000001751711620326252027676 0ustar laneylaney 8.0.50727 {ED1BE103-1699-4116-A732-616BEB142EB2} Local 2.0 Debug AnyCPU Cecil.FlowAnalysis false Library Cecil.FlowAnalysis OnBuildSuccess bin\Debug\ false true DEBUG;TRACE 4096 false false false false false 4 full prompt AllRules.ruleset bin\Release\ false false TRACE 4096 false true false false false 4 none prompt AllRules.ruleset true full false bin\silverlight_Debug\ DEBUG;TRACE;NET_3_5;NET_4_0;SILVERLIGHT prompt 4 Silverlight v4.0 pdbonly true bin\silverlight_Release\ TRACE;NET_3_5;NET_4_0;SILVERLIGHT prompt 4 Silverlight v4.0 Code Code Code Code Code Code Code Code Code Code False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true {D68133BD-1E63-496E-9EDE-4FBDBF77B486} Mono.Cecil cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/AUTHORS0000644000175000017500000000023711620326252020431 0ustar laneylaneyRodrigo B. de Oliveira (rodrigobamboo@gmail.com) Klaus Wuestefeld (klauswuestefeld@gmail.com) Patrick Roemer (patrick.roemer@db4o.com) Jb Evain (jb@nurv.fr) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.sln0000644000175000017500000002002611620326252023526 0ustar laneylaneyMicrosoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cecil.FlowAnalysis.Tests", "Cecil.FlowAnalysis.Tests\Cecil.FlowAnalysis.Tests.csproj", "{A2D41337-2817-453A-B299-E4DF957CEE7B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cecil.FlowAnalysis", "Cecil.FlowAnalysis\Cecil.FlowAnalysis.csproj", "{ED1BE103-1699-4116-A732-616BEB142EB2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "..\..\cecil\Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU net_2_0_Debug|Any CPU = net_2_0_Debug|Any CPU net_2_0_Release|Any CPU = net_2_0_Release|Any CPU net_3_5_Debug|Any CPU = net_3_5_Debug|Any CPU net_3_5_Release|Any CPU = net_3_5_Release|Any CPU net_4_0_Debug|Any CPU = net_4_0_Debug|Any CPU net_4_0_Release|Any CPU = net_4_0_Release|Any CPU Release|Any CPU = Release|Any CPU silverlight_Debug|Any CPU = silverlight_Debug|Any CPU silverlight_Release|Any CPU = silverlight_Release|Any CPU winphone_Debug|Any CPU = winphone_Debug|Any CPU winphone_Release|Any CPU = winphone_Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A2D41337-2817-453A-B299-E4DF957CEE7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_2_0_Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_2_0_Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_2_0_Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_2_0_Release|Any CPU.Build.0 = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_3_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_3_5_Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_3_5_Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_3_5_Release|Any CPU.Build.0 = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_4_0_Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_4_0_Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_4_0_Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.net_4_0_Release|Any CPU.Build.0 = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.Release|Any CPU.Build.0 = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.silverlight_Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.silverlight_Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.silverlight_Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.silverlight_Release|Any CPU.Build.0 = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.winphone_Debug|Any CPU.ActiveCfg = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.winphone_Debug|Any CPU.Build.0 = Debug|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.winphone_Release|Any CPU.ActiveCfg = Release|Any CPU {A2D41337-2817-453A-B299-E4DF957CEE7B}.winphone_Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_2_0_Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_2_0_Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_2_0_Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_2_0_Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_3_5_Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_3_5_Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_3_5_Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_3_5_Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_4_0_Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_4_0_Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_4_0_Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.net_4_0_Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.silverlight_Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.silverlight_Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.silverlight_Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.silverlight_Release|Any CPU.Build.0 = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.winphone_Debug|Any CPU.ActiveCfg = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.winphone_Debug|Any CPU.Build.0 = Debug|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.winphone_Release|Any CPU.ActiveCfg = Release|Any CPU {ED1BE103-1699-4116-A732-616BEB142EB2}.winphone_Release|Any CPU.Build.0 = Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Debug|Any CPU.ActiveCfg = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Debug|Any CPU.Build.0 = net_2_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Release|Any CPU.ActiveCfg = net_2_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_2_0_Release|Any CPU.Build.0 = net_2_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.ActiveCfg = net_3_5_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Debug|Any CPU.Build.0 = net_3_5_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release|Any CPU.ActiveCfg = net_3_5_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_3_5_Release|Any CPU.Build.0 = net_3_5_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug|Any CPU.ActiveCfg = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Debug|Any CPU.Build.0 = net_4_0_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release|Any CPU.ActiveCfg = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.net_4_0_Release|Any CPU.Build.0 = net_4_0_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.ActiveCfg = winphone_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.Release|Any CPU.Build.0 = winphone_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Debug|Any CPU.ActiveCfg = silverlight_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Debug|Any CPU.Build.0 = silverlight_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Release|Any CPU.ActiveCfg = silverlight_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.silverlight_Release|Any CPU.Build.0 = silverlight_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Debug|Any CPU.ActiveCfg = winphone_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Debug|Any CPU.Build.0 = winphone_Debug|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Release|Any CPU.ActiveCfg = winphone_Release|Any CPU {D68133BD-1E63-496E-9EDE-4FBDBF77B486}.winphone_Release|Any CPU.Build.0 = winphone_Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/0000755000175000017500000000000011620326252020763 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/CodeStructureModel.boo0000644000175000017500000000264311620326252025245 0ustar laneylaneyabstract class Expression(ICodeElement): pass abstract class Statement(ICodeElement): pass [collection(Expression)] class ExpressionCollection: pass [collection(Statement)] class StatementCollection: pass class MethodInvocationExpression(Expression): Target as Expression Arguments as ExpressionCollection class MethodReferenceExpression(Expression): Target as Expression Method as MethodReference class LiteralExpression(Expression): Value as object class UnaryExpression(Expression): Operator as UnaryOperator Operand as Expression class BinaryExpression(Expression): Operator as BinaryOperator Left as Expression Right as Expression class AssignExpression(Expression): Target as Expression Expression as Expression class ArgumentReferenceExpression(Expression): Parameter as ParameterReference class VariableReferenceExpression(Expression): Variable as VariableReference class ThisReferenceExpression(Expression): pass class FieldReferenceExpression(Expression): Target as Expression Field as FieldReference class PropertyReferenceExpression(Expression): Target as Expression Property as PropertyReference class BlockStatement(Statement): Statements as StatementCollection class ReturnStatement(Statement): Expression as Expression class CastExpression(Expression): Target as Expression ToType as TypeReference class TryCastExpression(Expression): Target as Expression ToType as TypeReference cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/gen-ControlFlowGraphRegression.boo0000644000175000017500000000357111620326252027534 0ustar laneylaney""" Generates regression tests for FlowGraphFactory.CreateControlFlowGraph by parsing FlowGraphExamples and outputting all of its methods and their corresponding flow graphs. """ import System.IO import Mono.Cecil import Cecil.FlowAnalysis import Cecil.FlowAnalysis.Utilities import Cecil.FlowAnalysis.Tests def WriteMethod(writer as TextWriter, method as MethodDefinition): returnType = Formatter.FormatTypeReference(method.ReturnType.ReturnType) args = "${Formatter.FormatTypeReference(p.ParameterType)} ${p.Name}" for p as ParameterReference in method.Parameters writer.WriteLine(""".assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static ${returnType} Main(${join(args, ', ')}) cil managed {""") for i in method.Body.Instructions: writer.WriteLine("\t\t${Formatter.FormatInstruction(i)}") writer.WriteLine(""" } }""") def WriteCFG(writer as TextWriter, method as MethodDefinition): cfg = FlowGraphFactory.CreateControlFlowGraph(method) AbstractControlFlowTestFixture.FormatControlFlowGraph(writer, cfg) def WriteTestFixture(testcases): for test in testcases: print """ [Test] public void ${test}() { RunTestCase("${test}"); }""" if len(argv) != 2: print "gen-ControlFlowGraphRegression " return assemblyPath, typeName = argv assembly = AssemblyFactory.GetAssembly(assemblyPath) examples = assembly.MainModule.Types[typeName] generated = [] for method as MethodDefinition in examples.Methods: fname = "testcases/FlowAnalysis/${method.Name}.il" if File.Exists(fname): print fname, "already exists, skipping..." continue generated.Add(method.Name) using writer=StreamWriter(fname): WriteMethod(writer, method) fname = "testcases/FlowAnalysis/${method.Name}-cfg.txt" using writer=StreamWriter(fname): WriteCFG(writer, method) WriteTestFixture(generated) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/gen-Utilities.boo0000644000175000017500000000502411620326252024207 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion import System import System.IO import Useful.BooTemplate from Boo.Lang.Useful class InstructionInfo: [getter(OpCodes)] _opcodes as (string) def constructor(line as string): _opcodes = array(formatOpCode(opcode) for opcode in /\s+/.Split(line.Trim())) class CodeTemplate(AbstractTemplate): [property(Instructions)] _instructions as (InstructionInfo) def formatOpCode(opcode as string): parts = /\./.Split(opcode) return join(capitalize(part) for part in parts, '_') def capitalize(s as string): return s[:1].ToUpper() + s[1:] def parse(fname as string): for line in File.OpenText(fname): yield InstructionInfo(line) def applyTemplate(instructions as (InstructionInfo), fname as string): compiler = TemplateCompiler(TemplateBaseClass: CodeTemplate) result = compiler.CompileFile(Path.Combine("codegen/templates/Utilities", fname)) assert 0 == len(result.Errors), result.Errors.ToString() templateType = result.GeneratedAssembly.GetType("Template") template as CodeTemplate = templateType() template.Instructions = instructions print fname using writer=StreamWriter(Path.Combine("Cecil.FlowAnalysis/Utilities", fname)): template.Output = writer template.Execute() instructions = array(parse("codegen/instructions.txt")) applyTemplate(instructions, "InstructionDispatcher.cs") applyTemplate(instructions, "IInstructionVisitor.cs") applyTemplate(instructions, "AbstractInstructionVisitor.cs") cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/0000755000175000017500000000000011620326252022761 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/Utilities/0000755000175000017500000000000011620326252024734 5ustar laneylaney././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/Utilities/AbstractInstructionVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/Utilities/AbstractInstructionVisitor0000644000175000017500000000316411620326252032250 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public class AbstractInstructionVisitor : IInstructionVisitor {<% for instr in Instructions: %> public virtual void On${instr.OpCodes[0]} (Instruction instruction) { throw new NotImplementedException (Formatter.FormatInstruction (instruction)); } <% end %> public void Visit (Instruction instruction) { InstructionDispatcher.Dispatch (instruction, this); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/Utilities/IInstructionVisitor.cs0000644000175000017500000000256711620326252031307 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public interface IInstructionVisitor { <% for instr in Instructions: %> void On${instr.OpCodes[0]} (Instruction instruction); <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/Utilities/InstructionDispatcher.cs0000644000175000017500000000461511620326252031621 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using System.Collections; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.Utilities { public class InstructionDispatcher { public static void Dispatch (Instruction instruction, IInstructionVisitor visitor) { InstructionVisitorDelegate handler = (InstructionVisitorDelegate)_handlers[instruction.OpCode.Value]; if (null == handler) throw new ArgumentException (Formatter.FormatInstruction (instruction), "instruction"); handler (visitor, instruction); } delegate void InstructionVisitorDelegate (IInstructionVisitor visitor, Instruction instruction); static IDictionary _handlers = new Hashtable (); static InstructionDispatcher () { <% for instr in Instructions: opcodes = join("OpCodes.${code}" for code in instr.OpCodes, ", ") %> Bind (new InstructionVisitorDelegate (Dispatch${instr.OpCodes[0]}), ${opcodes}); <% end %> } static void Bind (InstructionVisitorDelegate handler, params OpCode[] opcodes) { foreach (OpCode op in opcodes) { _handlers.Add (op.Value, handler); } } <% for instr in Instructions: %> static void Dispatch${instr.OpCodes[0]} (IInstructionVisitor visitor, Instruction instruction) { visitor.On${instr.OpCodes[0]} (instruction); } <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/0000755000175000017500000000000011620326252025554 5ustar laneylaney././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/ICodeStructureVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/ICodeStructureVisitor.0000644000175000017500000000253411620326252032045 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit namespace Cecil.FlowAnalysis.CodeStructure { public interface ICodeStructureVisitor { <% for node in model.GetVisitableNodes(): %> void Visit (${node.Name} node); <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/ClassInterface.cs0000644000175000017500000000272411620326252030776 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using System.Collections; using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public interface I${node.Name} : ${join(node.BaseTypes, ', ')} { <% for field in model.GetFields(node): %> ${GetFieldTypeName(field)} ${field.Name} { get; } <% end %> } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/AbstractCodeStructureVisitor.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/AbstractCodeStructureV0000644000175000017500000000337311620326252032112 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System.Collections; namespace Cecil.FlowAnalysis.CodeStructure { public class AbstractCodeStructureVisitor : ICodeStructureVisitor { public virtual void Visit (ICodeElement node) { if (null == node) return; node.Accept (this); } public virtual void Visit (ICollection collection) { foreach (ICodeElement node in collection) { Visit (node); } } <% for node in model.GetVisitableNodes(): %> public virtual void Visit (${node.Name} node) { <% for field in model.GetVisitableFields(node): %> Visit (node.${field.Name}); <% end %> } <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/CollectionInterface.cs0000644000175000017500000000263211620326252032022 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using System.Collections; using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public interface I${node.Name} : ICollection { ${model.GetCollectionItemType(node)} this[int index] { get; } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/CodeElementType.cs0000644000175000017500000000263711620326252031141 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit namespace Cecil.FlowAnalysis.CodeStructure { public enum CodeElementType { <% nodes = array(model.GetVisitableNodes()) last = nodes[-1] separator = "," for item in nodes: separator = "" if item is last %> ${item.Name}${separator} <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/Interface.cs0000644000175000017500000000270611620326252030010 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit using System; using System.Collections; using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public interface ${node.Name} : ${join(node.BaseTypes, ', ')} {<% for field in model.GetFields(node): %> ${field.Type} ${field.Name} { get; }<% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/Class.cs0000644000175000017500000000433511620326252027155 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit <% fields = model.GetFields(node) %>using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public <% if node.IsAbstract: %>abstract <% end %>class ${node.Name} : ${join(node.BaseTypes, ', ')} { <% for field in fields: %> ${GetFieldTypeName(field)} ${ToFieldName(field.Name)}; <%end %> <% args = join("${GetFieldTypeName(field)} ${ToParamName(field.Name)}" for field in fields, ", ") %> public ${node.Name} (${args}) { <% for field in fields: %> ${ToFieldName(field.Name)} = ${ToParamName(field.Name)}; <% end %> } <% for field in fields: %> public ${GetFieldTypeName(field)} ${field.Name} { get { return ${ToFieldName(field.Name)}; } } <% end %> <% if node.IsAbstract: %> public abstract CodeElementType CodeElementType { get; } public abstract void Accept (ICodeStructureVisitor visitor); <% else: %> public override CodeElementType CodeElementType { get { return CodeElementType.${node.Name}; } } public override void Accept (ICodeStructureVisitor visitor) { visitor.Visit (this); } <% end %> } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/templates/CodeStructure/CollectionClass.cs0000644000175000017500000000346711620326252031176 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion // Warning: generated do not edit <% itemType = model.GetCollectionItemType(node) %>using System; using System.Collections; using Mono.Cecil; using Mono.Cecil.Cil; namespace Cecil.FlowAnalysis.CodeStructure { public class ${node.Name} : CollectionBase, ICollection { public ${itemType} this [int index] { get { return (${itemType}) InnerList [index]; } } public void Add (${itemType} element) { if (element == null) throw new ArgumentNullException ("element"); InnerList.Add (element); } public void Insert (int index, ${itemType} element) { if (element == null) throw new ArgumentNullException ("element"); InnerList.Insert (index, element); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/gen-CodeStructure.boo0000644000175000017500000001204111620326252025024 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion import System import System.IO import Boo.Lang.Compiler import Boo.Lang.Compiler.Ast import Boo.Lang.Compiler.IO import Useful.BooTemplate from Boo.Lang.Useful class Model: [getter(Module)] _module as Module def constructor(module as Module): _module = module def GetFields(node as TypeDefinition): return array(Field, GetMembers(node, NodeType.Field)) def GetVisitableFields(node as TypeDefinition): for field in GetFields(node): type = ResolveType(field.Type) continue if type is null continue if IsEnum(type) yield field def GetVisitableNodes(): for node in _module.Members: continue if node.NodeType != NodeType.ClassDefinition continue if node.IsAbstract continue if IsCollection(node) yield node def GetClasses(): return array(ClassDefinition, GetMembers(_module, NodeType.ClassDefinition)) def GetMembers(container as TypeDefinition, type as NodeType): for member in container.Members: yield member if member.NodeType == type def GetCollectionItemType(node as TypeDefinition): assert IsCollection(node) attribute = node.Attributes.Get("collection")[0] reference as ReferenceExpression = attribute.Arguments[0] return reference.Name def IsCollection(node as TypeDefinition): return node.Attributes.Contains("collection") def IsEnum(node as TypeDefinition): return NodeType.EnumDefinition == node.NodeType def ResolveType(typeRef as TypeReference): return _module.Members[typeRef.ToString()] class CodeTemplate(AbstractTemplate): static Keywords = { "operator" : true } [property(model)] _model as Model [property(node)] _node as TypeDefinition def ToCamelCase(s as string): return s[:1].ToLower() + s[1:] def ToParamName(s as string): cc = ToCamelCase(s) cc += "_" if cc in Keywords return cc def ToFieldName(s as string): return "_${ToCamelCase(s)}" def GetFieldTypeName(field as Field): type = model.ResolveType(field.Type) return "${field.Type}" if type is not null return field.Type.ToString() def parse(fname as string): parser = BooCompiler() parser.Parameters.Pipeline = Pipelines.Parse() parser.Parameters.Input.Add(FileInput(fname)) result = parser.Run() assert 0 == len(result.Errors), result.Errors.ToString() return result.CompileUnit.Modules[0] def loadTemplate(model, fname as string): compiler = TemplateCompiler(TemplateBaseClass: CodeTemplate) result = compiler.CompileFile(Path.Combine("codegen/templates/CodeStructure", fname)) assert 0 == len(result.Errors), result.Errors.ToString() templateType = result.GeneratedAssembly.GetType("Template") template as CodeTemplate = templateType() template.model = model return template def applyTemplate(node as TypeDefinition, template as CodeTemplate, targetFile as string): using writer=StreamWriter(Path.Combine("Cecil.FlowAnalysis", targetFile)): template.node = node template.Output = writer template.Execute() print targetFile def applyModelTemplate(model as Model, templateName as string): applyTemplate(null, loadTemplate(model, templateName), "CodeStructure/${templateName}") module = parse("codegen/CodeStructureModel.boo") model = Model(module) interfaceTemplate = loadTemplate(model, "Interface.cs") classTemplate = loadTemplate(model, "Class.cs") classInterfaceTemplate = loadTemplate(model, "ClassInterface.cs") collectionInterfaceTemplate = loadTemplate(model, "CollectionInterface.cs") collectionClassTemplate = loadTemplate(model, "CollectionClass.cs") for node in module.Members: if node isa InterfaceDefinition: applyTemplate(node, interfaceTemplate, "CodeStructure/${node.Name}.cs") elif node isa ClassDefinition: if model.IsCollection(node): applyTemplate(node, collectionClassTemplate, "CodeStructure/${node.Name}.cs") else: applyTemplate(node, classTemplate, "CodeStructure/${node.Name}.cs") applyModelTemplate(model, "ICodeStructureVisitor.cs") applyModelTemplate(model, "AbstractCodeStructureVisitor.cs") applyModelTemplate(model, "CodeElementType.cs") cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/codegen/instructions.txt0000644000175000017500000000334011620326252024270 0ustar laneylaneynop break ldarg.0 ldarg.1 ldarg.2 ldarg.3 ldloc.0 ldloc.1 ldloc.2 ldloc.3 stloc.0 stloc.1 stloc.2 stloc.3 ldarg ldarg.s ldarga ldarga.s starg starg.s ldloc ldloc.s ldloca ldloca.s stloc stloc.s ldnull ldc.i4.m1 ldc.i4.0 ldc.i4.1 ldc.i4.2 ldc.i4.3 ldc.i4.4 ldc.i4.5 ldc.i4.6 ldc.i4.7 ldc.i4.8 ldc.i4 ldc.i4.s ldc.i8 ldc.r4 ldc.r8 dup pop jmp call calli ret br br.s brfalse brfalse.s brtrue brtrue.s beq beq.s bge bge.s bgt bgt.s ble ble.s blt blt.s bne.un bne.un.s bge.un bge.un.s bgt.un bgt.un.s ble.un ble.un.s blt.un blt.un.s switch ldind.i1 ldind.u1 ldind.i2 ldind.u2 ldind.i4 ldind.u4 ldind.i8 ldind.i ldind.r4 ldind.r8 ldind.ref stind.ref stind.i1 stind.i2 stind.i4 stind.i8 stind.r4 stind.r8 add sub mul div div.un rem rem.un and or xor shl shr shr.un neg not conv.i1 conv.i2 conv.i4 conv.i8 conv.r4 conv.r8 conv.u4 conv.u8 callvirt cpobj ldobj ldstr newobj castclass isinst conv.r.un unbox throw ldfld ldflda stfld ldsfld ldsflda stsfld stobj conv.ovf.i1.un conv.ovf.i2.un conv.ovf.i4.un conv.ovf.i8.un conv.ovf.u1.un conv.ovf.u2.un conv.ovf.u4.un conv.ovf.u8.un conv.ovf.i.un conv.ovf.u.un box newarr ldlen ldelema ldelem.i1 ldelem.u1 ldelem.i2 ldelem.u2 ldelem.i4 ldelem.u4 ldelem.i8 ldelem.i ldelem.r4 ldelem.r8 ldelem.ref stelem.i stelem.i1 stelem.i2 stelem.i4 stelem.i8 stelem.r4 stelem.r8 stelem.ref ldelem.any stelem.any unbox.any conv.ovf.i1 conv.ovf.u1 conv.ovf.i2 conv.ovf.u2 conv.ovf.i4 conv.ovf.u4 conv.ovf.i8 conv.ovf.u8 refanyval ckfinite mkrefany ldtoken conv.u2 conv.u1 conv.i conv.ovf.i conv.ovf.u add.ovf add.ovf.un mul.ovf mul.ovf.un sub.ovf sub.ovf.un endfinally leave leave.s stind.i conv.u arglist ceq cgt cgt.un clt clt.un ldftn ldvirtftn localloc endfilter unaligned volatile tail initobj cpblk initblk rethrow sizeof refanytype cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/README0000644000175000017500000000215611620326252020243 0ustar laneylaney* Building Simply type 'nant' or make. * License (C) db4objects Inc. http://www.db4o.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/0000755000175000017500000000000011620326252024111 5ustar laneylaney././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/AbstractControlFlowTestFixture.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/AbstractControlFlowTestFixtur0000644000175000017500000000546611620326252032045 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System.Collections; using System.IO; using Cecil.FlowAnalysis.Utilities; using Cecil.FlowAnalysis.ControlFlow; using Mono.Cecil; using Mono.Cecil.Cil; using NUnit.Framework; namespace Cecil.FlowAnalysis.Tests { public class AbstractControlFlowTestFixture : AbstractFlowAnalysisTestFixture { protected void RunTestCase (string name) { MethodDefinition method = LoadTestCaseMethod (name); ControlFlowGraph cfg = FlowGraphFactory.CreateControlFlowGraph (method); Assert.AreEqual (Normalize (LoadExpectedControlFlowString (name)), Normalize (ToString (cfg))); } public static string ToString (ControlFlowGraph cfg) { StringWriter writer = new StringWriter (); FormatControlFlowGraph (writer, cfg); return writer.ToString (); } public static void FormatControlFlowGraph (TextWriter writer, ControlFlowGraph cfg) { int id = 1; foreach (InstructionBlock block in cfg.Blocks) { writer.WriteLine ("block {0}:", id); writer.WriteLine ("\tbody:"); foreach (Instruction instruction in block) { writer.Write ("\t\t"); Formatter.WriteInstruction (writer, instruction); writer.WriteLine (); } InstructionBlock [] successors = block.Successors; if (successors.Length > 0) { writer.WriteLine ("\tsuccessors:"); foreach (InstructionBlock successor in successors) { writer.WriteLine ("\t\tblock {0}", GetBlockId (cfg, successor)); } } ++id; } } private static int GetBlockId (ControlFlowGraph cfg, InstructionBlock block) { return ((IList) cfg.Blocks).IndexOf (block) + 1; } private string LoadExpectedControlFlowString (string name) { return LoadTestCaseFile (name + "-cfg.txt"); } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/AbstractFlowAnalysisTestFixture.cscecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/AbstractFlowAnalysisTestFixtu0000644000175000017500000000702411620326252032016 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.Diagnostics; using System.IO; using System.Linq; using Mono.Cecil; using NUnit.Framework; namespace Cecil.FlowAnalysis.Tests { public class AbstractFlowAnalysisTestFixture { protected static string Normalize (string s) { return s.Trim ().Replace ("\r\n", "\n"); } private void CompileTestCase (string name) { string sourceFile = MapTestCasePath (name + ".il"); Assert.IsTrue (File.Exists (sourceFile), sourceFile + " not found!"); ilasm (string.Format ("/DLL \"/OUTPUT:{0}\" {1}", TestAssemblyPath, sourceFile)); } protected string LoadTestCaseFile (string fname) { using (StreamReader reader=File.OpenText (MapTestCasePath (fname))) { return reader.ReadToEnd (); } } protected string MapTestCasePath (string name) { return Path.Combine (TestCasesDirectory, name); } static void ilasm (string arguments) { Process p = new Process (); p.StartInfo.Arguments = arguments; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.FileName = "ilasm"; p.Start (); string output = p.StandardOutput.ReadToEnd (); string error = p.StandardError.ReadToEnd (); p.WaitForExit (); Assert.AreEqual (0, p.ExitCode, output + error); } protected MethodDefinition LoadTestCaseMethod (string testCaseName) { CompileTestCase (testCaseName); AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly (TestAssemblyPath); TypeDefinition type = assembly.MainModule.GetType ("TestCase"); Assert.IsNotNull (type, "Type TestCase not found!"); MethodDefinition found = type.Methods.First (m => m.Name == "Main"); return found; } public string TestCasesDirectory { get { return Path.GetFullPath (Path.Combine (FindTestcasesDirectory (), "FlowAnalysis")); } } static string FindTestcasesDirectory() { string currentPath = Environment.CurrentDirectory; while (!Directory.Exists(Path.Combine(currentPath, "testcases"))) { string oldPath = currentPath; currentPath = Path.GetDirectoryName(currentPath); Assert.AreNotEqual(oldPath, currentPath); } return Path.Combine(currentPath, "testcases"); } public string TestAssemblyPath { get { return Path.Combine (Path.GetTempPath (), "TestCase.dll"); } } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/AssemblyInfo.cs0000644000175000017500000000667011620326252027044 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System.Reflection; using System.Runtime.CompilerServices; // // 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("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // 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 Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/ActionFlowTestFixture.cs0000644000175000017500000001651111620326252030720 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using System; using System.IO; using Cecil.FlowAnalysis.ActionFlow; using Cecil.FlowAnalysis.CodeStructure; using Mono.Cecil; using NUnit.Framework; namespace Cecil.FlowAnalysis.Tests { [TestFixture] public class ActionFlowTestFixture : AbstractFlowAnalysisTestFixture { [Test] public void Box () { RunTestCase ("Box"); } [Test] public void StaticField () { RunTestCase ("StaticField"); } [Test] public void StringCast () { RunTestCase ("StringCast"); } [Test] public void StringTryCast () { RunTestCase ("StringTryCast"); } [Test] public void IntPropertyEquals1 () { RunTestCase ("IntPropertyEquals1"); } [Test] public void IntPropertyEquals2 () { RunTestCase ("IntPropertyEquals2"); } [Test] public void FloatGreaterThan () { RunTestCase ("FloatGreaterThan"); } [Test] public void FloatEquals () { RunTestCase ("FloatEquals"); } [Test] public void BoolOrLessOrEqualThan () { RunTestCase ("BoolOrLessOrEqualThan"); } [Test] [Ignore("TODO")] public void OptimizedNestedOr () { RunTestCase ("OptimizedNestedOr"); } [Test] public void NestedOrGreaterThan () { RunTestCase ("NestedOrGreaterThan"); } [Test] public void InRange () { RunTestCase ("InRange"); } [Test] public void OptimizedAnd () { RunTestCase ("OptimizedAnd"); } [Test] public void BoolAndGreaterOrEqualThan () { RunTestCase ("BoolAndGreaterOrEqualThan"); } [Test] public void OptimizedOr () { RunTestCase ("OptimizedOr"); } [Test] public void NotStringEquality () { RunTestCase ("NotStringEquality"); } [Test] public void IsNull () { RunTestCase ("IsNull"); } [Test] public void FieldAccessor () { RunTestCase ("FieldAccessor"); } [Test] public void NotEqual () { RunTestCase ("NotEqual"); } [Test] public void GreaterThanOrEqual () { RunTestCase ("GreaterThanOrEqual"); } [Test] public void LessThanOrEqual () { RunTestCase ("LessThanOrEqual"); } [Test] public void Empty () { RunTestCase ("Empty"); } [Test] public void SimpleReturn () { RunTestCase ("SimpleReturn"); } [Test] public void SimpleCalculation () { RunTestCase ("SimpleCalculation"); } [Test] public void SimpleCondition () { RunTestCase ("SimpleCondition"); } [Test] public void SimpleIf () { RunTestCase ("SimpleIf"); } [Test] public void ConditionalBranchActionBlock () { ActionFlowGraph afg = GetActionFlowGraph ("SimpleIf"); ConditionalBranchActionBlock cbr = (ConditionalBranchActionBlock) afg.Blocks [0]; Assert.AreSame (afg.Blocks [2], cbr.Then, "Then"); Assert.AreSame (afg.Blocks [1], cbr.Else, "Else"); } [Test] public void SingleAnd () { RunTestCase ("SingleAnd"); } [Test] public void SingleOr () { RunTestCase ("SingleOr"); } [Test] public void MultipleOr () { RunTestCase ("MultipleOr"); } [Test] public void FalseIf () { RunTestCase ("FalseIf"); } [Test] public void PropertyPredicate () { RunTestCase ("PropertyPredicate"); } [Test] public void MixedAndOr () { RunTestCase ("MixedAndOr"); } [Test] public void MultipleAndOr () { RunTestCase ("MultipleAndOr"); } [Test] public void StringPredicate () { RunTestCase ("StringPredicate"); } [Test] public void InPlaceAdd () { RunTestCase ("InPlaceAdd"); } [Test] public void MathOperators () { RunTestCase ("MathOperators"); } protected void RunTestCase (string name) { ActionFlowGraph afg = GetActionFlowGraph (name); Assert.AreEqual (Normalize (LoadTestCaseFile (name + "-afg.txt")), Normalize (ToString (afg))); } ActionFlowGraph GetActionFlowGraph (string name) { MethodDefinition method = LoadTestCaseMethod (name); return FlowGraphFactory.CreateActionFlowGraph (FlowGraphFactory.CreateControlFlowGraph (method)); } class ActionFlowGraphPrinter { private ExpressionPrinter _expressionPrinter; private TextWriter _writer; public ActionFlowGraphPrinter (TextWriter writer) { _writer = writer; _expressionPrinter = new ExpressionPrinter (writer); } public void Print (ActionFlowGraph afg) { int i = 1; foreach (ActionBlock block in afg.Blocks) { if (afg.IsBranchTarget (block)) { WriteLabel (i); } switch (block.ActionType) { case ActionType.Return: WriteReturn ((ReturnActionBlock) block); break; case ActionType.Branch: WriteBranch (afg, (BranchActionBlock) block); break; case ActionType.ConditionalBranch: WriteConditionalBranch (afg, (ConditionalBranchActionBlock) block); break; case ActionType.Assign: WriteAssign ((AssignActionBlock) block); break; case ActionType.Invoke: WriteInvoke ((InvokeActionBlock) block); break; default: throw new InvalidOperationException (); } _writer.WriteLine (); ++i; } } void WriteLabel (int index) { _writer.Write ("block{0}: ", index); } void WriteConditionalBranch (ActionFlowGraph afg, ConditionalBranchActionBlock block) { _writer.Write ("if "); WriteExpression (block.Condition); _writer.Write (' '); WriteGoto (afg, block.Then); } void WriteBranch (ActionFlowGraph afg, BranchActionBlock block) { WriteGoto (afg, block.Target); } void WriteGoto (ActionFlowGraph afg, ActionBlock target) { _writer.Write ("goto block{0}", afg.Blocks.IndexOf (target) + 1); } void WriteAssign (AssignActionBlock block) { WriteExpression (block.AssignExpression); } void WriteReturn (ReturnActionBlock block) { _writer.Write ("return"); if (null != block.Expression) { _writer.Write (" "); WriteExpression (block.Expression); } } void WriteInvoke (InvokeActionBlock block) { WriteExpression (block.Expression); } void WriteExpression (Expression expression) { _expressionPrinter.Visit (expression); } } public static string ToString (ActionFlowGraph afg) { StringWriter writer = new StringWriter (); new ActionFlowGraphPrinter (writer).Print (afg); return writer.ToString (); } } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/ControlFlowTestFixture.cs0000644000175000017500000001121311620326252031115 0ustar laneylaney#region license // // (C) db4objects Inc. http://www.db4o.com // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // #endregion using NUnit.Framework; namespace Cecil.FlowAnalysis.Tests { [TestFixture] public class ControlFlowTestFixture : AbstractControlFlowTestFixture { [Test] public void Box () { RunTestCase ("Box"); } [Test] public void Switch () { RunTestCase ("Switch"); } [Test] public void StaticField () { RunTestCase ("StaticField"); } [Test] public void StringCast () { RunTestCase ("StringCast"); } [Test] public void StringTryCast () { RunTestCase ("StringTryCast"); } [Test] public void FloatGreaterThan () { RunTestCase ("FloatGreaterThan"); } [Test] public void FloatEquals () { RunTestCase ("FloatEquals"); } [Test] public void BoolOrLessOrEqualThan () { RunTestCase ("BoolOrLessOrEqualThan"); } [Test] public void OptimizedNestedOr () { RunTestCase ("OptimizedNestedOr"); } [Test] public void NestedOrGreaterThan () { RunTestCase ("NestedOrGreaterThan"); } [Test] public void InRange () { RunTestCase ("InRange"); } [Test] public void OptimizedAnd () { RunTestCase ("OptimizedAnd"); } [Test] public void BoolAndGreaterOrEqualThan () { RunTestCase ("BoolAndGreaterOrEqualThan"); } [Test] public void OptimizedOr () { RunTestCase ("OptimizedOr"); } [Test] public void NotStringEquality () { RunTestCase ("NotStringEquality"); } [Test] public void IsNull () { RunTestCase ("IsNull"); } [Test] public void FieldAccessor () { RunTestCase ("FieldAccessor"); } [Test] public void NotEqual () { RunTestCase ("NotEqual"); } [Test] public void GreaterThanOrEqual () { RunTestCase ("GreaterThanOrEqual"); } [Test] public void LessThanOrEqual () { RunTestCase ("LessThanOrEqual"); } [Test] public void Empty () { RunTestCase ("Empty"); } [Test] public void SimpleReturn () { RunTestCase ("SimpleReturn"); } [Test] public void SimpleCalculation () { RunTestCase ("SimpleCalculation"); } [Test] public void SimpleCondition () { RunTestCase ("SimpleCondition"); } [Test] public void SingleAnd () { RunTestCase ("SingleAnd"); } [Test] public void SingleOr () { RunTestCase ("SingleOr"); } [Test] public void MultipleOr () { RunTestCase ("MultipleOr"); } [Test] public void MixedAndOr () { RunTestCase ("MixedAndOr"); } [Test] public void SimpleIf () { RunTestCase ("SimpleIf"); } [Test] public void TwoIfs () { RunTestCase ("TwoIfs"); } [Test] public void FalseIf () { RunTestCase ("FalseIf"); } [Test] public void IfNestedCondition () { RunTestCase ("IfNestedCondition"); } [Test] public void ThreeReturns () { RunTestCase ("ThreeReturns"); } [Test] public void TernaryExpression () { RunTestCase ("TernaryExpression"); } [Test] public void SideEffectExpression () { RunTestCase ("SideEffectExpression"); } [Test] public void SimpleWhile () { RunTestCase ("SimpleWhile"); } [Test] public void FlowTest () { RunTestCase ("FlowTest"); } [Test] public void PropertyPredicate () { RunTestCase ("PropertyPredicate"); } [Test] public void MultipleAndOr () { RunTestCase ("MultipleAndOr"); } [Test] public void StringPredicate () { RunTestCase ("StringPredicate"); } [Test] public void InPlaceAdd () { RunTestCase ("InPlaceAdd"); } [Test] public void MathOperators () { RunTestCase ("MathOperators"); } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/Cecil.FlowAnalysis.Tests.csprojcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Cecil.FlowAnalysis.Tests/Cecil.FlowAnalysis.Tests.cspr0000644000175000017500000001426411620326252031543 0ustar laneylaney Local 8.0.50727 2.0 {A2D41337-2817-453A-B299-E4DF957CEE7B} Debug AnyCPU Cecil.FlowAnalysis.Tests JScript Grid IE50 false Library Cecil.FlowAnalysis.Tests OnBuildSuccess v3.5 2.0 publish\ true Disk false Foreground 7 Days false false true 0 1.0.0.%2a false false true bin\Debug\ false 285212672 false DEBUG;TRACE true 4096 false false false false false 4 full prompt AllRules.ruleset bin\Release\ false 285212672 false TRACE false 4096 false true false false false 4 none prompt AllRules.ruleset False ..\..\..\cecil\Test\libs\nunit-2.4.8\nunit.framework.dll {D68133BD-1E63-496E-9EDE-4FBDBF77B486} Mono.Cecil Cecil.FlowAnalysis {ED1BE103-1699-4116-A732-616BEB142EB2} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Code Code Code Code Code False .NET Framework 3.5 SP1 Client Profile false False .NET Framework 3.5 SP1 true False Windows Installer 3.1 true cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/default.build0000644000175000017500000001067111620326252022031 0ustar laneylaney cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/0000755000175000017500000000000011620326252021355 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/0000755000175000017500000000000011620326252023770 5ustar laneylaneycecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleOr-cfg.txt0000644000175000017500000000121611620326252027362 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: beq.s IL_0014 successors: block 5 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.5 IL_0006: beq.s IL_0014 successors: block 5 block 3 block 3: body: IL_0008: ldarg.0 IL_0009: ldc.i4.s 42 IL_000b: beq.s IL_0014 successors: block 5 block 4 block 4: body: IL_000d: ldarg.0 IL_000e: ldc.i4.s 100 IL_0010: cgt IL_0012: br.s IL_0015 successors: block 6 block 5: body: IL_0014: ldc.i4.1 successors: block 6 block 6: body: IL_0015: stloc.0 IL_0016: br.s IL_0018 successors: block 7 block 7: body: IL_0018: ldloc.0 IL_0019: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InPlaceAdd.il0000644000175000017500000000053411620326252026244 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .field int32 v .method public hidebysig void Main(int32 n) cil managed { IL_0000: ldarg.0 IL_0001: dup IL_0002: ldfld int32 TestCase::v IL_0007: ldarg.1 IL_0008: add IL_0009: stfld int32 TestCase::v IL_000e: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FalseIf-afg.txt0000644000175000017500000000016511620326252026577 0ustar laneylaneyif (x <= 0) goto block3 System.Console.WriteLine("x > 0") block3: local0 = (x < 0) goto block5 block5: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/GreaterThanOrEqual.il0000644000175000017500000000057711620326252030024 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: clt IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringCast.il0000644000175000017500000000076511620326252026407 0ustar laneylaney.assembly extern mscorlib {} .assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(string[] s) cil managed { IL_0000: nop IL_0001: ldarg.0 IL_0002: castclass [mscorlib]System.Collections.IEnumerable IL_0007: callvirt instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator() IL_000c: pop IL_000d: br.s IL_000f IL_000f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatGreaterThan.il0000644000175000017500000000054311620326252027512 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(float32 'value') cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.r4 2.9 IL_0006: cgt IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCalculation-cfg.txt0000644000175000017500000000026111620326252030675 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.2 IL_0002: mul IL_0003: stloc.0 IL_0004: ldloc.0 IL_0005: call void System.Console::WriteLine(int32) IL_000a: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FalseIf-cfg.txt0000644000175000017500000000064211620326252026601 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: ble.s IL_000e successors: block 3 block 2 block 2: body: IL_0004: ldstr "x > 0" IL_0009: call void System.Console::WriteLine(string) successors: block 3 block 3: body: IL_000e: ldarg.0 IL_000f: ldc.i4.0 IL_0010: clt IL_0012: stloc.0 IL_0013: br.s IL_0015 successors: block 4 block 4: body: IL_0015: ldloc.0 IL_0016: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StaticField-cfg.txt0000755000175000017500000000043011620326252027461 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldc.i4.s 42 IL_0003: stsfld System.Int32 TestCase::_field IL_0008: ldsfld System.Int32 TestCase::_field IL_000d: stloc.0 IL_000e: br.s IL_0010 successors: block 2 block 2: body: IL_0010: ldloc.0 IL_0011: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCondition-cfg.txt0000644000175000017500000000027511620326252030372 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: ceq IL_0005: stloc.0 IL_0006: br.s IL_0008 successors: block 2 block 2: body: IL_0008: ldloc.0 IL_0009: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/PropertyPredicate-afg.txt0000644000175000017500000000012711620326252030731 0ustar laneylaneylocal0 = string.op_Equality(cat.get_Name(), "Occam") goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Empty-cfg.txt0000644000175000017500000000005611620326252026365 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/LessThanOrEqual.il0000644000175000017500000000057711620326252027341 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: cgt IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InRange.il0000644000175000017500000000061211620326252025640 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 'value') cil managed { IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: blt.s IL_000c IL_0004: ldarg.0 IL_0005: ldc.i4.8 IL_0006: cgt IL_0008: ldc.i4.0 IL_0009: ceq IL_000b: ret IL_000c: ldc.i4.0 IL_000d: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/ThreeReturns-cfg.txt0000644000175000017500000000110411620326252027714 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_0008 successors: block 3 block 2 block 2: body: IL_0004: ldc.i4.1 IL_0005: stloc.0 IL_0006: br.s IL_0014 successors: block 6 block 3: body: IL_0008: ldarg.0 IL_0009: ldarg.1 IL_000a: bge.s IL_0010 successors: block 5 block 4 block 4: body: IL_000c: ldc.i4.1 IL_000d: stloc.0 IL_000e: br.s IL_0014 successors: block 6 block 5: body: IL_0010: ldc.i4.0 IL_0011: stloc.0 IL_0012: br.s IL_0014 successors: block 6 block 6: body: IL_0014: ldloc.0 IL_0015: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SideEffectExpression-cfg.txt0000644000175000017500000000036711620326252031355 0ustar laneylaneyblock 1: body: IL_0000: ldc.i4.0 IL_0001: stloc.0 IL_0002: ldc.i4.3 IL_0003: ldloc.0 IL_0004: ldc.i4.1 IL_0005: add IL_0006: dup IL_0007: stloc.0 IL_0008: add IL_0009: ldc.i4.2 IL_000a: add IL_000b: stloc.1 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedOr.il0000644000175000017500000000071611620326252026567 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(string s) cil managed { IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: brtrue.s IL_0019 IL_000d: ldarg.0 IL_000e: ldstr "bar" IL_0013: call bool string::op_Equality(string, string) IL_0018: ret IL_0019: ldc.i4.1 IL_001a: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IntPropertyEquals2.il0000644000175000017500000000237411620326252030060 0ustar laneylaney.assembly extern mscorlib {} .assembly TestCase {} .class public auto ansi beforefieldinit Pilot extends [mscorlib]System.Object { .field private int32 _points .method public hidebysig specialname rtspecialname instance void .ctor(int32 points) cil managed { // Code size 14 (0xe) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ldarg.0 IL_0007: ldarg.1 IL_0008: stfld int32 Pilot::_points IL_000d: ret } .method public hidebysig specialname instance int32 get_Points() cil managed { // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 Pilot::_points IL_0006: ret } .property instance int32 Points() { .get instance int32 Pilot::get_Points() } } .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(class Pilot pilot) cil managed { .maxstack 2 .locals init (bool V_0) IL_0000: ldarg.0 IL_0001: callvirt instance int32 Pilot::get_Points() IL_0006: ldc.i4.s 100 IL_0008: ceq IL_000a: stloc.0 IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringCast-afg.txt0000644000175000017500000000011711620326252027344 0ustar laneylaney((System.Collections.IEnumerable)s).GetEnumerator() goto block3 block3: return ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolAndGreaterOrEqualThan-cfg.txtcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolAndGreaterOrEqualThan-cfg.t0000644000175000017500000000106011620326252031643 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldstr "A" IL_0006: callvirt bool string::StartsWith(string) IL_000b: brfalse.s IL_001b successors: block 3 block 2 block 2: body: IL_000d: ldarg.0 IL_000e: callvirt int32 string::get_Length() IL_0013: ldc.i4.3 IL_0014: clt IL_0016: ldc.i4.0 IL_0017: ceq IL_0019: br.s IL_001c successors: block 4 block 3: body: IL_001b: ldc.i4.0 successors: block 4 block 4: body: IL_001c: stloc.0 IL_001d: br.s IL_001f successors: block 5 block 5: body: IL_001f: ldloc.0 IL_0020: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InRange-afg.txt0000644000175000017500000000004611620326252026607 0ustar laneylaneyreturn ((value >= 5) && (value <= 8)) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FlowTest.il0000644000175000017500000000150011620326252026061 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main() cil managed { IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: br.s IL_002b IL_0004: ldloc.0 IL_0005: ldc.i4.2 IL_0006: rem IL_0007: brtrue.s IL_0027 IL_0009: ldstr "Even number" IL_000e: call void [mscorlib]System.Console::WriteLine(string) IL_0013: ldc.i4.0 IL_0014: stloc.1 IL_0015: ldstr "!" IL_001a: call void [mscorlib]System.Console::WriteLine(string) IL_001f: ldloc.1 IL_0020: ldc.i4.1 IL_0021: add IL_0022: stloc.1 IL_0023: ldloc.1 IL_0024: ldloc.0 IL_0025: blt.s IL_0015 IL_0027: ldloc.0 IL_0028: ldc.i4.1 IL_0029: add IL_002a: stloc.0 IL_002b: ldloc.0 IL_002c: ldc.i4.5 IL_002d: blt.s IL_0004 IL_002f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleAnd-cfg.txt0000644000175000017500000000065011620326252027133 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_000b successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: clt IL_0009: br.s IL_000c successors: block 4 block 3: body: IL_000b: ldc.i4.0 successors: block 4 block 4: body: IL_000c: stloc.0 IL_000d: br.s IL_000f successors: block 5 block 5: body: IL_000f: ldloc.0 IL_0010: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedNestedOr-cfg.txt0000644000175000017500000000056011620326252030677 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: bge.s IL_0008 successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.2 IL_0006: bne.un.s IL_000e successors: block 4 block 3 block 3: body: IL_0008: ldarg.0 IL_0009: ldc.i4.s 10 IL_000b: clt IL_000d: ret block 4: body: IL_000e: ldc.i4.0 IL_000f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleOr-cfg.txt0000644000175000017500000000064511620326252027015 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: beq.s IL_000a successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.5 IL_0006: ceq IL_0008: br.s IL_000b successors: block 4 block 3: body: IL_000a: ldc.i4.1 successors: block 4 block 4: body: IL_000b: stloc.0 IL_000c: br.s IL_000e successors: block 5 block 5: body: IL_000e: ldloc.0 IL_000f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/LessThanOrEqual-afg.txt0000644000175000017500000000006511620326252030277 0ustar laneylaneylocal0 = (x <= 42) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InPlaceAdd-cfg.txt0000644000175000017500000000026711620326252027217 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: dup IL_0002: ldfld System.Int32 TestCase::v IL_0007: ldarg.1 IL_0008: add IL_0009: stfld System.Int32 TestCase::v IL_000e: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCondition.il0000644000175000017500000000053411620326252027420 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: ceq IL_0005: stloc.0 IL_0006: br.s IL_0008 IL_0008: ldloc.0 IL_0009: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NestedOrGreaterThan.il0000644000175000017500000000102311620326252030162 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 'value') cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: bge.s IL_0009 IL_0004: ldarg.0 IL_0005: ldc.i4.s 2 IL_0007: bne.un.s IL_0010 IL_0009: ldarg.0 IL_000a: ldc.i4.s 10 IL_000c: clt IL_000e: br.s IL_0011 IL_0010: ldc.i4.0 IL_0011: stloc.0 IL_0012: br.s IL_0014 IL_0014: ldloc.0 IL_0015: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleWhile-cfg.txt0000644000175000017500000000076111620326252027514 0ustar laneylaneyblock 1: body: IL_0000: newobj void System.Random::.ctor() IL_0005: stloc.0 IL_0006: br.s IL_0012 successors: block 3 block 2: body: IL_0008: ldstr "funny..." IL_000d: call void System.Console::WriteLine(string) successors: block 3 block 3: body: IL_0012: ldloc.0 IL_0013: ldc.i4.0 IL_0014: ldc.i4.s 10 IL_0016: callvirt int32 System.Random::Next(int32, int32) IL_001b: ldc.i4.5 IL_001c: blt.s IL_0008 successors: block 2 block 4 block 4: body: IL_001e: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleIf.il0000644000175000017500000000055211620326252026030 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(int32 x, int32 y) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_000e IL_0004: ldstr "x > y" IL_0009: call void [mscorlib]System.Console::WriteLine(string) IL_000e: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringTryCast-cfg.txt0000644000175000017500000000044311620326252030047 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldarg.0 IL_0002: isinst System.Collections.IEnumerable IL_0007: callvirt System.Collections.IEnumerator System.Collections.IEnumerable::GetEnumerator() IL_000c: pop IL_000d: br.s IL_000f successors: block 2 block 2: body: IL_000f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MixedAndOr-cfg.txt0000644000175000017500000000103511620326252027257 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_0009 successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: blt.s IL_0010 successors: block 4 block 3 block 3: body: IL_0009: ldarg.0 IL_000a: ldc.i4.s 100 IL_000c: cgt IL_000e: br.s IL_0011 successors: block 5 block 4: body: IL_0010: ldc.i4.1 successors: block 5 block 5: body: IL_0011: stloc.0 IL_0012: br.s IL_0014 successors: block 6 block 6: body: IL_0014: ldloc.0 IL_0015: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotStringEquality-cfg.txt0000644000175000017500000000041211620326252030730 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: ldc.i4.0 IL_000c: ceq IL_000e: stloc.0 IL_000f: br.s IL_0011 successors: block 2 block 2: body: IL_0011: ldloc.0 IL_0012: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringCast-cfg.txt0000644000175000017500000000044611620326252027353 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldarg.0 IL_0002: castclass System.Collections.IEnumerable IL_0007: callvirt System.Collections.IEnumerator System.Collections.IEnumerable::GetEnumerator() IL_000c: pop IL_000d: br.s IL_000f successors: block 2 block 2: body: IL_000f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolOrLessOrEqualThan-afg.txt0000644000175000017500000000010511620326252031407 0ustar laneylaneylocal0 = ((id > 42) || (id <= 10)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FalseIf.il0000644000175000017500000000076311620326252025635 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.0 IL_0002: ble.s IL_000e IL_0004: ldstr "x > 0" IL_0009: call void [mscorlib]System.Console::WriteLine(string) IL_000e: ldarg.0 IL_000f: ldc.i4.0 IL_0010: clt IL_0012: stloc.0 IL_0013: br.s IL_0015 IL_0015: ldloc.0 IL_0016: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FieldAccessor-cfg.txt0000644000175000017500000000030611620326252027773 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldfld System.Int32 TestCase::_field IL_0006: stloc.0 IL_0007: br.s IL_0009 successors: block 2 block 2: body: IL_0009: ldloc.0 IL_000a: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedNestedOr-afg.txt0000644000175000017500000000007011620326252030671 0ustar laneylaneyreturn (((value >= 5) || (value == 2)) && (value < 10)) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatEquals.il0000644000175000017500000000054311620326252026540 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(float32 'value') cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.r4 1.1 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedNestedOr.il0000644000175000017500000000071211620326252027726 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 'value') cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: bge.s IL_0008 IL_0004: ldarg.0 IL_0005: ldc.i4.2 IL_0006: bne.un.s IL_000e IL_0008: ldarg.0 IL_0009: ldc.i4.s 10 IL_000b: clt IL_000d: ret IL_000e: ldc.i4.0 IL_000f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCondition-afg.txt0000644000175000017500000000006511620326252030365 0ustar laneylaneylocal0 = (x == 42) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IntPropertyEquals1.il0000644000175000017500000000232411620326252030052 0ustar laneylaney.assembly extern mscorlib {} .assembly TestCase {} .class public auto ansi beforefieldinit Pilot extends [mscorlib]System.Object { .field private int32 _points .method public hidebysig specialname rtspecialname instance void .ctor(int32 points) cil managed { // Code size 14 (0xe) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ldarg.0 IL_0007: ldarg.1 IL_0008: stfld int32 Pilot::_points IL_000d: ret } .method public hidebysig specialname instance int32 get_Points() cil managed { // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldfld int32 Pilot::_points IL_0006: ret } .property instance int32 Points() { .get instance int32 Pilot::get_Points() } } .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(class Pilot pilot) cil managed { // Code size 11 (0xb) .maxstack 8 IL_0000: ldarg.0 IL_0001: callvirt instance int32 Pilot::get_Points() IL_0006: ldc.i4.s 100 IL_0008: ceq IL_000a: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleAndOr-cfg.txt0000644000175000017500000000141411620326252030005 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_0009 successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: blt.s IL_0018 successors: block 7 block 3 block 3: body: IL_0009: ldarg.0 IL_000a: ldc.i4.s 100 IL_000c: blt.s IL_0015 successors: block 5 block 4 block 4: body: IL_000e: ldarg.0 IL_000f: ldc.i4.s 115 IL_0011: clt IL_0013: br.s IL_0016 successors: block 6 block 5: body: IL_0015: ldc.i4.0 successors: block 6 block 6: body: IL_0016: br.s IL_0019 successors: block 8 block 7: body: IL_0018: ldc.i4.1 successors: block 8 block 8: body: IL_0019: stloc.0 IL_001a: br.s IL_001c successors: block 9 block 9: body: IL_001c: ldloc.0 IL_001d: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatEquals-afg.txt0000644000175000017500000000007211620326252027503 0ustar laneylaneylocal0 = (value == 1.1) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Box-afg.txt0000755000175000017500000000010711620326252026015 0ustar laneylaneylocal0 = ((System.Int32)42) System.Console.WriteLine(local0) return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleIf-cfg.txt0000644000175000017500000000040611620326252026776 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_000e successors: block 3 block 2 block 2: body: IL_0004: ldstr "x > y" IL_0009: call void System.Console::WriteLine(string) successors: block 3 block 3: body: IL_000e: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringTryCast-afg.txt0000644000175000017500000000012111620326252030036 0ustar laneylaney(s as System.Collections.IEnumerable).GetEnumerator() goto block3 block3: return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolOrLessOrEqualThan-cfg.txt0000644000175000017500000000071611620326252031421 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: bgt.s IL_000f successors: block 3 block 2 block 2: body: IL_0005: ldarg.0 IL_0006: ldc.i4.s 10 IL_0008: cgt IL_000a: ldc.i4.0 IL_000b: ceq IL_000d: br.s IL_0010 successors: block 4 block 3: body: IL_000f: ldc.i4.1 successors: block 4 block 4: body: IL_0010: stloc.0 IL_0011: br.s IL_0013 successors: block 5 block 5: body: IL_0013: ldloc.0 IL_0014: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleIf-afg.txt0000644000175000017500000000011111620326252026765 0ustar laneylaneyif (x <= y) goto block3 System.Console.WriteLine("x > y") block3: return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleOr.il0000644000175000017500000000111411620326252026407 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: beq.s IL_0014 IL_0004: ldarg.0 IL_0005: ldc.i4.5 IL_0006: beq.s IL_0014 IL_0008: ldarg.0 IL_0009: ldc.i4.s 42 IL_000b: beq.s IL_0014 IL_000d: ldarg.0 IL_000e: ldc.i4.s 100 IL_0010: cgt IL_0012: br.s IL_0015 IL_0014: ldc.i4.1 IL_0015: stloc.0 IL_0016: br.s IL_0018 IL_0018: ldloc.0 IL_0019: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedAnd-cfg.txt0000644000175000017500000000047311620326252027661 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: brfalse.s IL_0010 successors: block 3 block 2 block 2: body: IL_0003: ldarg.0 IL_0004: callvirt int32 string::get_Length() IL_0009: ldc.i4.3 IL_000a: clt IL_000c: ldc.i4.0 IL_000d: ceq IL_000f: ret block 3: body: IL_0010: ldc.i4.0 IL_0011: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InRange-cfg.txt0000644000175000017500000000043411620326252026612 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: blt.s IL_000c successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.8 IL_0006: cgt IL_0008: ldc.i4.0 IL_0009: ceq IL_000b: ret block 3: body: IL_000c: ldc.i4.0 IL_000d: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedAnd-afg.txt0000644000175000017500000000004411620326252027651 0ustar laneylaneyreturn (s && (s.get_Length() >= 3)) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/InPlaceAdd-afg.txt0000644000175000017500000000003511620326252027206 0ustar laneylaneythis.v = (this.v + n) return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotStringEquality.il0000644000175000017500000000065211620326252027766 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(string s) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: ldc.i4.0 IL_000c: ceq IL_000e: stloc.0 IL_000f: br.s IL_0011 IL_0011: ldloc.0 IL_0012: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/PropertyPredicate.il0000644000175000017500000000343111620326252027764 0ustar laneylaney.assembly extern mscorlib {} .assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig instance bool Main(class Cat cat) cil managed { .locals init (bool V_0) IL_0000: ldarg.1 IL_0001: callvirt instance string Cat::get_Name() IL_0006: ldstr "Occam" IL_000b: call bool [mscorlib]System.String::op_Equality(string, string) IL_0010: stloc.0 IL_0011: br.s IL_0013 IL_0013: ldloc.0 IL_0014: ret } // end of method TestCase::Main .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } // end of method TestCase::.ctor } // end of class TestCase .class public auto ansi beforefieldinit Cat extends [mscorlib]System.Object { .field public string _name .method public hidebysig specialname rtspecialname instance void .ctor(string name) cil managed { IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ldarg.0 IL_0007: ldarg.1 IL_0008: stfld string Cat::_name IL_000d: ret } .method public hidebysig specialname instance string get_Name() cil managed { .locals init (string V_0) IL_0000: ldarg.0 IL_0001: ldfld string Cat::_name IL_0006: stloc.0 IL_0007: br.s IL_0009 IL_0009: ldloc.0 IL_000a: ret } // end of method Cat::get_Name .property instance string Name() { .get instance string Cat::get_Name() } // end of property Cat::Name } // end of class Cat cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringPredicate-cfg.txt0000644000175000017500000000102111620326252030347 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: brtrue.s IL_001a successors: block 3 block 2 block 2: body: IL_000d: ldarg.0 IL_000e: ldstr "bar" IL_0013: call bool string::op_Equality(string, string) IL_0018: br.s IL_001b successors: block 4 block 3: body: IL_001a: ldc.i4.1 successors: block 4 block 4: body: IL_001b: stloc.0 IL_001c: br.s IL_001e successors: block 5 block 5: body: IL_001e: ldloc.0 IL_001f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IfNestedCondition-cfg.txt0000644000175000017500000000112411620326252030634 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.1 IL_0002: beq.s IL_000d successors: block 4 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.3 IL_0006: ble.s IL_0011 successors: block 5 block 3 block 3: body: IL_0008: ldarg.0 IL_0009: ldc.i4.s 42 IL_000b: bge.s IL_0011 successors: block 5 block 4 block 4: body: IL_000d: ldc.i4.1 IL_000e: stloc.0 IL_000f: br.s IL_0015 successors: block 6 block 5: body: IL_0011: ldc.i4.0 IL_0012: stloc.0 IL_0013: br.s IL_0015 successors: block 6 block 6: body: IL_0015: ldloc.0 IL_0016: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FieldAccessor-afg.txt0000644000175000017500000000006711620326252027775 0ustar laneylaneylocal0 = this._field goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MixedAndOr.il0000644000175000017500000000101411620326252026304 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_0009 IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: blt.s IL_0010 IL_0009: ldarg.0 IL_000a: ldc.i4.s 100 IL_000c: cgt IL_000e: br.s IL_0011 IL_0010: ldc.i4.1 IL_0011: stloc.0 IL_0012: br.s IL_0014 IL_0014: ldloc.0 IL_0015: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotEqual.il0000644000175000017500000000057711620326252026057 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: ceq IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedAnd.il0000644000175000017500000000064411620326252026711 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(string s) cil managed { IL_0000: ldarg.0 IL_0001: brfalse.s IL_0010 IL_0003: ldarg.0 IL_0004: callvirt int32 string::get_Length() IL_0009: ldc.i4.3 IL_000a: clt IL_000c: ldc.i4.0 IL_000d: ceq IL_000f: ret IL_0010: ldc.i4.0 IL_0011: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/TwoIfs.il0000644000175000017500000000100311620326252025523 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(int32 x, int32 y) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_000e IL_0004: ldstr "x > y" IL_0009: call void [mscorlib]System.Console::WriteLine(string) IL_000e: ldarg.0 IL_000f: ldarg.1 IL_0010: bge.s IL_001c IL_0012: ldstr "x < y" IL_0017: call void [mscorlib]System.Console::WriteLine(string) IL_001c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotEqual-afg.txt0000644000175000017500000000006511620326252027015 0ustar laneylaneylocal0 = (x != 42) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/TernaryExpression-cfg.txt0000644000175000017500000000056611620326252031001 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 successors: block 3 block 2 block 2: body: IL_0003: ldc.i4.m1 IL_0004: br.s IL_0008 successors: block 4 block 3: body: IL_0006: ldc.i4.s 42 successors: block 4 block 4: body: IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 5 block 5: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/TwoIfs-cfg.txt0000644000175000017500000000075511620326252026510 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_000e successors: block 3 block 2 block 2: body: IL_0004: ldstr "x > y" IL_0009: call void System.Console::WriteLine(string) successors: block 3 block 3: body: IL_000e: ldarg.0 IL_000f: ldarg.1 IL_0010: bge.s IL_001c successors: block 5 block 4 block 4: body: IL_0012: ldstr "x < y" IL_0017: call void System.Console::WriteLine(string) successors: block 5 block 5: body: IL_001c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MathOperators.il0000644000175000017500000000215311620326252027107 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main() cil managed { .entrypoint .locals init (int32 V_0) IL_0000: nop IL_0001: ldc.i4.1 IL_0002: stloc.0 IL_0003: ldloc.0 IL_0004: ldc.i4.2 IL_0005: add IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: ldc.i4.3 IL_0009: sub IL_000a: stloc.0 IL_000b: ldloc.0 IL_000c: ldc.i4.4 IL_000d: mul IL_000e: stloc.0 IL_000f: ldloc.0 IL_0010: ldc.i4.5 IL_0011: div IL_0012: stloc.0 IL_0013: ldloc.0 IL_0014: ldc.i4.6 IL_0015: shr IL_0016: stloc.0 IL_0017: ldloc.0 IL_0018: ldc.i4.7 IL_0019: shl IL_001a: stloc.0 IL_001b: ldloc.0 IL_001c: ldc.i4.8 IL_001d: or IL_001e: stloc.0 IL_001f: ldloc.0 IL_0020: ldc.i4.s 9 IL_0022: and IL_0023: stloc.0 IL_0024: ldloc.0 IL_0025: ldc.i4.s 10 IL_0027: xor IL_0028: stloc.0 IL_0029: ldloc.0 IL_002a: ldc.i4.s 11 IL_002c: rem IL_002d: stloc.0 IL_002e: ldloc.0 IL_002f: not IL_0030: stloc.0 IL_0031: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/ThreeReturns.il0000644000175000017500000000103311620326252026745 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32, int32) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: ble.s IL_0008 IL_0004: ldc.i4.1 IL_0005: stloc.0 IL_0006: br.s IL_0014 IL_0008: ldarg.0 IL_0009: ldarg.1 IL_000a: bge.s IL_0010 IL_000c: ldc.i4.1 IL_000d: stloc.0 IL_000e: br.s IL_0014 IL_0010: ldc.i4.0 IL_0011: stloc.0 IL_0012: br.s IL_0014 IL_0014: ldloc.0 IL_0015: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/PropertyPredicate-cfg.txt0000644000175000017500000000042411620326252030733 0ustar laneylaneyblock 1: body: IL_0000: ldarg.1 IL_0001: callvirt string Cat::get_Name() IL_0006: ldstr "Occam" IL_000b: call bool string::op_Equality(string, string) IL_0010: stloc.0 IL_0011: br.s IL_0013 successors: block 2 block 2: body: IL_0013: ldloc.0 IL_0014: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotStringEquality-afg.txt0000644000175000017500000000011311620326252030724 0ustar laneylaneylocal0 = (!string.op_Equality(s, "foo")) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NestedOrGreaterThan-cfg.txt0000644000175000017500000000103611620326252031136 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.5 IL_0002: bge.s IL_0009 successors: block 3 block 2 block 2: body: IL_0004: ldarg.0 IL_0005: ldc.i4.s 2 IL_0007: bne.un.s IL_0010 successors: block 4 block 3 block 3: body: IL_0009: ldarg.0 IL_000a: ldc.i4.s 10 IL_000c: clt IL_000e: br.s IL_0011 successors: block 5 block 4: body: IL_0010: ldc.i4.0 successors: block 5 block 5: body: IL_0011: stloc.0 IL_0012: br.s IL_0014 successors: block 6 block 6: body: IL_0014: ldloc.0 IL_0015: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MathOperators-afg.txt0000644000175000017500000000040511620326252030053 0ustar laneylaneylocal0 = 1 local0 = (local0 + 2) local0 = (local0 - 3) local0 = (local0 * 4) local0 = (local0 / 5) local0 = (local0 >> 6) local0 = (local0 << 7) local0 = (local0 | 8) local0 = (local0 & 9) local0 = (local0 ^ 10) local0 = (local0 % 11) local0 = (~local0) return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NotEqual-cfg.txt0000644000175000017500000000034011620326252027013 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: ceq IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 2 block 2: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FieldAccessor.il0000644000175000017500000000054711620326252027032 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .field int32 _field .method public hidebysig int32 Main() cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldfld int32 TestCase::_field IL_0006: stloc.0 IL_0007: br.s IL_0009 IL_0009: ldloc.0 IL_000a: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleOr-afg.txt0000644000175000017500000000014011620326252027353 0ustar laneylaneylocal0 = ((x == 3) || ((x == 5) || ((x == 42) || (x > 100)))) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FlowTest-cfg.txt0000644000175000017500000000162211620326252027036 0ustar laneylaneyblock 1: body: IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: br.s IL_002b successors: block 6 block 2: body: IL_0004: ldloc.0 IL_0005: ldc.i4.2 IL_0006: rem IL_0007: brtrue.s IL_0027 successors: block 5 block 3 block 3: body: IL_0009: ldstr "Even number" IL_000e: call void System.Console::WriteLine(string) IL_0013: ldc.i4.0 IL_0014: stloc.1 successors: block 4 block 4: body: IL_0015: ldstr "!" IL_001a: call void System.Console::WriteLine(string) IL_001f: ldloc.1 IL_0020: ldc.i4.1 IL_0021: add IL_0022: stloc.1 IL_0023: ldloc.1 IL_0024: ldloc.0 IL_0025: blt.s IL_0015 successors: block 4 block 5 block 5: body: IL_0027: ldloc.0 IL_0028: ldc.i4.1 IL_0029: add IL_002a: stloc.0 successors: block 6 block 6: body: IL_002b: ldloc.0 IL_002c: ldc.i4.5 IL_002d: blt.s IL_0004 successors: block 2 block 7 block 7: body: IL_002f: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StaticField.il0000755000175000017500000000064711620326252026523 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static int32 Main() cil managed { .locals init (bool local0) IL_0000: nop IL_0001: ldc.i4.s 42 IL_0003: stsfld int32 TestCase::_field IL_0008: ldsfld int32 TestCase::_field IL_000d: stloc.0 IL_000e: br.s IL_0010 IL_0010: ldloc.0 IL_0011: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleAnd.il0000644000175000017500000000070711620326252026166 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init(bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_000b IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: clt IL_0009: br.s IL_000c IL_000b: ldc.i4.0 IL_000c: stloc.0 IL_000d: br.s IL_000f IL_000f: ldloc.0 IL_0010: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleWhile.il0000644000175000017500000000106211620326252026537 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main() cil managed { IL_0000: newobj void [mscorlib]System.Random::.ctor() IL_0005: stloc.0 IL_0006: br.s IL_0012 IL_0008: ldstr "funny..." IL_000d: call void [mscorlib]System.Console::WriteLine(string) IL_0012: ldloc.0 IL_0013: ldc.i4.0 IL_0014: ldc.i4.s 10 IL_0016: callvirt int32 [mscorlib]System.Random::Next(int32, int32) IL_001b: ldc.i4.5 IL_001c: blt.s IL_0008 IL_001e: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatGreaterThan-cfg.txt0000644000175000017500000000027411620326252030463 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.r4 2.9 IL_0006: cgt IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 2 block 2: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SideEffectExpression.il0000644000175000017500000000063111620326252030377 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main() cil managed { IL_0000: ldc.i4.0 IL_0001: stloc.0 IL_0002: ldc.i4.3 IL_0003: ldloc.0 IL_0004: ldc.i4.1 IL_0005: add IL_0006: dup IL_0007: stloc.0 IL_0008: add IL_0009: ldc.i4.2 IL_000a: add IL_000b: stloc.1 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/GreaterThanOrEqual-cfg.txt0000644000175000017500000000034011620326252030760 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: clt IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 2 block 2: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatGreaterThan-afg.txt0000644000175000017500000000007111620326252030454 0ustar laneylaneylocal0 = (value > 2.9) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Empty.il0000644000175000017500000000032011620326252025407 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main() cil managed { IL_0000: nop IL_0001: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IsNull-cfg.txt0000644000175000017500000000035011620326252026472 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldfld System.Object TestCase::_field IL_0006: ldnull IL_0007: ceq IL_0009: stloc.0 IL_000a: br.s IL_000c successors: block 2 block 2: body: IL_000c: ldloc.0 IL_000d: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCalculation-afg.txt0000644000175000017500000000007111620326252030672 0ustar laneylaneylocal0 = (x * 2) System.Console.WriteLine(local0) return cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Box.il0000755000175000017500000000070011620326252025046 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(string[] args) cil managed { .locals init (int32 local0) IL_0000: nop IL_0001: ldc.i4.s 42 IL_0003: box [mscorlib]System.Int32 IL_0008: stloc.0 IL_0009: ldloc.0 IL_000a: call void [mscorlib]System.Console::WriteLine(object) IL_000f: nop IL_0010: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IsNull.il0000644000175000017500000000061211620326252025523 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .field object _field .method public hidebysig bool Main() cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldfld object TestCase::_field IL_0006: ldnull IL_0007: ceq IL_0009: stloc.0 IL_000a: br.s IL_000c IL_000c: ldloc.0 IL_000d: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IfNestedCondition.il0000644000175000017500000000103211620326252027662 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32) cil managed { IL_0000: ldarg.0 IL_0001: ldc.i4.1 IL_0002: beq.s IL_000d IL_0004: ldarg.0 IL_0005: ldc.i4.3 IL_0006: ble.s IL_0011 IL_0008: ldarg.0 IL_0009: ldc.i4.s 42 IL_000b: bge.s IL_0011 IL_000d: ldc.i4.1 IL_000e: stloc.0 IL_000f: br.s IL_0015 IL_0011: ldc.i4.0 IL_0012: stloc.0 IL_0013: br.s IL_0015 IL_0015: ldloc.0 IL_0016: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleOr.il0000644000175000017500000000070511620326252026042 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: beq.s IL_000a IL_0004: ldarg.0 IL_0005: ldc.i4.5 IL_0006: ceq IL_0008: br.s IL_000b IL_000a: ldc.i4.1 IL_000b: stloc.0 IL_000c: br.s IL_000e IL_000e: ldloc.0 IL_000f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedOr-afg.txt0000644000175000017500000000010611620326252027526 0ustar laneylaneyreturn (string.op_Equality(s, "foo") || string.op_Equality(s, "bar")) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolAndGreaterOrEqualThan.il0000644000175000017500000000112111620326252031245 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(string s) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldstr "A" IL_0006: callvirt bool string::StartsWith(string) IL_000b: brfalse.s IL_001b IL_000d: ldarg.0 IL_000e: callvirt int32 string::get_Length() IL_0013: ldc.i4.3 IL_0014: clt IL_0016: ldc.i4.0 IL_0017: ceq IL_0019: br.s IL_001c IL_001b: ldc.i4.0 IL_001c: stloc.0 IL_001d: br.s IL_001f IL_001f: ldloc.0 IL_0020: ret } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolAndGreaterOrEqualThan-afg.txtcecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolAndGreaterOrEqualThan-afg.t0000644000175000017500000000013011620326252031636 0ustar laneylaneylocal0 = (s.StartsWith("A") && (s.get_Length() >= 3)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IntPropertyEquals1-afg.txt0000644000175000017500000000004311620326252031014 0ustar laneylaneyreturn (pilot.get_Points() == 100) cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleReturn-afg.txt0000644000175000017500000000005511620326252027715 0ustar laneylaneylocal0 = 1 goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IntPropertyEquals2-afg.txt0000644000175000017500000000006311620326252031017 0ustar laneylaneylocal0 = (pilot.get_Points() == 100) return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/BoolOrLessOrEqualThan.il0000644000175000017500000000075711620326252030456 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 id) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: bgt.s IL_000f IL_0005: ldarg.0 IL_0006: ldc.i4.s 10 IL_0008: cgt IL_000a: ldc.i4.0 IL_000b: ceq IL_000d: br.s IL_0010 IL_000f: ldc.i4.1 IL_0010: stloc.0 IL_0011: br.s IL_0013 IL_0013: ldloc.0 IL_0014: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/GreaterThanOrEqual-afg.txt0000644000175000017500000000006511620326252030762 0ustar laneylaneylocal0 = (x >= 42) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/NestedOrGreaterThan-afg.txt0000644000175000017500000000013411620326252031132 0ustar laneylaneylocal0 = (((value >= 5) || (value == 2)) && (value < 10)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MixedAndOr-afg.txt0000644000175000017500000000012011620326252027247 0ustar laneylaneylocal0 = (((x > 3) && (x < 42)) || (x > 100)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleAnd-afg.txt0000644000175000017500000000010111620326252027120 0ustar laneylaneylocal0 = ((x > 3) && (x < 42)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleReturn-cfg.txt0000644000175000017500000000023011620326252027712 0ustar laneylaneyblock 1: body: IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: br.s IL_0004 successors: block 2 block 2: body: IL_0004: ldloc.0 IL_0005: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleAndOr.il0000644000175000017500000000117411620326252027040 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(int32 x) cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldc.i4.3 IL_0002: ble.s IL_0009 IL_0004: ldarg.0 IL_0005: ldc.i4.s 42 IL_0007: blt.s IL_0018 IL_0009: ldarg.0 IL_000a: ldc.i4.s 100 IL_000c: blt.s IL_0015 IL_000e: ldarg.0 IL_000f: ldc.i4.s 115 IL_0011: clt IL_0013: br.s IL_0016 IL_0015: ldc.i4.0 IL_0016: br.s IL_0019 IL_0018: ldc.i4.1 IL_0019: stloc.0 IL_001a: br.s IL_001c IL_001c: ldloc.0 IL_001d: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/FloatEquals-cfg.txt0000644000175000017500000000027411620326252027511 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.r4 1.1 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 2 block 2: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleReturn.il0000644000175000017500000000046011620326252026747 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main() cil managed { .locals init (bool local0) IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: br.s IL_0004 IL_0004: ldloc.0 IL_0005: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Box-cfg.txt0000755000175000017500000000033611620326252026023 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldc.i4.s 42 IL_0003: box System.Int32 IL_0008: stloc.0 IL_0009: ldloc.0 IL_000a: call void System.Console::WriteLine(System.Object) IL_000f: nop IL_0010: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/LessThanOrEqual-cfg.txt0000644000175000017500000000034011620326252030275 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldc.i4.s 42 IL_0003: cgt IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.0 IL_0009: br.s IL_000b successors: block 2 block 2: body: IL_000b: ldloc.0 IL_000c: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/OptimizedOr-cfg.txt0000644000175000017500000000054511620326252027537 0ustar laneylaneyblock 1: body: IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: brtrue.s IL_0019 successors: block 3 block 2 block 2: body: IL_000d: ldarg.0 IL_000e: ldstr "bar" IL_0013: call bool string::op_Equality(string, string) IL_0018: ret block 3: body: IL_0019: ldc.i4.1 IL_001a: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/IsNull-afg.txt0000644000175000017500000000010111620326252026462 0ustar laneylaneylocal0 = (this._field == null) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Switch.il0000644000175000017500000000150111620326252025554 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static int32 Main(int32 'value') cil managed { .locals init (int32 local0, int32 local1) IL_0000: nop IL_0001: ldarg.0 IL_0002: stloc.1 IL_0003: ldloc.1 IL_0004: ldc.i4.1 IL_0005: sub IL_0006: switch (IL_001d, IL_0021, IL_0025, IL_0029) IL_001b: br.s IL_002d IL_001d: ldc.i4.1 IL_001e: stloc.0 IL_001f: br.s IL_0031 IL_0021: ldc.i4.2 IL_0022: stloc.0 IL_0023: br.s IL_0031 IL_0025: ldc.i4.3 IL_0026: stloc.0 IL_0027: br.s IL_0031 IL_0029: ldc.i4.4 IL_002a: stloc.0 IL_002b: br.s IL_0031 IL_002d: ldc.i4.m1 IL_002e: stloc.0 IL_002f: br.s IL_0031 IL_0031: ldloc.0 IL_0032: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StaticField-afg.txt0000755000175000017500000000012411620326252027457 0ustar laneylaneyTestCase._field = 42 local0 = TestCase._field goto block4 block4: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/TernaryExpression.il0000644000175000017500000000056711620326252030032 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static int32 Main(bool) cil managed { IL_0000: ldarg.0 IL_0001: brtrue.s IL_0006 IL_0003: ldc.i4.m1 IL_0004: br.s IL_0008 IL_0006: ldc.i4.s 42 IL_0008: stloc.0 IL_0009: br.s IL_000b IL_000b: ldloc.0 IL_000c: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MultipleAndOr-afg.txt0000644000175000017500000000014011620326252027776 0ustar laneylaneylocal0 = (((x > 3) && (x < 42)) || ((x >= 100) && (x < 115))) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringPredicate-afg.txt0000644000175000017500000000016211620326252030352 0ustar laneylaneylocal0 = (string.op_Equality(value, "foo") || string.op_Equality(value, "bar")) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SimpleCalculation.il0000644000175000017500000000060211620326252027724 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(int32 x) cil managed { .locals init (int32 local0) IL_0000: ldarg.0 IL_0001: ldc.i4.2 IL_0002: mul IL_0003: stloc.0 IL_0004: ldloc.0 IL_0005: call void [mscorlib]System.Console::WriteLine(int32) IL_000a: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringTryCast.il0000644000175000017500000000076211620326252027103 0ustar laneylaney.assembly extern mscorlib {} .assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static void Main(string[] s) cil managed { IL_0000: nop IL_0001: ldarg.0 IL_0002: isinst [mscorlib]System.Collections.IEnumerable IL_0007: callvirt instance class [mscorlib]System.Collections.IEnumerator [mscorlib]System.Collections.IEnumerable::GetEnumerator() IL_000c: pop IL_000d: br.s IL_000f IL_000f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Empty-afg.txt0000644000175000017500000000000711620326252026357 0ustar laneylaneyreturn cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/Switch-cfg.txt0000644000175000017500000000154111620326252026530 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldarg.0 IL_0002: stloc.1 IL_0003: ldloc.1 IL_0004: ldc.i4.1 IL_0005: sub IL_0006: switch (IL_001d, IL_0021, IL_0025, IL_0029) successors: block 3 block 4 block 5 block 6 block 2 block 2: body: IL_001b: br.s IL_002d successors: block 7 block 3: body: IL_001d: ldc.i4.1 IL_001e: stloc.0 IL_001f: br.s IL_0031 successors: block 8 block 4: body: IL_0021: ldc.i4.2 IL_0022: stloc.0 IL_0023: br.s IL_0031 successors: block 8 block 5: body: IL_0025: ldc.i4.3 IL_0026: stloc.0 IL_0027: br.s IL_0031 successors: block 8 block 6: body: IL_0029: ldc.i4.4 IL_002a: stloc.0 IL_002b: br.s IL_0031 successors: block 8 block 7: body: IL_002d: ldc.i4.m1 IL_002e: stloc.0 IL_002f: br.s IL_0031 successors: block 8 block 8: body: IL_0031: ldloc.0 IL_0032: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/SingleOr-afg.txt0000644000175000017500000000010211620326252026777 0ustar laneylaneylocal0 = ((x == 3) || (x == 5)) goto block3 block3: return local0 cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/StringPredicate.il0000644000175000017500000000107011620326252027403 0ustar laneylaney.assembly TestCase {} .class public auto ansi beforefieldinit TestCase extends [mscorlib]System.Object { .method public hidebysig static bool Main(string 'value') cil managed { .locals init (bool local0) IL_0000: ldarg.0 IL_0001: ldstr "foo" IL_0006: call bool string::op_Equality(string, string) IL_000b: brtrue.s IL_001a IL_000d: ldarg.0 IL_000e: ldstr "bar" IL_0013: call bool string::op_Equality(string, string) IL_0018: br.s IL_001b IL_001a: ldc.i4.1 IL_001b: stloc.0 IL_001c: br.s IL_001e IL_001e: ldloc.0 IL_001f: ret } } cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/testcases/FlowAnalysis/MathOperators-cfg.txt0000644000175000017500000000155311620326252030062 0ustar laneylaneyblock 1: body: IL_0000: nop IL_0001: ldc.i4.1 IL_0002: stloc.0 IL_0003: ldloc.0 IL_0004: ldc.i4.2 IL_0005: add IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: ldc.i4.3 IL_0009: sub IL_000a: stloc.0 IL_000b: ldloc.0 IL_000c: ldc.i4.4 IL_000d: mul IL_000e: stloc.0 IL_000f: ldloc.0 IL_0010: ldc.i4.5 IL_0011: div IL_0012: stloc.0 IL_0013: ldloc.0 IL_0014: ldc.i4.6 IL_0015: shr IL_0016: stloc.0 IL_0017: ldloc.0 IL_0018: ldc.i4.7 IL_0019: shl IL_001a: stloc.0 IL_001b: ldloc.0 IL_001c: ldc.i4.8 IL_001d: or IL_001e: stloc.0 IL_001f: ldloc.0 IL_0020: ldc.i4.s 9 IL_0022: and IL_0023: stloc.0 IL_0024: ldloc.0 IL_0025: ldc.i4.s 10 IL_0027: xor IL_0028: stloc.0 IL_0029: ldloc.0 IL_002a: ldc.i4.s 11 IL_002c: rem IL_002d: stloc.0 IL_002e: ldloc.0 IL_002f: not IL_0030: stloc.0 IL_0031: ret cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/Makefile0000755000175000017500000000074511620326252021030 0ustar laneylaneyMCS = mcs KEY_FILE = ../../mcs/class/mono.snk MCS_FLAGS = -keyfile:$(KEY_FILE) BUILD.DIR = bin MONO.CECIL.DLL = ../../mcs/class/Mono.Cecil/Mono.Cecil.dll all: init $(MCS) $(MCS_FLAGS) @Cecil.FlowAnalysis.sources /target:library /out:$(BUILD.DIR)/Cecil.FlowAnalysis.dll /r:$(BUILD.DIR)/Mono.Cecil.dll init: mkdir -p $(BUILD.DIR) cp $(MONO.CECIL.DLL) $(BUILD.DIR)/ find Cecil.FlowAnalysis -name "*.cs" > Cecil.FlowAnalysis.sources clean: rm -fr $(BUILD.DIR) rebuild: clean all cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/ChangeLog0000755000175000017500000000660711620326252021145 0ustar laneylaney2009-03-09 Rodrigo B. de Oliveira * Cecil.FlowAnalysis.Tests/ActionFlowTestFixture.cs * Cecil.FlowAnalysis.Tests/ControlFlowTestFixture.cs * Cecil.FlowAnalysis/ActionFlow/ExpressionDecompiler.cs * testcases/FlowAnalysis/Box.il * testcases/FlowAnalysis/Box-afg.txt * testcases/FlowAnalysis/Box-cfg.txt Interpret box instruction as CastExpression. 2008-02-07 Jb Evain * Cecil.FlowAnalysis/ControlFlow/ControlFlowGraphBuilder.cs * Cecil.FlowAnalysis/Utilities/Formatter.cs * Cecil.FlowAnalysis.Tests/ControlFlowTestFixture.cs * testcases/FlowAnalysis/Switch-cfg.txt * testcases/FlowAnalysis/Switch.il Add support for switch in control flow graphs. 2008-01-16 Jb Evain * Support for not. 2008-01-13 Jb Evain * Support for more ldloc, stloc, ldarg. 2008-01-13 Jb Evain * Support for div, sub, shr, shl, and, or, xor, rem. 2007-12-29 Rodrigo B. de Oliveira * Support for static fields (ldsfld, stsfld) 2007-12-10 Jb Evain * Support for dup, add and stfld. Patch by Sanghyeon Seo 2007-12-09 Jb Evain * Support for isinst. 2007-11-26 Rodrigo B. de Oliveira * codegen/gen-ControlFlowGraphRegression.boo codegen/CodeStructureModel.boo Cecil.FlowAnalysis/ActionFlow/ActionFlowGraphBuilder.cs Cecil.FlowAnalysis/ActionFlow/ExpressionDecompiler.cs Cecil.FlowAnalysis/Cecil.FlowAnalysis.csproj Cecil.FlowAnalysis/CodeStructure/ICodeStructureVisitor.cs Cecil.FlowAnalysis/CodeStructure/CodeElementType.cs Cecil.FlowAnalysis/CodeStructure/AbstractCodeStructureVisitor.cs Cecil.FlowAnalysis/CodeStructure/ExpressionPrinter.cs Cecil.FlowAnalysis/CodeStructure/CastExpression.cs Cecil.FlowAnalysis.Tests/ActionFlowTestFixture.cs Cecil.FlowAnalysis.Tests/ControlFlowTestFixture.cs testcases/FlowAnalysis/StringCast.il testcases/FlowAnalysis/StringCast-afg.txt testcases/FlowAnalysis/StringCast-cfg.txt: Support for converting castclass to CastExpression and callvirt to MethodInvocationExpression. 2007-09-30 Jb Evain * README: test commit script 2007-08-08 Rodrigo B. de Oliveira * default.build: compact framework 1.0 build fix 2006-09-15 Jb Evain * convert to the new Cecil API. 2006-05-12 Jb Evain * Cecil.FlowAnalysis/AssemblyInfo.cs: Hide the info if FlowAnalysis is embedded. 2006-05-08 Jb Evain * Cecil.FlowAnalysis/AssemblyInfo.cs Makefile: Sign the assembly. 2006-01-30 Rodrigo B. de Oliveira * Makefile a simple Makefile to get mono hackers started 2005-12-19 Rodrigo B. de Oliveira * Cecil.FlowAnalysis.Tests/ActionFlowTestFixture.cs testcases/FlowAnalysis/IntPropertyEquals2.il testcases/FlowAnalysis/IntPropertyEquals1-afg.txt testcases/FlowAnalysis/IntPropertyEquals2-afg.txt: more test cases testcases/FlowAnalysis/IntPropertyEquals1.il 2005-12-19 Rodrigo B. de Oliveira * Cecil.FlowAnalysis.Tests/AbstractFlowAnalysisTestFixture.cs: take into account that the path to the temp directory might contain spaces 2005-11-29 Rodrigo B. de Oliveira * Initial import cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/decompiler-notes.txt0000644000175000017500000000212011620326252023364 0ustar laneylaneyCode Structure Decoding *********************** Basic Flow Analysis =================== * input: raw instruction list * output: instruction block list * a instruction block is defined by a start instruction and a finishing instruction + a list of successor blocks * split bytecode into multiple instruction blocks: * the first instruction of a method starts a block * the target of a branch instruction start a block * a branch instruction finishes a block * the instruction after a branch instruction starts a block * the last instruction of a method finishes a block Action/Low-level statement Delimitation ============================= * input: control flow graph * output: action flow graph 1) ASSIGN EXPRESSION 2) INVOKE EXPRESSION+ 3) BRANCH 4) COND_BRANCH EXPRESSION 5) RETURN 1) stloc, starg, stfld, stsfld 3) call, callvirt 3) br.s, br 4) ble, beq, ... 5) ret Deoptimization ============== * replace ret instructions in leaves by a connection to a single ret block from both leaves Expression Aggregation ====================== Simple Copy Propagation ======================= cecil-flowanalysis-0.1~vcs20110809.r1.b34edf6/nunit.inc0000644000175000017500000000141011620326252021203 0ustar laneylaney