2 // Mono.ILASM.DebuggingInfo.cs
5 // Martin Baulig (martin@ximian.com)
7 // Copyright (C) 2004 Novell, Inc.
13 using System
.Collections
;
14 using Mono
.CompilerServices
.SymbolWriter
;
16 namespace Mono
.ILASM
{
18 public class SymbolWriter
: MonoSymbolWriter
20 Mono
.ILASM
.SourceMethod current_method
;
21 CompileUnitEntry current_source
;
24 public SymbolWriter (string filename
)
27 methods
= new ArrayList ();
30 public Mono
.ILASM
.SourceMethod
BeginMethod (MethodDef method
, Location start
)
32 current_method
= new Mono
.ILASM
.SourceMethod (current_source
, method
, start
);
33 methods
.Add (current_method
);
34 return current_method
;
37 public void EndMethod (Location end
)
39 current_method
.EndLine
= end
.line
;
40 current_method
= null;
43 public void BeginSourceFile (string filename
)
45 SourceFileEntry file
= DefineDocument (filename
, null, null);
46 current_source
= DefineCompilationUnit (file
);
49 public void EndSourceFile ()
51 current_source
= null;
54 public void Write (Guid guid
)
56 foreach (Mono
.ILASM
.SourceMethod method
in methods
)
59 WriteSymbolFile (guid
);
63 public class SourceMethod
: IMethodDef
65 CompileUnitEntry file
;
68 public int StartLine
, EndLine
;
70 public SourceMethod (CompileUnitEntry file
, MethodDef method
, Location start
)
74 this.StartLine
= start
.line
;
76 lines
= new ArrayList ();
77 MarkLocation (start
.line
, 0);
81 get { return method.Name; }
86 PEAPI
.MethodDef pemethod
= method
.PeapiMethodDef
;
87 return (int) (((uint) PEAPI
.MDTable
.Method
<< 24) | pemethod
.Row
);
91 public void MarkLocation (int line
, uint offset
)
93 lines
.Add (new LineNumberEntry (0, line
, (int) offset
));
96 public void Write (MonoSymbolWriter writer
)
98 LineNumberEntry
[] the_lines
= new LineNumberEntry
[lines
.Count
];
99 lines
.CopyTo (the_lines
, 0);
101 LocalVariableEntry
[] locals
= method
.GetLocalVars ();
103 MethodEntry entry
= writer
.SymbolFile
.DefineMethod (
104 file
, Token
, null, locals
, the_lines
, null, null, 0, 0);