Skip to content

TypeSig

Raymond Chen edited this page May 3, 2019 · 5 revisions

A xmr::TypeSig structure represents a type.

Types

value_type

using value_type =
    std::variant<xmr::ElementType,                     // index 0
                 xmr::coded_index<xmr::TypeDefOrRef>,  // index 1
                 xmr::GenericTypeIndex,                // index 2
                 xmr::GenericTypeInstSig,              // index 3
                 xmr::GenericMethodTypeIndex>;         // index 4

The TypeSig::value_type represents the possible values of the Type().

  • ElementType is used if the type is a predefined type like System.Int32 or System.String.
  • coded_index<TypeDefOrRef> is used if the type is a user-defined type.
  • GenericTypeIndex is used to refer to a generic type parameter of the enclosing type. For example, the IMap<K, V>.Insert method would use GenericTypeIndex(0) to refer to K and GenericTypeIndex(1) to refer to V.
  • GenericTypeInstSig is used if the type is an instantiation of a generic type.
  • GenericMethodTypeIndex is used to refer to a generic type parameter of the enclosing method. For example, the Widget::GetValueOrDefault<T>(T defaultValue) method would use GenericMethodTypeIndex(0) to refer to T. (Not used by xlang.)

Type()

TypeSig::value_type const& Type() const noexcept;

Returns information that identifies the type. See value_type above for details.

Complexity: O(1)

element_type

xmr::ElementType element_type() const noexcept;

Returns the type category of the type.

Complexity: O(1)

is_szarray

bool is_szarray() const noexcept;

Indicates whether the type is a single-dimensional zero-based array. If true, then the type reported by the TypeSig represents the underlying type of the array (in other words, the type of a single element of the array).

Complexity: O(1).

Clone this wiki locally