本文整理汇总了C#中IMethod.GetSymMethod方法的典型用法代码示例。如果您正苦于以下问题:C# IMethod.GetSymMethod方法的具体用法?C# IMethod.GetSymMethod怎么用?C# IMethod.GetSymMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethod
的用法示例。
在下文中一共展示了IMethod.GetSymMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLocalVariables
public IEnumerable<ILLocalVariable> GetLocalVariables(IMethod method)
{
List<ILLocalVariable> vars = new List<ILLocalVariable>();
var symMethod = method.GetSymMethod();
if (symMethod == null)
return vars;
Stack<ISymUnmanagedScope> scopes = new Stack<ISymUnmanagedScope>();
scopes.Push(symMethod.GetRootScope());
while(scopes.Count > 0) {
ISymUnmanagedScope scope = scopes.Pop();
foreach (ISymUnmanagedVariable symVar in scope.GetLocals()) {
int index = (int)symVar.GetAddressField1();
vars.Add(new ILLocalVariable() {
Index = index,
Type = method.GetLocalVariableType(index),
Name = symVar.GetName(),
IsCompilerGenerated = (symVar.GetAttributes() & 1) == 1,
// symVar also has Get*Offset methods, but the are not implemented
ILRanges = new [] { new ILRange() { From = (int)scope.GetStartOffset(), To = (int)scope.GetEndOffset() } }
});
}
foreach(ISymUnmanagedScope childScope in scope.GetChildren()) {
scopes.Push(childScope);
}
}
return vars;
}
示例2: GetSequencePoint
public SequencePoint GetSequencePoint(IMethod method, int iloffset)
{
var symMethod = method.GetSymMethod();
if (symMethod == null)
return null;
// 0xFEEFEE means "code generated by compiler"
int codeSize = (int)method.ToCorFunction().GetILCode().GetSize();
var sequencePoints = symMethod.GetSequencePoints(codeSize);
var realSeqPoints = sequencePoints.Where(p => p.StartLine != 0xFEEFEE);
// Find point for which (ilstart <= iloffset < ilend) or fallback to the next valid sequence point
var sequencePoint = realSeqPoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)) ??
realSeqPoints.FirstOrDefault(p => iloffset <= p.ILOffset);
if (sequencePoint != null) {
// VB.NET sometimes produces temporary files which it then deletes
// (eg 17d14f5c-a337-4978-8281-53493378c1071.vb)
string name = Path.GetFileName(sequencePoint.Filename);
if (name.Length == 40 && name.EndsWith(".vb")) {
if (name.Substring(0, name.Length - 3).All(c => ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || (c == '-'))) {
return null;
}
}
sequencePoint.Filename = GetSourceCodePath(method.ParentAssembly.GetModule().Process, sequencePoint.Filename);
}
return sequencePoint;
}
示例3: GetIgnoredILRanges
public IEnumerable<ILRange> GetIgnoredILRanges(IMethod method)
{
var symMethod = method.GetSymMethod();
if (symMethod == null)
return null;
int codeSize = (int)method.ToCorFunction().GetILCode().GetSize();
return symMethod.GetSequencePoints(codeSize).Where(p => p.StartLine == 0xFEEFEE).SelectMany(p => p.ILRanges).ToList();
}
示例4: IsCompilerGenerated
public bool IsCompilerGenerated(IMethod method)
{
return method.GetSymMethod() == null;
}