本文整理匯總了C#中Mono.Cecil.Cil.MethodBody.ComputeCodeSize方法的典型用法代碼示例。如果您正苦於以下問題:C# MethodBody.ComputeCodeSize方法的具體用法?C# MethodBody.ComputeCodeSize怎麽用?C# MethodBody.ComputeCodeSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.Cil.MethodBody
的用法示例。
在下文中一共展示了MethodBody.ComputeCodeSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Disassemble
public void Disassemble(MethodBody body)
{
// start writing IL code
var method = body.Method;
var codesize = body.ComputeCodeSize();
var maxstacksize = body.ComputeMaxStackSize();
body.ComputeOffsets();
_o.WriteLine("// Code size {0} (0x{0:x})", codesize);
_o.WriteLine(".maxstack {0}", maxstacksize);
if (method.DeclaringType.Module.Assembly != null && method.DeclaringType.Module.Assembly.EntryPoint == method)
_o.WriteLine(".entrypoint");
if (method.Body.HasVariables)
{
_o.Write(".locals ");
if (body.InitLocals)
_o.Write("init ");
_o.WriteLine("(");
_o.Indent();
foreach (var v in body.Variables)
{
_o.Write("[" + v.Index + "] ");
v.VariableType.WriteTo(_o);
if (!string.IsNullOrEmpty(v.Name))
{
_o.Write(' ');
_o.Write(DisassemblerHelpers.Escape(v.Name));
}
if (v.Index + 1 < body.Variables.Count)
_o.Write(',');
_o.WriteLine();
}
_o.Unindent();
_o.WriteLine(")");
}
_o.WriteLine();
if (body.Instructions.Count > 0)
{
var inst = body.Instructions[0];
var branchTargets = GetBranchTargets(body.Instructions);
WriteStructureBody(new IlStructure(body, codesize), branchTargets, ref inst);
}
else
{
// we ignore method without instructions (but it can have exception handlers)
_o.WriteLine();
}
}