Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the CIL evaluation stack contain value types?

I'm a little confused about value types and the CIL evaluation stack. ECMA-335, Partition III, §1.1 says that the CLI deals with these "Basic CLI types":

  • A subset of the full numeric types (int32, int64, native int, and F).

  • Object references (O) without distinction between the type of object referenced.

  • Pointer types (native unsigned int and &) without distinction as to the type pointed to.

Partition II, §12.1 also provides a similar list which excludes value types, and states:

However, the CLI supports only a subset of these types in its operations upon values stored on its evaluation stack— int32 , int64 , and native int.

This makes no mention of value types other than through managed pointer types. Yet the specification for ldfld, for example, says:

The ldfld instruction pushes onto the stack the value of a field of obj. obj shall be an object (type O), a managed pointer (type &), an unmanaged pointer (type native int), or an instance of a value type.

Does this mean value types can be pushed directly on the evaluation stack (as opposed to via a managed pointer)? If so, can I assume that the value type being pushed is a memberwise copy of the original (the field value, for example)?

like image 351
Trillian Avatar asked Oct 02 '22 08:10

Trillian


1 Answers

See the introduction to III.1.1 (emphasis mine):

While the CTS defines a rich type system and the CLS specifies a subset that can be used for language interoperability, the CLI itself deals with a much simpler set of types. These types include user-defined value types and a subset of the built-in types. The subset, collectively called the “basic CLI types”, contains the following types:

like image 156
kvb Avatar answered Oct 13 '22 10:10

kvb