本文整理汇总了C#中Mono.Cecil.Cil.MethodBody.ComputeMaxStackSize方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBody.ComputeMaxStackSize方法的具体用法?C# MethodBody.ComputeMaxStackSize怎么用?C# MethodBody.ComputeMaxStackSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.Cil.MethodBody
的用法示例。
在下文中一共展示了MethodBody.ComputeMaxStackSize方法的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();
}
}