~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Mono.Debugger.Soft/Mono.Debugger.Soft/StructMirror.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections.Generic;
 
3
 
 
4
namespace Mono.Debugger.Soft
 
5
{
 
6
        /*
 
7
         * Represents a valuetype value in the debuggee
 
8
         */
 
9
        public class StructMirror : Value {
 
10
        
 
11
                TypeMirror type;
 
12
                Value[] fields;
 
13
 
 
14
                internal StructMirror (VirtualMachine vm, TypeMirror type, Value[] fields) : base (vm, 0) {
 
15
                        this.type = type;
 
16
                        this.fields = fields;
 
17
                }
 
18
 
 
19
                public TypeMirror Type {
 
20
                        get {
 
21
                                return type;
 
22
                        }
 
23
                }
 
24
 
 
25
                public Value[] Fields {
 
26
                        get {
 
27
                                return fields;
 
28
                        }
 
29
                }
 
30
 
 
31
                public Value this [String field] {
 
32
                        get {
 
33
                                FieldInfoMirror[] field_info = Type.GetFields ();
 
34
                                int nf = 0;
 
35
                                for (int i = 0; i < field_info.Length; ++i) {
 
36
                                        if (!field_info [i].IsStatic) {
 
37
                                                if (field_info [i].Name == field)
 
38
                                                        return Fields [nf];
 
39
                                                nf++;
 
40
                                        }
 
41
                                }
 
42
                                throw new ArgumentException ("Unknown struct field '" + field + "'.", "field");
 
43
                        }
 
44
                }
 
45
 
 
46
                internal void SetField (int index, Value value) {
 
47
                        fields [index] = value;
 
48
                }
 
49
 
 
50
                public Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments) {
 
51
                        return ObjectMirror.InvokeMethod (vm, thread, method, this, arguments, InvokeOptions.None);
 
52
                }
 
53
 
 
54
                public Value InvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options) {
 
55
                        return ObjectMirror.InvokeMethod (vm, thread, method, this, arguments, options);
 
56
                }
 
57
 
 
58
                [Obsolete ("Use the overload without the 'vm' argument")]
 
59
                public IAsyncResult BeginInvokeMethod (VirtualMachine vm, ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state) {
 
60
                        return ObjectMirror.BeginInvokeMethod (vm, thread, method, this, arguments, options, callback, state);
 
61
                }
 
62
 
 
63
                public IAsyncResult BeginInvokeMethod (ThreadMirror thread, MethodMirror method, IList<Value> arguments, InvokeOptions options, AsyncCallback callback, object state) {
 
64
                        return ObjectMirror.BeginInvokeMethod (vm, thread, method, this, arguments, options, callback, state);
 
65
                }
 
66
 
 
67
                public Value EndInvokeMethod (IAsyncResult asyncResult) {
 
68
                        return ObjectMirror.EndInvokeMethodInternal (asyncResult);
 
69
                }
 
70
        }
 
71
}