feat(stdlib): namespaced standard library (issue #2)
Implement the bulk of the namespaced-stdlib proposal (workshopsoft/ludic#2): 156 namespace methods across Math, Text, List, Ease, Collide, World, Net, Sys, Save, Mem, extended Screen, Color functions, extended Random, and Time. All deterministic fixed-point; self-hosting (C-free bootstrap fixpoint holds). Compiler (selfhost/): - Math.*: sqrt/sin/cos/tan/atan2/asin/acos (fixed-point runtime prelude — bit-by-bit isqrt, 256-entry interpolated sine table, Ross atan2), plus hypot/dist/dist2/deg_to_rad/rad_to_deg/posmod/wrap/ping_pong/snapped/ move_toward/smoothstep/lerp/remap/sign/floor/ceil/round. - Text.* (complete): upper/lower/trim/repeat/pad, split/join/replace, and the libc-backed queries. - List.* (complete): insert/remove_at/remove/sort plus the earlier ops. - Ease.* (in/out/in_out/back/bounce) and Collide.* (rects/point_rect/ circles/rect_circle). - Phase 3: World/Net/Sys/Save namespaced over the bare builtins (byte- identical IR) and Mem.* (bytes/words/copy/fill/peek/poke). - Screen.* extended (line/circle/fill_circle/triangle/fill_triangle via new runtime primitives; sprite/sprite_scaled aliases), Color.* functions, Random.* (value/int/sign), Time.* (frame/delta/elapsed/now — new game-loop frame counter). - Fix a lexer bug: fixed-point literals with >4 fractional digits overflowed. Docs & tooling: - 129 new per-symbol doc pages; gen.py made data-driven (namespaces discovered from the docs, no hardcoded list); new check-impl.py enforces that every implemented namespace method / keyword / type / phase has a doc page, wired into `x test-tools`. Document the previously-undocumented keywords (break/continue/where/entry/new/public + and/or/not tokens). - LSP: namespaced signature help (ns_method_sig) covering every namespace. Tests: 12 new self-host/regression tests + a golden render for the drawing primitives. All suites green (selfhost 21, regression 45, tools 29). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ff15c4e01d
commit
a38195128f
235 changed files with 24676 additions and 7762 deletions
7
docs/language/ease/_section.md
Normal file
7
docs/language/ease/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: ease
|
||||
title: Ease
|
||||
order: 6
|
||||
---
|
||||
|
||||
Tween curves — the "juice" layer. Each takes a normalized amount <code>t</code> in <code>0.0</code>..<code>1.0</code> and returns an eased <code>fixed</code>, ready to feed to <code>Math.lerp</code>. All deterministic fixed-point.
|
||||
22
docs/language/ease/ease-back.md
Normal file
22
docs/language/ease/ease-back.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
id: ease-back
|
||||
name: Ease.back
|
||||
category: ease
|
||||
kind: namespace-method
|
||||
tokens: Ease.back
|
||||
sig: Ease.back(t) -> fixed
|
||||
tip: Ease in with a small backward anticipation.
|
||||
order: 3
|
||||
ns: Ease
|
||||
member: back
|
||||
---
|
||||
|
||||
Returns an ease-in that first dips slightly below <code>0</code> before shooting forward — the anticipation windup that gives a motion snap. Because it undershoots, the eased value can go negative near the start, so use it where a little overshoot reads as lively rather than wrong.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
handler Step phase Update {
|
||||
let s = Math.lerp(rest, poke, Ease.back(progress))
|
||||
}
|
||||
}
|
||||
```
|
||||
22
docs/language/ease/ease-bounce.md
Normal file
22
docs/language/ease/ease-bounce.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
id: ease-bounce
|
||||
name: Ease.bounce
|
||||
category: ease
|
||||
kind: namespace-method
|
||||
tokens: Ease.bounce
|
||||
sig: Ease.bounce(t) -> fixed
|
||||
tip: Ease out with a settling bounce.
|
||||
order: 4
|
||||
ns: Ease
|
||||
member: bounce
|
||||
---
|
||||
|
||||
Returns an ease-out that overshoots and bounces a few times before settling at <code>1.0</code>, like a ball dropping to the floor. Great for coins landing, badges popping, or a menu that lands with character.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
handler Step phase Update {
|
||||
let y = Math.lerp(top, floor_y, Ease.bounce(progress))
|
||||
}
|
||||
}
|
||||
```
|
||||
22
docs/language/ease/ease-in.md
Normal file
22
docs/language/ease/ease-in.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
id: ease-in
|
||||
name: Ease.in
|
||||
category: ease
|
||||
kind: namespace-method
|
||||
tokens: Ease.in
|
||||
sig: Ease.in(t) -> fixed
|
||||
tip: Accelerate from rest (quadratic ease-in).
|
||||
order: 0
|
||||
ns: Ease
|
||||
member: in
|
||||
---
|
||||
|
||||
Returns <code>t * t</code> — motion that starts slow and speeds up. Feed the result to <code>Math.lerp</code> as the blend amount so a value accelerates into its target. The input <code>t</code> is expected in <code>0.0</code>..<code>1.0</code>.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
handler Step phase Update {
|
||||
let x = Math.lerp(start_x, end_x, Ease.in(progress))
|
||||
}
|
||||
}
|
||||
```
|
||||
22
docs/language/ease/ease-in_out.md
Normal file
22
docs/language/ease/ease-in_out.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
id: ease-in_out
|
||||
name: Ease.in_out
|
||||
category: ease
|
||||
kind: namespace-method
|
||||
tokens: Ease.in_out
|
||||
sig: Ease.in_out(t) -> fixed
|
||||
tip: Ease in and then out (smoothstep).
|
||||
order: 2
|
||||
ns: Ease
|
||||
member: in_out
|
||||
---
|
||||
|
||||
Returns the smooth <code>3t^2 - 2t^3</code> S-curve: slow at both ends, fastest in the middle. Use it for a polished there-and-back or point-to-point move that neither jerks off the mark nor slams into the target.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
handler Step phase Update {
|
||||
let a = Math.lerp(0.0, 1.0, Ease.in_out(progress))
|
||||
}
|
||||
}
|
||||
```
|
||||
22
docs/language/ease/ease-out.md
Normal file
22
docs/language/ease/ease-out.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
id: ease-out
|
||||
name: Ease.out
|
||||
category: ease
|
||||
kind: namespace-method
|
||||
tokens: Ease.out
|
||||
sig: Ease.out(t) -> fixed
|
||||
tip: Decelerate to rest (quadratic ease-out).
|
||||
order: 1
|
||||
ns: Ease
|
||||
member: out
|
||||
---
|
||||
|
||||
Returns <code>t * (2 - t)</code> — motion that starts fast and slows as it arrives. The most natural-feeling easing for things settling into place, like a panel sliding in or a camera coming to rest.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
handler Step phase Update {
|
||||
let y = Math.lerp(top, rest_y, Ease.out(progress))
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue