wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 15:31:34 +03:00
parent 3eda72e8c2
commit 5ffe50ed02
463 changed files with 72045 additions and 67421 deletions

View file

@ -6,56 +6,53 @@ export property Queue<T> {
}
# every named queue's pending count, so a frame's end can say which facts nobody read
export state BaseState {
qb_names: []string = null
qb_pending: []int = null
cs_list: []System = null
}
var qb_names: []string = null
var qb_pending: []int = null
function qb_init(base_st: mut BaseState) -> void {
if base_st.qb_names != null { return }
base_st.qb_names = new []string
base_st.qb_pending = new []int
function qb_init() -> void {
if qb_names != null { return }
qb_names = new []string
qb_pending = new []int
}
# a queue; the name is only for core_undrained
export function queue_new<T>(base_st: mut BaseState, name: string) -> Queue<T> {
qb_init(base_st)
export function queue_new<T>(name: string) -> Queue<T> {
qb_init()
let q = new Queue<T>
q.items = new []T
q.id = len(base_st.qb_names)
push(base_st.qb_names, name)
push(base_st.qb_pending, 0)
q.id = len(qb_names)
push(qb_names, name)
push(qb_pending, 0)
return q
}
export function q_push<T>(base_st: mut BaseState, q: Queue<T>, v: T) -> void {
export function q_push<T>(q: Queue<T>, v: T) -> void {
push(q.items, v)
base_st.qb_pending[q.id] = len(q.items)
qb_pending[q.id] = len(q.items)
}
# the facts in the order they were pushed; the queue is empty afterwards
export function q_drain<T>(base_st: mut BaseState, q: Queue<T>) -> []T {
export function q_drain<T>(q: Queue<T>) -> []T {
let out = q.items
q.items = new []T
base_st.qb_pending[q.id] = 0
qb_pending[q.id] = 0
return out
}
export function q_len<T>(q: Queue<T>) -> int { return len(q.items) }
export function q_clear<T>(base_st: mut BaseState, q: Queue<T>) -> void {
export function q_clear<T>(q: Queue<T>) -> void {
q.items = new []T
base_st.qb_pending[q.id] = 0
qb_pending[q.id] = 0
}
# the names of the queues still holding facts; call it at the end of a frame, where a fact
# left behind is a route nobody wrote
export function core_undrained(base_st: mut BaseState) -> []string {
qb_init(base_st)
export function core_undrained() -> []string {
qb_init()
let out = new []string
for i in 0 .. len(base_st.qb_names) {
if base_st.qb_pending[i] > 0 { push(out, base_st.qb_names[i]) }
for i in 0 .. len(qb_names) {
if qb_pending[i] > 0 { push(out, qb_names[i]) }
}
return out
}