Object handling



      box      box_ptr      bread_field      bwrite_field
      castclass      castinterface      cknull      cknull_n
      get_static      iread_field      iread_this      isinst
      isinterface      iwrite_field      mkrefany      new
      new_value      pread_field      pread_this      pwrite_field
      refanytype      refanyval      sread_field      swrite_field
      thread_static      ubread_field      usread_field 


 box 
  ·  OperationBox a value type instance
  ·  Format
box
N[1]
class
wide
box
N[4]
class
  ·  Direct Format
{box}
N
class
  ·  Forms box = 235 (0xEB)
  ·  Stack..., value => ..., object
   · Description Pop the managed value from the stack. The size of value is N stack words. Allocate a new object instance of class, copy value into it, and then push object onto the stack.
   · Notes The class value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

There is no unbox instruction. The object layout is defined so that an object reference can also be used as a managed pointer to the contents of the object.

   · Exceptions System.OutOfMemoryException -- Raised if there is insufficient memory to allocate the new object.


 box_ptr 
  ·  OperationBox a value type instance at a pointer
  ·  Format
box_ptr
N[1]
class
wide
box_ptr
N[4]
class
  ·  Direct Format
{box_ptr}
N
class
  ·  Forms box_ptr = 236 (0xEC)
  ·  Stack..., pointer => ..., object
   · Description Pop pointer from the stack as type ptr. Allocate a new object of N bytes in size as an instance of class. Copy the N bytes of memory from pointer to the object. Push object onto the stack.
   · Notes The class value is a native pointer to the class descriptor, which may 32 or 64 bits in size.
   · Exceptions System.OutOfMemoryException -- Raised if there is insufficient memory to allocate the new object.


 bread_field 
  ·  OperationRead int8 field
  ·  Format
bread_field
N[1]
  ·  Direct Format
{bread_field}
N
  ·  Forms bread_field = 194 (0xC2)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the 8 bit value at object + N, sign-extend it to int32, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, bread.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 bwrite_field 
  ·  OperationWrite int8 field
  ·  Format
bwrite_field
N[1]
  ·  Direct Format
{bwrite_field}
N
  ·  Forms bwrite_field = 200 (0xC8)
  ·  Stack..., object, value => ...
   · Description Pop object and value from the stack as the types ptr and int32 respectively. Truncate value to 8 bits and store it at object + N.
   · Notes If the offset N is greater than 255, then use the sequence cknull_n 1, padd_offset_n 1 N, bwrite.

This instruction can also be used to write values of type uint8.

   · Exceptions System.NullReferenceException -- Raised if object is null.


 castclass 
  ·  OperationCast an object to a new class
  ·  Format
castclass
class
  ·  Direct Format
{castclass}
class
  ·  Forms castclass = 226 (0xE2)
  ·  Stack..., object => ..., object
   · Description Inspect the object on the top of the stack. If object is null or its class inherits from class, execution continues with the next instruction. Otherwise, System.InvalidCastException is thrown.
   · Notes The class value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

This instruction can only be used to test for normal inheritance. Use castinterface to cast objects to interfaces.

   · Exceptions System.InvalidCastException -- Raised if object's class does not inherit from class.


 castinterface 
  ·  OperationCast an object to a new interface
  ·  Format
castinterface
interface
  ·  Direct Format
{castinterface}
interface
  ·  Forms castinterface = 228 (0xE4)
  ·  Stack..., object => ..., object
   · Description Inspect the object on the top of the stack. If object is null or its class implements interface, execution continues with the next instruction. Otherwise, System.InvalidCastException is thrown.
   · Notes The interface value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

This instruction can only be used to test for interface inheritance. Use castclass to cast objects to parent classes.

   · Exceptions System.InvalidCastException -- Raised if object's class does not implement interface.


 cknull 
  ·  OperationCheck pointer for null
  ·  Format
cknull
  ·  Direct Format
{cknull}
  ·  Forms cknull = 142 (0x8E)
  ·  Stack..., pointer => ..., pointer
   · Description Throw System.NullReferenceException if the ptr value on the top of the stack is null. Otherwise do nothing.


 cknull_n 
  ·  OperationCheck pointer down the stack for null
  ·  Format
cknull_n
N[1]
wide
cknull_n
N[4]
  ·  Direct Format
{cknull_n}
N
  ·  Forms cknull_n = 143 (0x8F)
  ·  Stack..., pointer, val1, ..., valN => ..., pointer, val1, ..., valN
   · Description Throw System.NullReferenceException if the ptr value N words down the stack is null. Otherwise do nothing. N == 0 indicates the top of the stack.
   · Notes The cknull instruction is more efficient if N == 0.


 get_static 
  ·  OperationGet a pointer to the static data area of a class
  ·  Format
