Esempio n. 1
0
        public override void EnumerateRefsOfObject(Address objRef, Action <Address, int> action)
        {
            if (IsArray)
            {
                bool isRefType = GCRootNames.IsReferenceType(m_array.componentType);
                if (isRefType || m_array.componentType == CorElementType.ELEMENT_TYPE_VALUETYPE)
                {
                    var arrayLength = (int)m_heap.FetchIntPtrAt(objRef, m_array.countOffset);
                    int offset      = m_array.firstElementOffset;
                    if (isRefType)
                    {
                        for (int i = 0; i < arrayLength; i++)
                        {
                            var val = m_heap.FetchIntPtrAt(objRef, offset);
                            if (val != 0)
                            {
                                action(val, offset);
                            }

                            offset += m_array.elementSize;
                        }
                    }
                    else
                    {
                        Debug.Assert(m_array.componentType == CorElementType.ELEMENT_TYPE_VALUETYPE);
                        for (int i = 0; i < arrayLength; i++)
                        {
                            m_elementType.EnumerateRefsOfUnboxedClass(objRef, offset, action);
                            offset += m_array.elementSize;
                        }
                    }
                }
            }
            else
            {
                // Do the base type's references
                if (BaseType != null)
                {
                    BaseType.EnumerateRefsOfObjectCarefully(objRef, action);
                }
                // And then my fields.
                EnumerateRefsOfUnboxedClass(objRef, m_boxOffset, action);
            }
        }