Files
sx/examples
agra 179310d62b mem: Phase 1.4a — fat-pointer aggregates from #run serialize via host memory
The Phase 1.4 serializer left a silent malformed-const case: when the
interp evaluated a `#run` returning a string (or anything with a fat
pointer inside), the data field came in as a `.int` holding a libc
host address. `LLVMConstInt(ptr_type, addr, 1)` happily emitted `i0 0`
in the static const, and the runtime segfaulted on the first read.

Phase 1.4a closes this for string and slice destinations. The signature
of `valueToLLVMConst` now takes the IR `TypeId` (instead of just the
LLVM type) and a borrowed `*Interpreter`. A new helper
`serializeAggregateValue` splits on the IR type:

- `string` / `slice` (fat pointer `{data, len}`): extract `len`, read
  that many bytes from the data field's address (via `interp.heapSlice`
  for `heap_ptr`, via a new `readHostBytes` for `byte_ptr` / `.int`,
  via slice indexing for string literals). Emit the bytes as a private
  global byte array using the existing `emitConstStringGlobal`. The
  fat-pointer aggregate's data ptr resolves to the byte array's address.
- `struct`: walk the IR field types in lockstep with the value's
  fields; recurse with each declared field TypeId. This replaces the
  old LLVM-type-walk via `LLVMStructGetTypeAtIndex` which couldn't tell
  string-typed fields from generic ptr fields.
- `array`: walk with the element TypeId.

The remaining `.int → ptr` trap (a host address landing in a bare ptr
field outside a fat pointer) now bails loudly with a named diagnostic
identifying it as Phase 1.4a heap-walk follow-up territory. No
practical trigger in-tree, so deferred.

`Interpreter.heapSlice` promoted from package-private to `pub` so
the serializer can read interp-managed heap data.

Regression: `examples/136-comptime-string-global.sx` —
`GREETING :: #run build_greeting();` where `build_greeting` returns
`concat("hello", " world")`. Runtime prints `greeting = 'hello world'`
and `greeting.len = 11`. Pre-1.4a this segfaulted on the first read.

158/158 example tests; chess clean on macOS / iOS sim / Android via
`tools/verify-step.sh`.
2026-05-25 15:45:33 +03:00
..
2026-03-06 10:46:28 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-14 13:17:22 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-09 18:07:41 +02:00
2026-02-24 15:10:02 +02:00
2026-02-24 17:37:52 +02:00
2026-02-24 15:10:02 +02:00
2026-02-11 14:22:25 +02:00
2026-02-09 18:07:41 +02:00
2026-02-24 17:37:52 +02:00
2026-02-14 13:17:22 +02:00
2026-02-09 18:07:41 +02:00
...
2026-02-11 13:03:04 +02:00
2026-02-17 16:57:12 +02:00
2026-02-17 16:57:12 +02:00
2026-02-14 14:52:39 +02:00
2026-02-24 17:37:52 +02:00
2026-02-16 01:13:34 +02:00
2026-02-24 06:20:38 +02:00
2026-02-11 01:05:21 +02:00
2026-02-22 22:16:30 +02:00
2026-02-11 20:41:43 +02:00
ir
2026-02-26 02:25:02 +02:00
2026-02-12 12:27:35 +02:00
2026-02-14 13:17:22 +02:00
2026-02-14 14:52:39 +02:00
2026-02-22 22:16:30 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-24 17:37:52 +02:00
2026-02-25 15:51:22 +02:00
sm
2026-03-02 21:00:55 +02:00
2026-03-04 17:12:56 +02:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00