get_static
class
  ·  Direct Format
{get_static}
class
  ·  Forms get_static = 230 (0xE6)
  ·  Stack... => ..., pointer
   · Description If class currently has a static data area, then push the data area's pointer onto the stack. Otherwise, allocate a new static data area for class and push it onto the stack.
   · Notes The class value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

This instruction is used in combination with the *read and *write instructions to access static fields within a class.

   · Exceptions System.OutOfMemoryException -- Raised if there is insufficient memory to allocate the static data area.


 iread_field 
  ·  OperationRead int32 field
  ·  Format
iread_field
N[1]
  ·  Direct Format
{iread_field}
N
  ·  Forms iread_field = 198 (0xC6)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the int32 value at object + N, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, iread.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 iread_this 
  ·  OperationRead int32 field from this
  ·  Format
iread_this
N[1]
  ·  Direct Format
{iread_this}
N
  ·  Forms iread_this = 205 (0xCD)
  ·  Stack... => ..., value
   · Description Retrieve offset 0 from the frame as object, of type ptr. Fetch the int32 value at object + N, and push it onto the stack.
   · Notes This instruction is used to optimise the sequence pload_0, iread_field N.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 isinst 
  ·  OperationDetermine if an object is an instance of a class
  ·  Format
isinst
class
  ·  Direct Format
{isinst}
class
  ·  Forms isinst = 227 (0xE3)
  ·  Stack..., object => ..., newobject
   · Description Pop object from the stack as type ptr. If object is null or its class inherits from class, then set newobject to object. Otherwise, set newobject to null. Push newobject onto the stack.
   · Notes The class value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

This instruction can only be used to test for normal inheritance. Use isinterface to test for interface membership.



 isinterface 
  ·  OperationDetermine if an object is an instance of an interface
  ·  Format
isinterface
interface
  ·  Direct Format
{isinterface}
interface
  ·  Forms isinterface = 229 (0xE5)
  ·  Stack..., object => ..., newobject
   · Description Pop object from the stack as type ptr. If object is null or its class implements interface, then set newobject to object. Otherwise, set newobject to null. Push newobject onto the stack.
   · Notes The interface value is a native pointer to the class descriptor, which may 32 or 64 bits in size.

This instruction can only be used to test for interface inheritance. Use isinst to test for normal inheritance.



 iwrite_field 
  ·  OperationWrite int32 field
  ·  Format
iwrite_field
N[1]
  ·  Direct Format
{iwrite_field}
N
  ·  Forms iwrite_field = 202 (0xCA)
  ·  Stack..., object, value => ...
   · Description Pop object and value from the stack as the types ptr and int32 respectively. Store value at object + N.
   · Notes If the offset N is greater than 255, then use the sequence cknull_n 1, padd_offset_n 1 N, iwrite.

This instruction can also be used to write values of type uint32.

   · Exceptions System.NullReferenceException -- Raised if object is null.


 mkrefany 
  ·  OperationMake a typedref
  ·  Format
prefix
mkrefany
class
  ·  Direct Format
{mkrefany}
class
  ·  Forms mkrefany = 255, 34 (0xFF, 0x22)
  ·  Stack..., pointer => ..., reference
   · Description Pop pointer from the stack as type ptr. Make a typedref reference from pointer and class. Push reference onto the stack.
   · Notes The class is a native pointer, which may be either 32 or 64 bits in size, depending upon the platform.


 new 
  ·  OperationAllocate an instance of the current class
  ·  Format
new
  ·  Direct Format
{new}
  ·  Forms new = 231 (0xE7)
  ·  Stack... => ..., pointer
   · Description Allocates an instance of the class associated with the currently executing method, and pushes a pointer to this instance onto the stack.
   · Notes This instruction is used inside constructors to allocate memory for a new object. The fields of the new object are initialized to zero.
   · Exceptions System.OutOfMemoryException -- Raised if there is insufficient memory to allocate the object.


 new_value 
  ·  OperationAllocate a new value type instance and push it down
  ·  Format
new_value
N[1]
M[1]
wide
new_value
N[4]
M[4]
  ·  Direct Format
{new_value}
N
M
  ·  Forms new_value = 232 (0xE8)
  ·  Stack..., val1, ..., valN => ..., value, pointer, val1, ..., valN
   · Description Creates a new value type instance of M stack words in size and places it, and a pointer to it, N positions down the stack. The fields of the new instance are initialized to zero. N == 0 to place the new instance at the top of the stack.
   · Notes This instruction is used inside value type constructors to insert the return value and the this pointer into the stack prior to running the main constructor code.


 pread_field 
  ·  OperationRead ptr field
  ·  Format
pread_field
N[1]
  ·  Direct Format
{pread_field}
N
  ·  Forms pread_field = 199 (0xC7)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the ptr value at object + N, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, pread.

