Skip to content

Latest commit

 

History

History
39 lines (21 loc) · 1.69 KB

iii.4.7-ldelem.md

File metadata and controls

39 lines (21 loc) · 1.69 KB

III.4.7 ldelem – load element from array

Format Assembly Format Description
A3 <T> ldelem typeTok Load the element at index onto the top of the stack.

Stack Transition:

…, array, index → …, value

Description:

The ldelem instruction loads the value of the element with index index (of type native int or int32) in the zero-based one-dimensional array array, and places it on the top of the stack. The type of the return value is indicated by the type token typeTok in the instruction. If required elements are converted to the representation of their intermediate typeI.8.7) when loaded onto the stack (§III.1.1.1).

[Note: that is elements that are smaller than 4 bytes, a boolean or a character are converted to 4 bytes by sign or zero-extension as appropriate. Floating-point values are converted to their native size (type F). end note]

Exceptions:

System.IndexOutOfRangeException is thrown if index is larger than the bound of array.

System.NullReferenceException is thrown if array is null.

Correctness:

typeTok shall be a valid typedef, typeref, or typespec metadata token.

array shall be either null or a single dimensional, zero-based array.

Verifiability:

Verification requires that:

  • the tracked type of array is T[], for some T;

  • T is array-element-compatible-withI.8.7.1) typeTok; and

  • the type of index is int32 or native int.

Verification tracks the type of the result value as typeTok.