// There are several flavors of conversions from/to RelativePointer:
// - GetValue/SetValue: The most common version. Assumes that the pointer is not NULL.
// - GetValueMaybeNull/SetValueMaybeNull: Pointer can be NULL.
-// - GetValueAtPtr/SetValueAtPtr: Static version of GetValue/SetValue. It is
+// - GetValueAtPtr: Static version of GetValue. It is
// meant to simplify access to arrays of RelativePointers.
-// - GetValueMaybeNullAtPtr/SetValueMaybeNullAtPtr
+// - GetValueMaybeNullAtPtr
template<typename PTR_TYPE>
class RelativePointer
{
return dac_cast<DPTR(RelativePointer<PTR_TYPE>)>(base)->GetValueMaybeNull(base);
}
- // Set encoded value of the pointer. Assumes that the value is not NULL.
- void SetValue(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- PRECONDITION(addr != NULL);
- m_delta = dac_cast<TADDR>(addr) - base;
- }
-
#ifndef DACCESS_COMPILE
// Set encoded value of the pointer. Assumes that the value is not NULL.
- // Does not need explicit base and thus can be used in non-DAC builds only.
FORCEINLINE void SetValue(PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- return SetValue((TADDR)this, addr);
- }
-#endif
-
- // Static version of SetValue. It is meant to simplify access to arrays of pointers.
- FORCEINLINE static void SetValueAtPtr(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- dac_cast<DPTR(RelativePointer<PTR_TYPE>)>(base)->SetValue(base, addr);
+ PRECONDITION(addr != NULL);
+ m_delta = (TADDR)addr - (TADDR)this;
}
// Set encoded value of the pointer. The value can be NULL.
void SetValueMaybeNull(TADDR base, PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- if (addr == NULL) m_delta = NULL; else SetValue(base, addr);
+ if (addr == NULL)
+ m_delta = NULL;
+ else
+ m_delta = (TADDR)addr - (TADDR)base;
}
-#ifndef DACCESS_COMPILE
// Set encoded value of the pointer. The value can be NULL.
- // Does not need explicit base and thus can be used in non-DAC builds only.
FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- return SetValueMaybeNull((TADDR)this, addr);
+ SetValueMaybeNull((TADDR)this, addr);
}
#endif
- // Static version of SetValueMaybeNull. It is meant to simplify access to arrays of pointers.
- FORCEINLINE static void SetValueMaybeNullAtPtr(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- dac_cast<DPTR(RelativePointer<PTR_TYPE>)>(base)->SetValueMaybeNull(base, addr);
- }
-
#ifndef DACCESS_COMPILE
void BitwiseCopyTo(RelativePointer<PTR_TYPE> &dest) const
{
return dac_cast<DPTR(RelativeFixupPointer<PTR_TYPE>)>(base)->GetValueMaybeNull(base);
}
- // Set encoded value of the pointer. Assumes that the value is not NULL.
- void SetValue(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- PRECONDITION(addr != NULL);
- m_delta = dac_cast<TADDR>(addr) - base;
- }
-
#ifndef DACCESS_COMPILE
// Set encoded value of the pointer. Assumes that the value is not NULL.
- // Does not need explicit base and thus can be used in non-DAC builds only.
FORCEINLINE void SetValue(PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- return SetValue((TADDR)this, addr);
- }
-#endif
-
- // Static version of SetValue. It is meant to simplify access to arrays of pointers.
- FORCEINLINE static void SetValueAtPtr(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- dac_cast<DPTR(RelativeFixupPointer<PTR_TYPE>)>(base)->SetValue(base, addr);
+ PRECONDITION(addr != NULL);
+ m_delta = (TADDR)addr - (TADDR)this;
}
// Set encoded value of the pointer. The value can be NULL.
void SetValueMaybeNull(TADDR base, PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- if (addr == NULL) m_delta = NULL; else SetValue(base, addr);
+ if (addr == NULL)
+ m_delta = NULL;
+ else
+ m_delta = (TADDR)addr - (TADDR)base;
}
-#ifndef DACCESS_COMPILE
// Set encoded value of the pointer. The value can be NULL.
- // Does not need explicit base and thus can be used in non-DAC builds only.
FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- return SetValueMaybeNull((TADDR)this, addr);
+ SetValueMaybeNull((TADDR)this, addr);
}
#endif
- // Static version of SetValueMaybeNull. It is meant to simplify access to arrays of pointers.
- FORCEINLINE static void SetValueMaybeNullAtPtr(TADDR base, PTR_TYPE addr)
- {
- LIMITED_METHOD_CONTRACT;
- dac_cast<DPTR(RelativeFixupPointer<PTR_TYPE>)>(base)->SetValueMaybeNull(base, addr);
- }
-
// Returns the pointer to the indirection cell.
PTR_TYPE * GetValuePtr(TADDR base) const
{
struct LookupMap : LookupMapBase
{
static TYPE GetValueAt(PTR_TADDR pValue, TADDR* pFlags, TADDR supportedFlags);
+
+#ifndef DACCESS_COMPILE
static void SetValueAt(PTR_TADDR pValue, TYPE value, TADDR flags);
+#endif // DACCESS_COMPILE
TYPE GetElement(DWORD rid, TADDR* pFlags);
void SetElement(DWORD rid, TYPE value, TADDR flags);
SetElement(rid, value, flags);
}
+#ifndef DACCESS_COMPILE
void AddFlag(DWORD rid, TADDR flag)
{
WRAPPER_NO_CONTRACT;
TYPE existingValue = GetValueAt(pElement, &existingFlags, supportedFlags);
SetValueAt(pElement, existingValue, existingFlags | flag);
}
+#endif // DACCESS_COMPILE
//
// Try to store an association in a map. Will never throw or fail.