2 using System.Collections;
3 using System.Collections.Generic;
5 namespace Mono.Debugger.Soft
7 public class ArrayMirror : ObjectMirror, IEnumerable {
10 public int[] lower_bounds;
13 internal ArrayMirror (VirtualMachine vm, long id) : base (vm, id) {
16 internal ArrayMirror (VirtualMachine vm, long id, TypeMirror type, AppDomainMirror domain) : base (vm, id, type, domain) {
23 int length = lengths [0];
25 for (int i = 1; i < Rank; i++) {
26 length *= lengths [i];
41 public int GetLength (int dimension) {
44 if (dimension < 0 || dimension >= Rank)
45 throw new ArgumentOutOfRangeException ("dimension");
47 return lengths [dimension];
50 public int GetLowerBound (int dimension) {
53 if (dimension < 0 || dimension >= Rank)
54 throw new ArgumentOutOfRangeException ("dimension");
56 return lower_bounds [dimension];
61 lengths = vm.conn.Array_GetLength (id, out this.rank, out this.lower_bounds);
64 public Value this [int index] {
66 // FIXME: Multiple dimensions
67 if (index < 0 || index > Length - 1)
68 throw new IndexOutOfRangeException ();
69 return vm.DecodeValue (vm.conn.Array_GetValues (id, index, 1) [0]);
72 // FIXME: Multiple dimensions
73 if (index < 0 || index > Length - 1)
74 throw new IndexOutOfRangeException ();
75 vm.conn.Array_SetValues (id, index, new ValueImpl [] { vm.EncodeValue (value) });
79 public IList<Value> GetValues (int index, int length) {
80 // FIXME: Multiple dimensions
81 if (index < 0 || index > Length - length)
82 throw new IndexOutOfRangeException ();
83 return vm.DecodeValues (vm.conn.Array_GetValues (id, index, length));
86 public void SetValues (int index, Value[] values) {
88 throw new ArgumentNullException ("values");
89 // FIXME: Multiple dimensions
90 if (index < 0 || index > Length - values.Length)
91 throw new IndexOutOfRangeException ();
92 vm.conn.Array_SetValues (id, index, vm.EncodeValues (values));
95 IEnumerator IEnumerable.GetEnumerator ()
97 return new SimpleEnumerator (this);
100 internal class SimpleEnumerator : IEnumerator, ICloneable
105 public SimpleEnumerator (ArrayMirror arr)
109 this.length = arr.Length;
112 public object Current {
115 throw new InvalidOperationException ("Enumeration has not started.");
117 throw new InvalidOperationException ("Enumeration has already ended");
122 public bool MoveNext()
137 public object Clone ()
139 return MemberwiseClone ();