File: AssemblerMethod.cs

package info (click to toggle)
mono-debugger 0.60%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,556 kB
  • ctags: 22,787
  • sloc: ansic: 99,407; cs: 42,429; sh: 9,192; makefile: 376
file content (126 lines) | stat: -rw-r--r-- 2,741 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using System.Collections;

using Mono.Debugger.Languages;

namespace Mono.Debugger
{
	[Serializable]
	public sealed class AssemblerLine
	{
		public readonly string Label;
		public readonly TargetAddress Address;
		public readonly byte InstructionSize;
		public readonly string Text;

		public AssemblerLine (string label, TargetAddress address, byte size, string text)
		{
			this.Label = label;
			this.Address = address;
			this.InstructionSize = size;
			this.Text = text;
		}

		public AssemblerLine (TargetAddress address, byte size, string text)
			: this (null, address, size, text)
		{ }

		public string FullText {
			get {
				return String.Format ("{0:x}   {1}", Address, Text);
			}
		}
	}

	public sealed class AssemblerMethod : MethodSource
	{
		protected readonly Method method;
		protected readonly SourceBuffer buffer;
		protected readonly int start_row, end_row;
		protected readonly AssemblerLine[] lines;
		ArrayList addresses;

		public AssemblerMethod (Method method, AssemblerLine[] lines)
		{
			this.lines = lines;
			addresses = new ArrayList ();

			ArrayList contents = new ArrayList ();
			foreach (AssemblerLine line in lines) {
				if (line.Label != null) {
					if (end_row > 0) {
						contents.Add ("");
						end_row++;
					} else
						start_row++;
					contents.Add (String.Format ("{0}:", line.Label));
					end_row++;
				}

				addresses.Add (new LineEntry (line.Address, ++end_row));
				contents.Add (String.Format ("  {0:x}   {1}", line.Address, line.Text));
			}

			string[] text = new string [contents.Count];
			contents.CopyTo (text);

			buffer = new SourceBuffer (method.Name, text);
		}

		public override Module Module {
			get { return method.Module; }
		}

		public override string Name {
			get { return method.Name; }
		}

		public override bool IsManaged {
			get { return false; }
		}

		public override bool IsDynamic {
			get { return true; }
		}

		public override TargetClassType DeclaringType {
			get { throw new InvalidOperationException (); }
		}

		public override TargetFunctionType Function {
			get { throw new InvalidOperationException (); }
		}

		public override bool HasSourceFile {
			get { throw new InvalidOperationException (); }
		}

		public override SourceFile SourceFile {
			get { throw new InvalidOperationException (); }
		}

		public override bool HasSourceBuffer {
			get { return true; }
		}

		public override SourceBuffer SourceBuffer {
			get { return buffer; }
		}

		public override int StartRow {
			get { return start_row; }
		}

		public override int EndRow {
			get { return end_row; }
		}

		public override Method NativeMethod {
			get { return method; }
		}

		public AssemblerLine[] Lines {
			get { return lines; }
		}
	}
}