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

@ -3,15 +3,13 @@
# Running it prints: 1 2 3 4 5 6 7 8 9 10 11 12
program Floats {
const HALF: float = 0.5
state FloatsState {
g_gravity: float = -9.81
}
var g_gravity: float = -9.81
property Body { x: float = 1.25, vy: float, mass: double = 70.5 }
function lerp(a: float, b: float, t: float) -> float { return a + (b - a) * t }
entry (floats_st: FloatsState) {
entry {
let a: float = 0.1
if a * 3 > 0.29 and a * 3 < 0.31 { print(1) } # the int 3 promotes
if lerp(0, 10, 0.25) == 2.5 { print(2) } # ints and literals as floats
@ -20,7 +18,7 @@ program Floats {
if string(a + 0.2) == "0.3" { print(4) } # shortest text that reads back
let b = new Body
b.vy = b.vy + floats_st.g_gravity * HALF
b.vy = b.vy + g_gravity * HALF
if b.vy < -4.9 and b.vy > -4.91 and b.mass == 70.5 { print(5) }
let v = floats(3)

View file

@ -5,14 +5,12 @@
# Running it prints: 4294967295 3988292384 -4294967296 1099511627776 -3750763034362895579 -1 1
program LongLiterals {
const MASK: long = 4294967295
state LongliteralsState {
poly: long = 3988292384
}
var poly: long = 3988292384
function neg() -> long { return -4294967296 }
entry (longliterals_st: LongliteralsState) {
entry {
let big = 0x10000000000
let fnv = 0xcbf29ce484222325
let small = 0xFFFFFFFF
print(`{MASK} {longliterals_st.poly} {neg()} {big} {fnv} {small} {MASK > long(2147483647)}`)
print(`{MASK} {poly} {neg()} {big} {fnv} {small} {MASK > long(2147483647)}`)
}
}

View file

@ -15,32 +15,30 @@
# bin/ludic-dev game-build bin/ludicc examples/lang/scenes.ludic /tmp/scenes
# printf 'aaaa' | /tmp/scenes
program SceneDemo {
state ScenedemoState {
counter: int = 0
}
var counter: int = 0
handler Boot(scenedemo_st: mut ScenedemoState) phase Start { scenedemo_st.counter = 0; print(1000) }
handler Boot phase Start { counter = 0; print(1000) }
scene Title start {
on enter { print(1) }
on exit { print(2) }
layer Main {
handler Tick(scenedemo_st: mut ScenedemoState) phase Update {
scenedemo_st.counter += 1
print(100 + scenedemo_st.counter)
if scenedemo_st.counter >= 2 { become Play }
handler Tick phase Update {
counter += 1
print(100 + counter)
if counter >= 2 { become Play }
}
}
}
scene Play {
on enter (scenedemo_st: mut ScenedemoState) { print(3); scenedemo_st.counter = 0 }
on enter { print(3); counter = 0 }
on exit { print(4) }
layer World {
handler Step(scenedemo_st: mut ScenedemoState) phase Update {
scenedemo_st.counter += 1
print(200 + scenedemo_st.counter)
if scenedemo_st.counter >= 2 { quit() }
handler Step phase Update {
counter += 1
print(200 + counter)
if counter >= 2 { quit() }
}
}
layer Hud {