This instruction must not be confused with iread_field. Values of type int32 and ptr do not necessarily occupy the same amount of memory space on all platforms.

   · Exceptions System.NullReferenceException -- Raised if object is null.


 pread_this 
  ·  OperationRead ptr field from this
  ·  Format
pread_this
N[1]
  ·  Direct Format
{pread_this}
N
  ·  Forms pread_this = 204 (0xCC)
  ·  Stack... => ..., value
   · Description Retrieve offset 0 from the frame as object, of type ptr. Fetch the ptr value at object + N, and push it onto the stack.
   · Notes This instruction is used to optimise the sequence pload_0, pread_field N.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 pwrite_field 
  ·  OperationWrite int32 field
  ·  Format
pwrite_field
N[1]
  ·  Direct Format
{pwrite_field}
N
  ·  Forms pwrite_field = 203 (0xCB)
  ·  Stack..., object, value => ...
   · Description Pop object and value from the stack as type ptr. Store value at object + N.
   · Notes If the offset N is greater than 255, then use the sequence cknull_n 1, padd_offset_n 1 N, pwrite.

This instruction must not be confused with iwrite_field. Values of type int32 and ptr do not necessarily occupy the same amount of memory space on all platforms.

   · Exceptions System.NullReferenceException -- Raised if object is null.


 refanytype 
  ·  OperationExtract the type from a typedref
  ·  Format
prefix
refanytype
  ·  Direct Format
{refanytype}
  ·  Forms refanytype = 255, 36 (0xFF, 0x24)
  ·  Stack..., reference => ..., type
   · Description Pop reference from the stack as type typedref. Extract the type from reference and push it onto the stack.


 refanyval 
  ·  OperationExtract the value from a typedref
  ·  Format
prefix
refanyval
class
  ·  Direct Format
{refanyval}
class
  ·  Forms refanyval = 255, 35 (0xFF, 0x23)
  ·  Stack..., reference => ..., pointer
   · Description Pop reference from the stack as type typedref. If reference refers to an instance of class, then extract the pointer from the reference and push it onto the stack. Otherwise, throw System.InvalidCastException.
   · Notes The class is a native pointer, which may be either 32 or 64 bits in size, depending upon the platform.
   · Exceptions System.InvalidCastException -- Raised if reference does not refer to an instance of class.


 sread_field 
  ·  OperationRead int16 field
  ·  Format
sread_field
N[1]
  ·  Direct Format
{sread_field}
N
  ·  Forms sread_field = 196 (0xC4)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the 16 bit value at object + N, sign-extend it to int32, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, sread.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 swrite_field 
  ·  OperationWrite int16 field
  ·  Format
swrite_field
N[1]
  ·  Direct Format
{swrite_field}
N
  ·  Forms swrite_field = 201 (0xC9)
  ·  Stack..., object, value => ...
   · Description Pop object and value from the stack as the types ptr and int32 respectively. Truncate value to 16 bits and store it at object + N.
   · Notes If the offset N is greater than 255, then use the sequence cknull_n 1, padd_offset_n 1 N, swrite.

This instruction can also be used to write values of type uint16.

   · Exceptions System.NullReferenceException -- Raised if object is null.


 thread_static 
  ·  OperationGet a pointer to the thread-static data area
  ·  Format
prefix
thread_static
slot[4]
size[4]
  ·  Direct Format
{thread_static}
slot
size
  ·  Forms thread_static = 255, 94 (0xFF, 0x5E)
  ·  Stack... => ..., ptr
   · Description Push a pointer to the current thread's static data area onto the stack. The value slot indicates which slot to retrieve the pointer from. The value size indicates the size of the data object if the slot is currently empty.


 ubread_field 
  ·  OperationRead uint8 field
  ·  Format
ubread_field
N[1]
  ·  Direct Format
{ubread_field}
N
  ·  Forms ubread_field = 195 (0xC3)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the 8 bit value at object + N, zero-extend it to int32, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, ubread.
   · Exceptions System.NullReferenceException -- Raised if object is null.


 usread_field 
  ·  OperationRead uint16 field
  ·  Format
usread_field
N[1]
  ·  Direct Format
{usread_field}
N
  ·  Forms usread_field = 197 (0xC5)
  ·  Stack..., object => ..., value
   · Description Pop object from the stack as type ptr. Fetch the 16 bit value at object + N, zero-extend it to int32, and push it onto the stack.
   · Notes If the offset N is greater than 255, then use the sequence cknull, ldc_i4 N, padd_i4, usread.
   · Exceptions System.NullReferenceException -- Raised if object is null.


Copyright © Southern Storm Software Pty Ltd 2002
Licensed under GNU FDL