This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
/
MonoFundamentalType.cs
166 lines (140 loc) · 5.08 KB
/
MonoFundamentalType.cs
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Runtime.InteropServices;
using Mono.Debugger.Backend;
using Mono.Debugger.Backend.Mono;
namespace Mono.Debugger.Languages.Mono
{
internal class MonoFundamentalType : TargetFundamentalType
{
MonoSymbolFile file;
MonoClassType class_type;
Cecil.TypeDefinition typedef;
protected MonoFundamentalType (MonoSymbolFile file, Cecil.TypeDefinition typedef,
string name, FundamentalKind kind, int size)
: base (file.Language, name, kind, size)
{
this.file = file;
this.typedef = typedef;
}
public static MonoFundamentalType Create (MonoSymbolFile corlib,
TargetMemoryAccess memory,
FundamentalKind kind)
{
MonoFundamentalType fundamental;
TargetAddress klass;
switch (kind) {
case FundamentalKind.Boolean:
klass = corlib.MonoLanguage.MetadataHelper.GetBooleanClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Boolean"),
"bool", kind, 1);
break;
case FundamentalKind.Char:
klass = corlib.MonoLanguage.MetadataHelper.GetCharClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Char"),
"char", kind, 2);
break;
case FundamentalKind.SByte:
klass = corlib.MonoLanguage.MetadataHelper.GetSByteClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.SByte"),
"sbyte", kind, 1);
break;
case FundamentalKind.Byte:
klass = corlib.MonoLanguage.MetadataHelper.GetByteClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Byte"),
"byte", kind, 1);
break;
case FundamentalKind.Int16:
klass = corlib.MonoLanguage.MetadataHelper.GetInt16Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Int16"),
"short", kind, 2);
break;
case FundamentalKind.UInt16:
klass = corlib.MonoLanguage.MetadataHelper.GetUInt16Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.UInt16"),
"ushort", kind, 2);
break;
case FundamentalKind.Int32:
klass = corlib.MonoLanguage.MetadataHelper.GetInt32Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Int32"),
"int", kind, 4);
break;
case FundamentalKind.UInt32:
klass = corlib.MonoLanguage.MetadataHelper.GetUInt32Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.UInt32"),
"uint", kind, 4);
break;
case FundamentalKind.Int64:
klass = corlib.MonoLanguage.MetadataHelper.GetInt64Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Int64"),
"long", kind, 8);
break;
case FundamentalKind.UInt64:
klass = corlib.MonoLanguage.MetadataHelper.GetUInt64Class (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.UInt64"),
"ulong", kind, 8);
break;
case FundamentalKind.Single:
klass = corlib.MonoLanguage.MetadataHelper.GetSingleClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Single"),
"float", kind, 4);
break;
case FundamentalKind.Double:
klass = corlib.MonoLanguage.MetadataHelper.GetDoubleClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Double"),
"double", kind, 8);
break;
case FundamentalKind.IntPtr:
klass = corlib.MonoLanguage.MetadataHelper.GetIntPtrClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.IntPtr"),
"System.IntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize);
break;
case FundamentalKind.UIntPtr:
klass = corlib.MonoLanguage.MetadataHelper.GetUIntPtrClass (memory);
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.UIntPtr"),
"System.UIntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize);
break;
case FundamentalKind.Decimal:
fundamental = new MonoFundamentalType (
corlib, corlib.ModuleDefinition.GetType ("System.Decimal"),
"decimal", kind, Marshal.SizeOf (typeof (Decimal)));
return fundamental;
default:
throw new InternalError ();
}
fundamental.create_type (memory, klass);
return fundamental;
}
internal void SetClass (MonoClassType info)
{
this.class_type = info;
}
protected void create_type (TargetMemoryAccess memory, TargetAddress klass)
{
class_type = file.MonoLanguage.CreateCoreType (file, typedef, memory, klass);
file.MonoLanguage.AddCoreType (typedef, this, class_type, klass);
}
public override bool HasClassType {
get { return true; }
}
public override TargetClassType ClassType {
get { return class_type; }
}
internal MonoClassType MonoClassType {
get { return class_type; }
}
}
}