aboutsummaryrefslogtreecommitdiff
path: root/language
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-12-22 18:07:17 -0700
committerMelody Horn <melody@boringcactus.com>2020-12-22 18:07:17 -0700
commitf2cd937b4b6389ccc1f03c71a7d2f8df6e6089da (patch)
treed9bd735a15d0b2e2ca2987fd78600715f2d1d14a /language
parent02e06c6a20ecc68325671326f09583b3692fae3b (diff)
downloadspec-f2cd937b4b6389ccc1f03c71a7d2f8df6e6089da.tar.gz
spec-f2cd937b4b6389ccc1f03c71a7d2f8df6e6089da.zip
define basic types
Diffstat (limited to 'language')
-rw-r--r--language/types.rst32
1 files changed, 31 insertions, 1 deletions
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 <https://en.wikipedia.org/wiki/IEEE_754>`_ 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.