public override bool TryGetMember(GetMemberBinder binder, out object result) { if (IsNull()) { result = new ClrNullValue(m_heap); return(true); } ClrInstanceField field = null; if (binder.IgnoreCase) { foreach (var inst in m_type.Fields) { if (inst.Name.Equals(binder.Name, StringComparison.CurrentCultureIgnoreCase)) { field = inst; break; } } } else { field = m_type.GetFieldByName(binder.Name); } if (field == null) { if (ClrDynamicClass.GetStaticField(m_heap, m_type, binder, out result)) { return(true); } throw new InvalidOperationException(string.Format("Type '{0}' does not contain a '{1}' field.", m_type.Name, binder.Name)); } if (field.IsPrimitive()) { object value = field.GetFieldValue(m_addr, m_inner); if (value == null) { result = new ClrNullValue(m_heap); } else { result = new ClrPrimitiveValue(value, field.ElementType); } return(true); } else if (field.IsValueClass()) { ulong addr = field.GetFieldAddress(m_addr, m_inner); result = new ClrObject(m_heap, field.Type, addr, true); return(true); } else if (field.ElementType == ClrElementType.String) { ulong addr = field.GetFieldAddress(m_addr, m_inner); if (!m_heap.GetRuntime().ReadPointer(addr, out addr)) { result = new ClrNullValue(m_heap); return(true); } result = new ClrObject(m_heap, field.Type, addr); return(true); } else { object value = field.GetFieldValue(m_addr, m_inner); if (value == null) { result = new ClrNullValue(m_heap); } else { result = new ClrObject(m_heap, field.Type, (ulong)value); } return(true); } }
public void GetFieldAddress(ulong objRef, int interior, out ulong pAddress) { pAddress = m_field.GetFieldAddress(objRef, interior != 0); }