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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user