You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/rfcs/0002-knums.md
+62-6Lines changed: 62 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,7 +232,7 @@ Prior to the body, one or more attributes may be specified. Attributes are of th
232
232
233
233
The following attributes are currently recognized:
234
234
*`align(N)`, `N` must an expression of type `ulong`, and must be a power of two. Indicates that the type requires alignment to at least `N` bytes.
235
-
*`option(ID)`. Inserts a field at the start of the structure type `ExtendedOptionHead` (The file `types::option` must be `use`d to use this struct attribute), and provides sufficient definitions. Must appear on a `struct`.
235
+
*`option(ID)`. Inserts a field at the start of the structure type `ExtendedOptionHead`, and provides sufficient definitions. Must appear on a `struct`. Both `types::option`and `types::uuid`must be `use`d to use this attribute,
236
236
*`option_head(N)`: Must appear on a `union`. Inserts a field of an unnamed struct type, containing a field of type `ExtendedOptionHead` (the file `types::option` must be `use`d to use this attribute), and a field of type `[byte; N]`.
237
237
238
238
#### `type` items
@@ -310,10 +310,6 @@ A UUID literal starts with `U` and is immediately followed by a braced UUID. Das
310
310
311
311
A `const` item in scope may be named by an expression. The value of the expression is the value of the const. The const value is evaluated before being substituted - in particular, the substituted expression is not reparsed.
312
312
313
-
Special constant values are always in scope:
314
-
*`__LILIUM_SIZEOF_POINTER__` is defined to be the number of bytes in a pointer, a power of 2 that is at least 4
315
-
* Constants that begin with `__LILIUM` are reserved for future definitions.
316
-
317
313
#### Unary Operator Expressions
318
314
319
315
Unary Operators may prefix an expression with an integer type. `-` is a value-wise negation of the value mod 2^N. `!` is a bitwise negation. `+` is an identity operation.
@@ -340,7 +336,67 @@ Parenthesis may surround an expression. This provides explicit grouping for the
340
336
341
337
### Standard Types
342
338
343
-
The following modules are
339
+
The following modules are predefined:
340
+
*`types::int`
341
+
*`types::hdl`
342
+
*`types::option`
343
+
*`types::uuid`
344
+
*`types`
345
+
346
+
Other than the `types` module, which simply acts as if it contains `inline use` declarations for each of the preceeding, we define the contents of each of the modules below
347
+
348
+
#### `types::int`
349
+
350
+
The `types::int` module contains the following definitions. Additionally, any knums module that refers to an integer type must (potentially-indirectly) contain the declaration `use types::int;`.
`__LILIUM_SIZEOF_POINTER__` is defined to be equal to the number of bytes in a pointer.
357
+
358
+
#### `types::hdl`
359
+
360
+
The `types::hdl` module contains the following definitions. Additionally, any knums module that refers to `*handle T` or `*shared_handle T` must (potentially-indirectly) contain the declaration `use types::hdl;`
361
+
362
+
```
363
+
use types::int; // Required for __LILIUM_SIZEOF_POINTER__ below
364
+
/// Base type of all handles in Lilium
365
+
struct Handle : opaque;
366
+
367
+
/// Handle Pointer that contains 16 bytes. A non-null pointer is guaranteed not to overlap in bit representation with a `Uuid`
The `types::option` module contains the following definitions. Additionally, any knums module that uses the `option` or `option_head` struct attributes must (potentially-indirectly) contain the declaration `use types::option`.
377
+
378
+
```
379
+
use types::int;
380
+
use types::uuid;
381
+
382
+
struct ExtendedOptionHead {
383
+
id: Uuid,
384
+
flags: u32,
385
+
pad([u32; 3])
386
+
}
387
+
```
388
+
389
+
#### `types::uuid`
390
+
391
+
The `types::uuid` module contains the following definitions. Additionally, any knums module that uses the `option` struct attribute or a UUID literal must (potentially-indirectly) contain the declaration `use types::uuid`.
0 commit comments