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/world/_section.md
Normal file
7
docs/language/world/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: world
|
||||
title: World
|
||||
order: 6
|
||||
---
|
||||
|
||||
Runtime reflection over the ECS world — read and write component fields by id, spawn and inspect entities, and register components at runtime. The introspection layer a mod uses.
|
||||
14
docs/language/world/world-attach.md
Normal file
14
docs/language/world/world-attach.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-attach
|
||||
name: World.attach
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.attach
|
||||
sig: World.attach(entity, prop_id) -> void
|
||||
tip: Attach a component to an entity at runtime.
|
||||
order: 13
|
||||
ns: World
|
||||
member: attach
|
||||
---
|
||||
|
||||
Adds component <code>prop_id</code> to <code>entity</code>, so <code>World.get</code>/<code>set</code>/<code>has</code> then work on it.
|
||||
14
docs/language/world/world-count.md
Normal file
14
docs/language/world/world-count.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-count
|
||||
name: World.count
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.count
|
||||
sig: World.count() -> int
|
||||
tip: The number of live entities.
|
||||
order: 3
|
||||
ns: World
|
||||
member: count
|
||||
---
|
||||
|
||||
Returns how many entities currently exist in the world.
|
||||
14
docs/language/world/world-detach.md
Normal file
14
docs/language/world/world-detach.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-detach
|
||||
name: World.detach
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.detach
|
||||
sig: World.detach(entity, prop_id) -> void
|
||||
tip: Detach a component from an entity at runtime.
|
||||
order: 14
|
||||
ns: World
|
||||
member: detach
|
||||
---
|
||||
|
||||
Removes component <code>prop_id</code> from <code>entity</code> — the inverse of <code>World.attach</code>.
|
||||
14
docs/language/world/world-field_id.md
Normal file
14
docs/language/world/world-field_id.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-field_id
|
||||
name: World.field_id
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.field_id
|
||||
sig: World.field_id(prop_id, name) -> int
|
||||
tip: Look up a field's id by name.
|
||||
order: 9
|
||||
ns: World
|
||||
member: field_id
|
||||
---
|
||||
|
||||
Returns the numeric id of field <code>name</code> within component <code>prop_id</code>.
|
||||
14
docs/language/world/world-get.md
Normal file
14
docs/language/world/world-get.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-get
|
||||
name: World.get
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.get
|
||||
sig: World.get(prop_id, field_id, entity) -> int
|
||||
tip: Read a component field by id.
|
||||
order: 0
|
||||
ns: World
|
||||
member: get
|
||||
---
|
||||
|
||||
Reads the value of field <code>field_id</code> of component <code>prop_id</code> on <code>entity</code>, by numeric id rather than by name — the reflective form the bare <code>world_get</code> provides.
|
||||
14
docs/language/world/world-has.md
Normal file
14
docs/language/world/world-has.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-has
|
||||
name: World.has
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.has
|
||||
sig: World.has(entity, prop_id) -> int
|
||||
tip: Does an entity have a component?
|
||||
order: 2
|
||||
ns: World
|
||||
member: has
|
||||
---
|
||||
|
||||
Returns non-zero when <code>entity</code> carries the component <code>prop_id</code>. Use it before <code>World.get</code> on a dynamically-attached component.
|
||||
14
docs/language/world/world-kind.md
Normal file
14
docs/language/world/world-kind.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-kind
|
||||
name: World.kind
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.kind
|
||||
sig: World.kind(entity) -> int
|
||||
tip: The model id of an entity.
|
||||
order: 11
|
||||
ns: World
|
||||
member: kind
|
||||
---
|
||||
|
||||
Returns the model id that <code>entity</code> was spawned as.
|
||||
14
docs/language/world/world-load.md
Normal file
14
docs/language/world/world-load.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-load
|
||||
name: World.load
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.load
|
||||
sig: World.load(buf, len) -> void
|
||||
tip: Restore the world from a buffer.
|
||||
order: 7
|
||||
ns: World
|
||||
member: load
|
||||
---
|
||||
|
||||
Replaces the current world with the snapshot in the first <code>len</code> bytes of <code>buf</code> — the inverse of <code>World.save</code>.
|
||||
14
docs/language/world/world-model_id.md
Normal file
14
docs/language/world/world-model_id.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-model_id
|
||||
name: World.model_id
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.model_id
|
||||
sig: World.model_id(name) -> int
|
||||
tip: Look up a model's id by name.
|
||||
order: 10
|
||||
ns: World
|
||||
member: model_id
|
||||
---
|
||||
|
||||
Returns the numeric id of the model named <code>name</code>, for passing to <code>World.spawn</code>.
|
||||
14
docs/language/world/world-prop_id.md
Normal file
14
docs/language/world/world-prop_id.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-prop_id
|
||||
name: World.prop_id
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.prop_id
|
||||
sig: World.prop_id(name) -> int
|
||||
tip: Look up a component's id by name.
|
||||
order: 8
|
||||
ns: World
|
||||
member: prop_id
|
||||
---
|
||||
|
||||
Returns the numeric id of the component named <code>name</code>, for use with the by-id reflection calls.
|
||||
14
docs/language/world/world-query_next.md
Normal file
14
docs/language/world/world-query_next.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-query_next
|
||||
name: World.query_next
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.query_next
|
||||
sig: World.query_next(query_id, cursor) -> int
|
||||
tip: Advance a reflective query.
|
||||
order: 15
|
||||
ns: World
|
||||
member: query_next
|
||||
---
|
||||
|
||||
Returns the next entity matching query <code>query_id</code> after <code>cursor</code>, or a terminal value when the query is exhausted.
|
||||
14
docs/language/world/world-register_prop.md
Normal file
14
docs/language/world/world-register_prop.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-register_prop
|
||||
name: World.register_prop
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.register_prop
|
||||
sig: World.register_prop(name, size) -> int
|
||||
tip: Register a new component at runtime.
|
||||
order: 12
|
||||
ns: World
|
||||
member: register_prop
|
||||
---
|
||||
|
||||
Declares a brand-new component named <code>name</code> holding <code>size</code> integer fields and returns its id — a component the game's source never wrote, for mods.
|
||||
14
docs/language/world/world-save.md
Normal file
14
docs/language/world/world-save.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-save
|
||||
name: World.save
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.save
|
||||
sig: World.save(buf) -> int
|
||||
tip: Serialize the world into a buffer.
|
||||
order: 6
|
||||
ns: World
|
||||
member: save
|
||||
---
|
||||
|
||||
Writes a binary snapshot of the whole ECS world into <code>buf</code> and returns the number of bytes written. Size the buffer with <code>World.size</code>.
|
||||
14
docs/language/world/world-set.md
Normal file
14
docs/language/world/world-set.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-set
|
||||
name: World.set
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.set
|
||||
sig: World.set(prop_id, field_id, entity, value) -> void
|
||||
tip: Write a component field by id.
|
||||
order: 1
|
||||
ns: World
|
||||
member: set
|
||||
---
|
||||
|
||||
Writes <code>value</code> into field <code>field_id</code> of component <code>prop_id</code> on <code>entity</code>. The reflective counterpart to <code>World.get</code>.
|
||||
14
docs/language/world/world-size.md
Normal file
14
docs/language/world/world-size.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-size
|
||||
name: World.size
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.size
|
||||
sig: World.size() -> int
|
||||
tip: The serialized size of the world.
|
||||
order: 4
|
||||
ns: World
|
||||
member: size
|
||||
---
|
||||
|
||||
Returns the number of bytes a full <code>World.save</code> snapshot of the current world would take, for sizing a buffer.
|
||||
14
docs/language/world/world-spawn.md
Normal file
14
docs/language/world/world-spawn.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
id: world-spawn
|
||||
name: World.spawn
|
||||
category: world
|
||||
kind: namespace-method
|
||||
tokens: World.spawn
|
||||
sig: World.spawn(model_id) -> entity
|
||||
tip: Spawn an entity of a model by id.
|
||||
order: 5
|
||||
ns: World
|
||||
member: spawn
|
||||
---
|
||||
|
||||
Creates a new entity of model <code>model_id</code> and returns it — the reflective form of the <code>spawn</code> statement.
|
||||
Loading…
Add table
Add a link
Reference in a new issue