本文整理汇总了C#中Mono.Cecil.Cil.MethodSymbols类的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbols类的具体用法?C# MethodSymbols怎么用?C# MethodSymbols使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodSymbols类属于Mono.Cecil.Cil命名空间,在下文中一共展示了MethodSymbols类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
int ICorDebugManagedCallback.LoadAssembly (CorDebugAppDomain pAppDomain, CorDebugAssembly pAssembly)
{
assemblies.Add (pAssembly);
//CorMetadataImport mi = new CorMetadataImport(pAssembly);
//Seems like this is always set on MicroFramework
//pAssembly. JITCompilerFlags = CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION;
List<string> docPaths = new List<string> ();
if (pAssembly.DebugData != null) {
var md = pAssembly.MetaData;
var reader = pAssembly.DebugData;
if (!pAssembly.IsFrameworkAssembly) {
foreach (var module in md.Assembly.Modules) {
foreach (var t in module.Types) {
foreach (var m in t.Methods) {
var methodSymbols = new MethodSymbols (m.MetadataToken);
//Ugly hack
if(reader is Mono.Cecil.Mdb.MdbReader)
{
foreach(var variable in m.Body.Variables)
methodSymbols.Variables.Add(variable);
}
reader.Read (methodSymbols);
if (methodSymbols.Instructions.Count == 0)
continue;
DocInfo document;
if (!documents.TryGetValue (methodSymbols.Instructions [0].SequencePoint.Document.Url, out document)) {
document = new DocInfo (methodSymbols.Instructions [0].SequencePoint.Document.Url);
document.Assembly = pAssembly;
documents.Add (document.Url, document);
}
document.AddMethod (m, methodSymbols);
if (!docPaths.Contains (document.Url))
docPaths.Add (document.Url);
}
}
}
}
pAssembly.SetJmcStatus (true);
} else {
// Flag modules without debug info as not JMC. In this way
// the debugger won't try to step into them
pAssembly.SetJmcStatus (false);
}
foreach (var docPath in docPaths)
BindSourceFileBreakpoints (docPath);
pAppDomain.Process.Continue ();
return 0;
}
示例2: GetLocalVarToken
static MetadataToken GetLocalVarToken (ByteBuffer buffer, MethodSymbols symbols)
{
if (symbols.variables.IsNullOrEmpty ())
return MetadataToken.Zero;
buffer.position = 8;
return new MetadataToken (buffer.ReadUInt32 ());
}
示例3: ReadLineNumbers
void ReadLineNumbers (MethodEntry entry, MethodSymbols symbols)
{
var table = entry.GetLineNumberTable ();
var lines = table.LineNumbers;
var instructions = symbols.instructions = new Collection<InstructionSymbol> (lines.Length);
for (int i = 0; i < lines.Length; i++) {
var line = lines [i];
instructions.Add (new InstructionSymbol (line.Offset, new SequencePoint (GetDocument (entry.CompileUnit.SourceFile)) {
StartLine = line.Row,
EndLine = line.Row,
}));
}
}
示例4: DefineSequencePoints
void DefineSequencePoints(MethodSymbols symbols)
{
var instructions = symbols.instructions;
if (instructions == null)
return;
for (int i = 0; i < instructions.Count; i++) {
var instruction = instructions [i];
var sequence_point = instruction.SequencePoint;
writer.DefineSequencePoints (
GetDocument (sequence_point.Document),
new [] { instruction.Offset },
new [] { sequence_point.StartLine },
new [] { sequence_point.StartColumn },
new [] { sequence_point.EndLine },
new [] { sequence_point.EndColumn });
}
}
示例5: WriteScope
void WriteScope(MethodSymbols symbols, ScopeSymbol scope)
{
writer.OpenScope (scope.Start);
foreach (var s in scope.Scopes)
WriteScope (symbols, s);
DefineVariables (symbols, scope.Variables, scope.Start, scope.End) ;
writer.CloseScope (scope.End);
}
示例6: PatchRawMethodBody
public ByteBuffer PatchRawMethodBody(MethodDefinition method, CodeWriter writer, out MethodSymbols symbols)
{
var buffer = new ByteBuffer ();
symbols = new MethodSymbols (method.Name);
this.method = method;
reader.context = method;
MoveTo (method.RVA);
var flags = ReadByte ();
MetadataToken local_var_token;
switch (flags & 0x3) {
case 0x2: // tiny
buffer.WriteByte (flags);
local_var_token = MetadataToken.Zero;
symbols.code_size = flags >> 2;
PatchRawCode (buffer, symbols.code_size, writer);
break;
case 0x3: // fat
base.position--;
PatchRawFatMethod (buffer, symbols, writer, out local_var_token);
break;
default:
throw new NotSupportedException ();
}
var symbol_reader = reader.module.SymbolReader;
if (symbol_reader != null && writer.metadata.write_symbols) {
symbols.method_token = GetOriginalToken (writer.metadata, method);
symbols.local_var_token = local_var_token;
symbol_reader.Read (symbols);
}
return buffer;
}
示例7: SourceMethodSymbol
public SourceMethodSymbol(MethodSymbols symbols)
{
name = symbols.MethodName;
token = symbols.MethodToken.ToInt32 ();
}
示例8: Write
public void Write(MethodSymbols symbols)
{
var sym_token = new SymbolToken (symbols.MethodToken.ToInt32 ());
writer.OpenMethod (sym_token);
DefineSequencePoints (symbols);
DefineVariables (symbols);
writer.CloseMethod ();
}
示例9: ReadLines
void ReadLines(PdbLines lines, MethodSymbols symbols)
{
symbols.Document = GetDocument (lines.file);
var count = lines.lines.Length;
symbols.Offsets = new int [count];
symbols.StartRows = new int [count];
symbols.StartColumns = new int [count];
symbols.EndRows = new int [count];
symbols.EndColumns = new int [count];
for (int i = 0; i < lines.lines.Length; i++) {
var line = lines.lines [i];
symbols.Offsets [i] = (int) line.offset;
symbols.StartRows [i] = (int) line.lineBegin;
symbols.StartColumns [i] = line.colBegin;
symbols.EndRows [i] = (int) line.lineEnd;
symbols.EndColumns [i] = line.colEnd;
}
}
示例10: DefineSequencePoints
void DefineSequencePoints(MethodSymbols symbols)
{
writer.DefineSequencePoints (
GetDocument (symbols.Document),
symbols.Offsets,
symbols.StartRows,
symbols.StartColumns,
symbols.EndRows,
symbols.EndColumns);
}
示例11: DefineVariables
void DefineVariables(MethodSymbols symbols)
{
if (!symbols.HasVariables)
return;
var start_offset = 0;
var end_offset = symbols.CodeSize;
writer.OpenScope (start_offset);
var sym_token = new SymbolToken (symbols.LocalVarToken.ToInt32 ());
var variables = symbols.Variables;
for (int i = 0; i < variables.Count; i++) {
var variable = variables [i];
CreateLocalVariable (variable, sym_token, start_offset, end_offset);
}
writer.CloseScope (end_offset);
}
示例12: ReadScopeAndLocals
static void ReadScopeAndLocals(PdbScope scope, ScopeSymbol parent, MethodSymbols symbols)
{
if (scope == null)
return;
ScopeSymbol s = new ScopeSymbol ();
s.start = (int) scope.offset;
s.end = (int)(scope.offset + scope.length);
if (parent != null)
parent.Scopes.Add (s);
else
if (symbols.scope == null)
symbols.scope = s;
else
throw new InvalidDataException () ;
foreach (PdbSlot slot in scope.slots) {
int index = (int) slot.slot;
if (index < 0 || index >= symbols.Variables.Count)
continue;
VariableDefinition variable = symbols.Variables [index];
variable.Name = slot.name;
s.Variables.Add (variable);
}
ReadScopeAndLocals (scope.scopes, s, symbols);
}
示例13: Read
public void Read(MethodSymbols symbols)
{
PdbFunction function;
if (!functions.TryGetValue (symbols.MethodToken.ToUInt32 (), out function))
return;
ReadSequencePoints (function, symbols);
ReadScopeAndLocals (function.scopes, null, symbols);
if (!string.IsNullOrEmpty (function.iteratorClass))
symbols.IteratorType = function.iteratorClass;
if (function.iteratorScopes != null)
foreach (Microsoft.Cci.ILocalScope scope in function.iteratorScopes)
{
RangeSymbol range = new RangeSymbol ();
range.start = (int) scope.Offset;
range.end = (int)(scope.Offset + scope.Length);
symbols.IteratorScopes.Add (range);
}
}
示例14: ReadLocalVariables
static void ReadLocalVariables (MethodEntry entry, MethodSymbols symbols)
{
foreach (var local in entry.GetLocals ()) {
if (local.Index < 0 || local.Index >= symbols.Variables.Count) // Mono 2.6 emits wrong local infos for iterators
continue;
var variable = symbols.Variables [local.Index];
variable.Name = local.Name;
}
}
示例15: Read
public void Read(MethodSymbols symbols)
{
PdbFunction function;
if (!functions.TryGetValue (symbols.MethodToken.ToUInt32 (), out function))
return;
ReadSequencePoints (function, symbols);
ReadLocals (function.scopes, symbols);
}