This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
/
TargetType.cs
102 lines (80 loc) · 2.03 KB
/
TargetType.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
using System;
namespace Mono.Debugger.Languages
{
public abstract class TargetType : DebuggerMarshalByRefObject
{
protected readonly Language language;
protected readonly TargetObjectKind kind;
protected TargetType (Language language, TargetObjectKind kind)
{
this.language = language;
this.kind = kind;
}
public TargetObjectKind Kind {
get { return kind; }
}
public abstract string Name {
get;
}
public abstract bool IsByRef {
get;
}
public abstract bool HasFixedSize {
get;
}
public Language Language {
get { return language; }
}
public abstract int Size {
get;
}
internal void SetObject (Thread target, TargetLocation location,
TargetObject obj)
{
if (obj == null) {
if (IsByRef) {
location.WriteAddress (target, TargetAddress.Null);
return;
}
throw new InvalidOperationException ();
}
if (IsByRef) {
if (obj.Type.IsByRef) {
location.WriteAddress (target, obj.Location.GetAddress (target));
return;
}
throw new InvalidOperationException ();
}
if (!HasFixedSize || !obj.Type.HasFixedSize)
throw new InvalidOperationException ();
if (Size != obj.Type.Size)
throw new InvalidOperationException ();
byte[] contents = obj.Location.ReadBuffer (target, obj.Type.Size);
location.WriteBuffer (target, contents);
}
internal TargetObject GetObject (TargetLocation location)
{
if (ContainsGenericParameters)
throw new InvalidOperationException ();
return DoGetObject (location);
}
protected abstract TargetObject DoGetObject (TargetLocation location);
public virtual bool ContainsGenericParameters {
get { return false; }
}
internal TargetType InflateType (Mono.MonoGenericContext context)
{
if (!ContainsGenericParameters)
return this;
return DoInflateType (context);
}
protected virtual TargetType DoInflateType (Mono.MonoGenericContext context)
{
return this;
}
public override string ToString ()
{
return String.Format ("{0} [{1}]", GetType (), Name);
}
}
}