Esempio n. 1
0
        internal T GetObject <T> (long id, long domain_id, long type_id) where T : ObjectMirror
        {
            lock (objects_lock)
            {
                if (objects == null)
                {
                    objects = new Dictionary <long, ObjectMirror> ();
                }
                ObjectMirror obj;
                if (!objects.TryGetValue(id, out obj))
                {
                    /*
                     * Obtain the domain/type of the object to determine the type of
                     * object we need to create.
                     */
                    if (domain_id == 0 || type_id == 0)
                    {
                        if (conn.Version.AtLeast(2, 5))
                        {
                            var info = conn.Object_GetInfo(id);
                            domain_id = info.domain_id;
                            type_id   = info.type_id;
                        }
                        else
                        {
                            if (domain_id == 0)
                            {
                                domain_id = conn.Object_GetDomain(id);
                            }
                            if (type_id == 0)
                            {
                                type_id = conn.Object_GetType(id);
                            }
                        }
                    }
                    AppDomainMirror d = GetDomain(domain_id);
                    TypeMirror      t = GetType(type_id);

                    if (t.Assembly == d.Corlib && t.Namespace == "System.Threading" && t.Name == "Thread")
                    {
                        obj = new ThreadMirror(this, id, t, d);
                    }
                    else if (t.Assembly == d.Corlib && t.Namespace == "System" && t.Name == "String")
                    {
                        obj = new StringMirror(this, id, t, d);
                    }
                    else if (typeof(T) == typeof(ArrayMirror))
                    {
                        obj = new ArrayMirror(this, id, t, d);
                    }
                    else
                    {
                        obj = new ObjectMirror(this, id, t, d);
                    }
                    objects [id] = obj;
                }
                return((T)obj);
            }
        }
 public static TypeMirror GetType(ArrayMirror parent, int key)
 {
     return parent.Type.GetElementType();
 }
Esempio n. 3
0
 public SimpleEnumerator(ArrayMirror arr)
 {
     this.arr    = arr;
     this.pos    = -1;
     this.length = arr.Length;
 }
Esempio n. 4
0
 public static VariableItem GetChild(ThreadMirror thread, VariableItem parentItem, ArrayMirror parent, int index)
 {
     string name = GetArrayName(parent, index);
     Value child = parent[index];
     return new VariableItem(thread, name, parentItem, index, child, index);
 }
Esempio n. 5
0
        private static int DoGetArrayLength(ArrayMirror parent, int dimension)
        {
            int length = 1;

            for (int dim = dimension + 1; dim < parent.Rank; ++dim)
            {
                length *= parent.GetLength(dim);
            }

            return length;
        }
Esempio n. 6
0
        internal static string GetArrayName(ArrayMirror parent, int i)
        {
            var builder = new System.Text.StringBuilder();

            builder.Append('[');
            for (int dim = 0; dim < parent.Rank; ++dim)
            {
                int length = DoGetArrayLength(parent, dim);
                int index;
                if (dim < parent.Rank - 1)
                {
                    index = i/length;
                    i = i - length*index;
                }
                else
                {
                    index = i;
                }

                builder.Append((index + parent.GetLowerBound(dim)).ToString());
                if (dim + 1 < parent.Rank)
                    builder.Append(", ");
            }
            builder.Append(']');

            return builder.ToString();
        }
Esempio n. 7
0
 public static void Set(ThreadMirror thread, VariableItem item, ArrayMirror parent, int key, Value newValue)
 {
     parent.SetValues(key, new Value[]{newValue});
 }
Esempio n. 8
0
        private void DoWalkArray(ArrayMirror value, Trace parent, string name)
        {
            if (!value.IsCollected && !m_objects.Contains(value.Address))
            {
                m_objects.Add(value.Address);
                if (value.Length > 0 &&  DoShouldWalkType(value.Type.GetElementType()))		// there's no need to walk arrays of primitives and they can be very large
                {
                    for (int i = 0; i < value.Length; ++i)
                    {
                        string temp = string.Format("{0}[{1}]", name, i);
                        Log.WriteLine(TraceLevel.Verbose, "TraceRoots", temp);

                        var child = new Trace(temp, value.Type.FullName, value[i]);
                        DoWalkValue(value[i], child, temp);
                        if (child.Children.Count > 0)
                            parent.Children.Add(child);
                    }
                }
            }
        }
		public ArrayAdaptor (ArrayMirror array)
		{
			this.array = array;
		}
			public SimpleEnumerator (ArrayMirror arr)
			{
				this.arr = arr;
				this.pos = -1;
				this.length = arr.Length;
			}
Esempio n. 11
0
 // Apply a hot reload delta to the current module
 // Since protocol version 2.60
 public void ApplyChanges(ArrayMirror dmeta, ArrayMirror dIL, Value dPDB)
 {
     /* dPDB is Value because it can be ArrayMirror or PrimitiveValue (vm, null) */
     vm.CheckProtocolVersion(2, 60);
     vm.conn.Module_ApplyChanges(id, dmeta.Id, dIL.Id, dPDB.Id);
 }