sdl phase 2
This commit is contained in:
18
specs.md
18
specs.md
@@ -286,8 +286,26 @@ val := mp[2]; // 30
|
||||
|
||||
**Implicit conversions**:
|
||||
- `*T` → `[*]T` (pointer to element → many-pointer)
|
||||
- `*[N]T` → `[*]T` (pointer to array → many-pointer)
|
||||
- `[N]T` → `[*]T` at call sites (array decays to many-pointer)
|
||||
- `[]T` → `[*]T` (slice decays to many-pointer, extracts `.ptr`)
|
||||
- `T` → `*T` at call sites (implicit address-of)
|
||||
- `null` (`*void`) → any `*T`
|
||||
|
||||
**Fat pointer layout**: `[:0]u8`, `string`, and `[]T` are `{ptr, i64}` structs. The raw pointer is always the first field at offset 0. This means `*[:0]u8` works as C's `char**` — a C function dereferences through the outer pointer and reads the raw `char*` from offset 0.
|
||||
|
||||
### C Interop Type Mapping
|
||||
|
||||
| C type | sx type | Notes |
|
||||
|--------|---------|-------|
|
||||
| `const char*` (input) | `[:0]u8` | compiler extracts `.ptr` at call site |
|
||||
| `char*` (output buffer) | `[*]u8` | raw buffer, no length |
|
||||
| `const char**` | `*[:0]u8` | address of `[:0]u8` — `.ptr` at offset 0 |
|
||||
| `int*` (single out) | `*s32` | |
|
||||
| `unsigned*` (single out) | `*u32` | |
|
||||
| `float*` (buffer) | `[*]f32` | |
|
||||
| `void*` (generic) | `*void` | only for truly opaque/generic data |
|
||||
|
||||
### Vector Types (SIMD)
|
||||
LLVM SIMD vectors, parameterized by length and element type.
|
||||
```sx
|
||||
|
||||
Reference in New Issue
Block a user