Format | Assembly Format | Description |
---|---|---|
C6 <T> | mkrefany class |
Push a typed reference to ptr of type class onto the stack. |
…, ptr → …, typedRef
The mkrefany
instruction supports the passing of dynamically typed references. ptr shall be a pointer (type &
, or native int
) that holds the address of a piece of data. class is the class token (a typeref
, typedef
or typespec
; see Partition II) describing the type of ptr. mkrefany
pushes a typed reference on the stack, that is an opaque descriptor of ptr and class. This instruction enables the passing of dynamically typed references as arguments. The callee can use the refanytype
and refanyval
instructions to retrieve the type (class) and address (ptr) respectively of the parameter.
System.TypeLoadException
is thrown if class cannot be found. This is typically detected when CIL is converted to native code rather than at runtime.
Correct CIL ensures that class is a valid typeref
or typedef
or typespec
token describing some type and that ptr is a pointer to exactly that type.
Verification additionally requires that ptr be a managed pointer. Verification will fail if it cannot deduce that ptr is a pointer to an instance of class.