Phase 8.2.4: Slice fat pointer + bounds checking

- T[] slices are now fat pointers {data: T*, len: size_t} in C backend
- Added hSliceIndex HIR node for slice indexing (distinct from hIndexPtr for raw pointers)
- Added exprIndexBoundsCheck flag to AST ekIndex
- Sema sets bounds-check flag in @[Checked] functions
- C backend emits Slice_<T> typedefs and compound literals for slice init
- bux_bounds_check() called automatically on slice indexing in @[Checked] funcs
- Unchecked functions allow raw access (C behavior) for performance
This commit is contained in:
2026-06-01 11:50:45 +03:00
parent bf9e73d56e
commit cefd2a8442
6 changed files with 85 additions and 24 deletions
+6
View File
@@ -24,6 +24,7 @@ type
hFieldPtr
hArrowField
hIndexPtr
hSliceIndex
# Functions
hCall
hCallIndirect
@@ -136,6 +137,11 @@ type
structInitFields*: seq[tuple[name: string, value: HirNode]]
of hSliceInit:
sliceInitElements*: seq[HirNode]
sliceInitLen*: int
of hSliceIndex:
sliceIndexBase*: HirNode
sliceIndexIndex*: HirNode
sliceIndexBoundsCheck*: bool
of hRange:
rangeLo*: HirNode
rangeHi*: HirNode