frame allocs (25.2): @frame on a step list's field, @alloc_ok on a statement, and on an exported function
A field declared '@frame run: fn(...)' makes every function stored in it a frame root, as a System's
tick is. @alloc_ok("why") before a statement takes that statement out of frame_allocs and makes what
it allocates declared at run time; a function holding one keeps the fence's scope depth and puts it
back at its return, so a return inside the statement cannot leave the scope open. @alloc_ok above
'export function' was lost - export parses the declaration one call down - and is now carried to it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b35409254e
commit
1e2a6bab5b
7 changed files with 75754 additions and 74774 deletions
|
|
@ -7,6 +7,26 @@
|
|||
|
||||
var g_alloc_ok_names: []pointer = new []pointer # functions and handlers under @alloc_ok("why")
|
||||
var g_frame_fields: []pointer = new []pointer # record fields declared `@frame`
|
||||
var g_aok_nodes: []Node = new []Node # statements under @alloc_ok("why")
|
||||
var g_aok_pending: bool = false # @alloc_ok read, its function or handler not yet
|
||||
|
||||
function fr_aok_stmt(n: Node) -> bool {
|
||||
var i = 0
|
||||
while i < len(g_aok_nodes) { if g_aok_nodes[i] == n { return true }; i += 1 }
|
||||
return false
|
||||
}
|
||||
|
||||
# does this body hold a statement under @alloc_ok? (its function then keeps the scope's depth)
|
||||
function fr_has_aok(n: Node) -> bool {
|
||||
if n == null or len(g_aok_nodes) == 0 { return false }
|
||||
if fr_aok_stmt(n) { return true }
|
||||
if fr_has_aok(n.a) or fr_has_aok(n.b) or fr_has_aok(n.c) { return true }
|
||||
if n.kids != null {
|
||||
var i = 0
|
||||
while i < len(n.kids) { if fr_has_aok(n.kids[i]) { return true }; i += 1 }
|
||||
}
|
||||
return false
|
||||
}
|
||||
var g_fr_root: []bool = new []bool
|
||||
var g_fr_from: []int = new []int # the node a reached one was first reached from
|
||||
|
||||
|
|
@ -76,6 +96,7 @@ function fr_alloc_kind(n: Node, text_above: bool) -> pointer {
|
|||
# the allocating constructs in one declaration, each a falloc line with its chain
|
||||
function fr_allocs(f: pointer, n: Node, k: int, text_above: bool) -> int {
|
||||
if n == null { return 0 }
|
||||
if fr_aok_stmt(n) { return 0 }
|
||||
var found = 0
|
||||
let kind = fr_alloc_kind(n, text_above)
|
||||
if kind != null {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue