wip(0.S3): packages and examples migrated again from their pre-0.S sources in one run
ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5ffe50ed02
commit
19fcf60599
459 changed files with 17862 additions and 17603 deletions
|
|
@ -6,53 +6,56 @@ export property Queue<T> {
|
|||
}
|
||||
|
||||
# every named queue's pending count, so a frame's end can say which facts nobody read
|
||||
var qb_names: []string = null
|
||||
var qb_pending: []int = null
|
||||
export state BaseState {
|
||||
qb_names: []string = null
|
||||
qb_pending: []int = null
|
||||
cs_list: []System = null
|
||||
}
|
||||
|
||||
function qb_init() -> void {
|
||||
if qb_names != null { return }
|
||||
qb_names = new []string
|
||||
qb_pending = new []int
|
||||
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
|
||||
}
|
||||
|
||||
# a queue; the name is only for core_undrained
|
||||
export function queue_new<T>(name: string) -> Queue<T> {
|
||||
qb_init()
|
||||
export function queue_new<T>(base_st: mut BaseState, name: string) -> Queue<T> {
|
||||
qb_init(base_st)
|
||||
let q = new Queue<T>
|
||||
q.items = new []T
|
||||
q.id = len(qb_names)
|
||||
push(qb_names, name)
|
||||
push(qb_pending, 0)
|
||||
q.id = len(base_st.qb_names)
|
||||
push(base_st.qb_names, name)
|
||||
push(base_st.qb_pending, 0)
|
||||
return q
|
||||
}
|
||||
|
||||
export function q_push<T>(q: Queue<T>, v: T) -> void {
|
||||
export function q_push<T>(base_st: mut BaseState, q: Queue<T>, v: T) -> void {
|
||||
push(q.items, v)
|
||||
qb_pending[q.id] = len(q.items)
|
||||
base_st.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>(q: Queue<T>) -> []T {
|
||||
export function q_drain<T>(base_st: mut BaseState, q: Queue<T>) -> []T {
|
||||
let out = q.items
|
||||
q.items = new []T
|
||||
qb_pending[q.id] = 0
|
||||
base_st.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>(q: Queue<T>) -> void {
|
||||
export function q_clear<T>(base_st: mut BaseState, q: Queue<T>) -> void {
|
||||
q.items = new []T
|
||||
qb_pending[q.id] = 0
|
||||
base_st.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() -> []string {
|
||||
qb_init()
|
||||
export function core_undrained(base_st: mut BaseState) -> []string {
|
||||
qb_init(base_st)
|
||||
let out = new []string
|
||||
for i in 0 .. len(qb_names) {
|
||||
if qb_pending[i] > 0 { push(out, qb_names[i]) }
|
||||
for i in 0 .. len(base_st.qb_names) {
|
||||
if base_st.qb_pending[i] > 0 { push(out, base_st.qb_names[i]) }
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue