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:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -2,24 +2,22 @@
|
|||
module toy_pack uses ludic_base
|
||||
numbers float
|
||||
import "ludic.base"
|
||||
export state ToyPackState {
|
||||
counts: []int = null
|
||||
var counts: []int = null
|
||||
export function pack_add(kind: int, n: int) -> void { counts[kind] = counts[kind] + n }
|
||||
export function pack_count(kind: int) -> int { return counts[kind] }
|
||||
function pack_reset() -> void {
|
||||
counts = new []int
|
||||
for i in 0 .. 3 { push(counts, 0) }
|
||||
}
|
||||
export function pack_add(toy_pack_st: mut ToyPackState, kind: int, n: int) -> void { toy_pack_st.counts[kind] = toy_pack_st.counts[kind] + n }
|
||||
export function pack_count(toy_pack_st: ToyPackState, kind: int) -> int { return toy_pack_st.counts[kind] }
|
||||
function pack_reset(toy_pack_st: mut ToyPackState) -> void {
|
||||
toy_pack_st.counts = new []int
|
||||
for i in 0 .. 3 { push(toy_pack_st.counts, 0) }
|
||||
}
|
||||
function pack_save(toy_pack_st: ToyPackState) -> Val {
|
||||
function pack_save() -> Val {
|
||||
let v = Value.object()
|
||||
sv_put_ints(v, "counts", toy_pack_st.counts)
|
||||
sv_put_ints(v, "counts", counts)
|
||||
return v
|
||||
}
|
||||
function pack_load(toy_pack_st: mut ToyPackState, v: Val, version: int) -> void {
|
||||
pack_reset(toy_pack_st)
|
||||
function pack_load(v: Val, version: int) -> void {
|
||||
pack_reset()
|
||||
let xs = sv_ints(v, "counts")
|
||||
for i in 0 .. len(xs) { if i < len(toy_pack_st.counts) { toy_pack_st.counts[i] = xs[i] } }
|
||||
for i in 0 .. len(xs) { if i < len(counts) { counts[i] = xs[i] } }
|
||||
}
|
||||
export function pack_system() -> System {
|
||||
let s = system_new("pack", PH_COMMIT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue