feat(types): Huge + Angle + Percent polish numeric types (#55)
Types phase 5 (polish). A splice-on-demand numeric runtime (runtime/native/numeric.ludic, built on the inline Math.* trig) behind three namespaces: - Huge.* — idle big numbers (normalized mantissa x 10^exponent): from/add/ sub/mul/neg/cmp/sign/mantissa/exp/str (scientific 1.23e45). Display-scale, not lockstep-exact (BigInt/Decimal for exactness). - Angle.* — auto-wrapping radians: from_degrees/to_degrees/wrap/sin/cos/add/ diff (shortest signed rotation)/lerp (shortest arc). - Percent.* — clamped [0,1]: clamp/of/lerp/apply. Remaining phase-5 items are already covered (duration=Duration.*, rune=Unicode.*, i64=long) or need a type-checking pass (handle, typed name, other sized ints) — tracked for later. Wired: parser splice trigger (g_uses_numeric), emit_call dispatch, reseeded seed, a self-asserting example (examples/library/numeric.ludic + feat_case), per-symbol docs + inventory. All suites green incl. golden renders byte- identical and the bootstrap fixpoint. NOTE: fixed `const`s lower to raw-int-typed values (emit_call N_CONST), which breaks fixed comparisons — the runtime uses inline fixed literals instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
539f258d92
commit
5dc8394f22
33 changed files with 23162 additions and 21092 deletions
|
|
@ -177,6 +177,7 @@ function p_postfix() -> Node {
|
|||
if e.a.kind == E_ID and e.a.s == "Regex" { g_uses_regex = true } # splice the regex runtime on demand
|
||||
if e.a.kind == E_ID and (e.a.s == "BigInt" or e.a.s == "Decimal") { g_uses_bignum = true } # splice the bignum runtime on demand
|
||||
if e.a.kind == E_ID and (e.a.s == "Dict" or e.a.s == "Set") { g_uses_dict = true } # splice the hash-table runtime on demand
|
||||
if e.a.kind == E_ID and (e.a.s == "Huge" or e.a.s == "Angle" or e.a.s == "Percent") { g_uses_numeric = true } # splice the huge/angle/percent runtime on demand
|
||||
if e.a.kind == E_ID and e.a.s == "Query" { g_uses_query = true } # splice the ECS spatial-query runtime on demand
|
||||
if e.a.kind == E_ID and e.a.s == "Reflect" { g_uses_reflect = true } # force-emit the reflection ABI (Reflect.* reads the world schema)
|
||||
if e.a.kind == E_ID and e.a.s == "Light" { g_uses_light = true } # splice the 2D light-accumulation pass on demand
|
||||
|
|
@ -425,6 +426,7 @@ var cur_dir: pointer
|
|||
var g_uses_regex: bool = false # a program mentioned Regex.* -> splice the regex runtime
|
||||
var g_uses_bignum: bool = false # a program mentioned BigInt.*/Decimal.* -> splice the bignum runtime
|
||||
var g_uses_dict: bool = false # a program mentioned Dict.*/Set.* -> splice the hash-table runtime
|
||||
var g_uses_numeric: bool = false # a program mentioned Huge.*/Angle.*/Percent.* -> splice the numeric runtime
|
||||
var g_uses_query: bool = false # a program mentioned Query.* -> splice the query runtime + reflection ABI
|
||||
var g_uses_reflect: bool = false # a program mentioned Reflect.* -> force-emit the reflection ABI
|
||||
var g_uses_light: bool = false # a program mentioned Light.* -> splice the 2D light pass
|
||||
|
|
@ -617,6 +619,13 @@ function maybe_splice_runtime() -> void {
|
|||
do_import("runtime/native/dict.ludic")
|
||||
cur_dir = saved
|
||||
}
|
||||
# any program that uses Huge.*/Angle.*/Percent.* gets the numeric runtime
|
||||
# spliced in (it builds on Math.*, which lowers inline, so a plain tool works).
|
||||
if g_uses_numeric {
|
||||
cur_dir = ""
|
||||
do_import("runtime/native/numeric.ludic")
|
||||
cur_dir = saved
|
||||
}
|
||||
# any program that uses Query.* gets the ECS spatial-query helpers spliced in;
|
||||
# they read entity state through the reflection ABI (emit_decl force-emits it
|
||||
# for a Query program even when it declares no events).
|
||||
|
|
@ -733,6 +742,7 @@ function parse_program() -> void {
|
|||
g_uses_regex = false
|
||||
g_uses_bignum = false
|
||||
g_uses_dict = false
|
||||
g_uses_numeric = false
|
||||
g_uses_query = false
|
||||
g_uses_reflect = false
|
||||
g_uses_esys = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue