2 using System
.Collections
;
3 using System
.Collections
.Generic
;
5 namespace Mono
.Debugger
7 public class ArrayMirror
: ObjectMirror
, IEnumerable
{
10 public int[] lower_bounds
;
13 internal ArrayMirror (VirtualMachine vm
, long id
) : base (vm
, id
) {
20 int length
= lengths
[0];
22 for (int i
= 1; i
< Rank
; i
++) {
23 length
*= lengths
[i
];
38 public int GetLength (int dimension
) {
41 if (dimension
< 0 || dimension
>= Rank
)
42 throw new ArgumentOutOfRangeException ("dimension");
44 return lengths
[dimension
];
47 public int GetLowerBound (int dimension
) {
50 if (dimension
< 0 || dimension
>= Rank
)
51 throw new ArgumentOutOfRangeException ("dimension");
53 return lower_bounds
[dimension
];
58 lengths
= vm
.conn
.Array_GetLength (id
, out this.rank
, out this.lower_bounds
);
61 public Value
this [int index
] {
63 // FIXME: Multiple dimensions
64 if (index
< 0 || index
> Length
- 1)
65 throw new IndexOutOfRangeException ();
66 return vm
.DecodeValue (vm
.conn
.Array_GetValues (id
, index
, 1) [0]);
69 // FIXME: Multiple dimensions
70 if (index
< 0 || index
> Length
- 1)
71 throw new IndexOutOfRangeException ();
72 vm
.conn
.Array_SetValues (id
, index
, new ValueImpl
[] { vm.EncodeValue (value) }
);
76 public IList
<Value
> GetValues (int index
, int length
) {
77 // FIXME: Multiple dimensions
78 if (index
< 0 || index
> Length
- length
)
79 throw new IndexOutOfRangeException ();
80 return vm
.DecodeValues (vm
.conn
.Array_GetValues (id
, index
, length
));
83 public void SetValues (int index
, Value
[] values
) {
85 throw new ArgumentNullException ("values");
86 // FIXME: Multiple dimensions
87 if (index
< 0 || index
> Length
- values
.Length
)
88 throw new IndexOutOfRangeException ();
89 vm
.conn
.Array_SetValues (id
, index
, vm
.EncodeValues (values
));
92 IEnumerator IEnumerable
.GetEnumerator ()
94 return new SimpleEnumerator (this);
97 internal class SimpleEnumerator
: IEnumerator
, ICloneable
102 public SimpleEnumerator (ArrayMirror arr
)
106 this.length
= arr
.Length
;
109 public object Current
{
112 throw new InvalidOperationException ("Enumeration has not started.");
114 throw new InvalidOperationException ("Enumeration has already ended");
119 public bool MoveNext()
134 public object Clone ()
136 return MemberwiseClone ();