From f2cd937b4b6389ccc1f03c71a7d2f8df6e6089da Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Tue, 22 Dec 2020 18:07:17 -0700 Subject: define basic types --- language/types.rst | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/language/types.rst b/language/types.rst index 0a38239..e9681d9 100644 --- a/language/types.rst +++ b/language/types.rst @@ -12,6 +12,36 @@ Types .. crowbar:element:: FunctionType <- BasicType 'function' '(' FunctionTypeArgs? ')' FunctionTypeArgs <- BasicType (',' BasicType)* ','? -.. crowbar:element:: BasicType <- 'void' / 'bool' / 'float32' / 'float64' / 'int8' / 'int16' / 'int32' / 'int64' / 'intaddr' / 'intmax' / 'intsize' / 'uint8' / 'uint16' / 'uint32' / 'uint64' / 'uintaddr' / 'uintmax' / 'uintsize' / 'struct' identifier / 'enum' identifier / 'union' identifier / '(' Type ')' .. todo:: define like any of these + +.. crowbar:element:: BasicType <- 'void' / 'bool' / 'float32' / 'float64' / 'int8' / 'int16' / 'int32' / 'int64' / 'intaddr' / 'intmax' / 'intsize' / 'uint8' / 'uint16' / 'uint32' / 'uint64' / 'uintaddr' / 'uintmax' / 'uintsize' / 'struct' identifier / 'enum' identifier / 'union' identifier / '(' Type ')' + + ``void`` denotes the empty type. + + ``bool`` denotes the Boolean type, with two values: ``true`` and ``false``, represented as 1 and 0, respectively. + + ``float32`` and ``float64`` denote the binary32 and binary64 `IEEE 754 floating-point `_ types, respectively. + + ``int8``, ``int16``, ``int32``, and ``int64`` denote signed, two's-complement integers with sizes 8 bits, 16 bits, 32 bits, and 64 bits, respectively. + + ``uint8``, ``uint16``, ``uint32``, and ``uint64`` denote unsigned integers with sizes 8 bits, 16 bits, 32 bits, and 64 bits, respectively. + + ``intmax`` is a synonym for the largest signed integer type supported by the compiler. + + ``uintmax`` is a synonym for the largest unsigned integer type supported by the compiler. + + ``uintaddr`` is a synonym for an unsigned integer type large enough to hold any memory address valid on the compilation target; the specific type is implementation defined. + + ``intaddr`` is a synonym for a signed integer type at least as large as ``uintaddr``. + + ``uintsize`` is a synonym for an unsigned integer type large enough to hold any number of bytes which may be contiguously allocated on the compilation target; the specific type is implementation defined. + + ``intsize`` is a synonym for a signed integer type at least as large as ``uintsize``. + + ``struct``, ``enum``, or ``union`` followed by an identifier denotes the type with the given nature and name, which should be available in the compilation context when used. + + Enclosing a :crowbar:ref:`Type` in parentheses does not have semantic significance, but allows for syntactic disambiguation of constructs that would otherwise be visually ambiguous. + + Multi-byte integer types should be represented as either big endian or little endian based on the preference of the compilation target platform, i.e. endianness is implementation defined. + Compilers targeting less-than-64-bit CPUs *may* omit support for some explicitly sized basic types, but *it would be nice* if they provided software support for types not supported in hardware. -- cgit v1.2.3