feat(lang): float and double types with ordinary operators

`float` (32-bit) and `double` (64-bit) with + - * / %, comparisons and unary minus.
Decimal literals take their type from context and stay `fixed` elsewhere; int and long
promote implicitly (LUDIC_WARN_FLOAT_PROMOTE=1 lists every promotion). float(), double(),
int(), long() and fixed() convert; floats(n)/doubles(n) buffers; float fields, globals,
constants and parameters; Math.* computes in float for float arguments; string/print
write the shortest round-tripping decimal; float_bits/float_from_bits expose the bits.
@deterministic code may not use floats. The f_* runtime helpers stay as they are.

Editors know the new type words; the JetBrains plugin is 1.5.0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-16 16:02:03 +03:00
parent f92d7f89c6
commit e010c2cecc
40 changed files with 67726 additions and 57272 deletions

View file

@ -4,6 +4,7 @@
# called only when the runtime defines them.
function emit_system_fn(sys: Node) -> void {
det_enter(sys.s)
g_cur_scene = sys.c # scene owning this handler (null if global) — for `become`
ll_t = 0; ll_lbl = 0; g_term = false; loc_reset(); nloop = 0; nself = 0
ret_ty = "void"
@ -19,6 +20,7 @@ function emit_system_fn(sys: Node) -> void {
emit(buf_str(falloc))
emit(buf_str(fbody))
emit("}\n\n")
g_det_ctx = ""
}
# one enable-gated call to @sys_<d.s> (skipped while the handler is disabled).

View file

@ -26,9 +26,8 @@ function emit_init_component(e: pointer, comp: pointer, rec: Node) -> void {
let addr = nreg()
emit(" "); emit(addr); emit(" = getelementptr inbounds %Cmp_"); emit(comp); emit(", ptr "); emit(slot); emit(", i32 0, i32 "); emit(itoa(f)); emit("\n")
let lt = llty(fd.ty)
var v = "0"
if (lt == "ptr") { v = "null" }
if (fd.a != null) { let dv = emit_expr(fd.a); v = dv.code }
var v = zero_of(lt)
if (fd.a != null) { let dv = emit_expr(fd.a); v = coerce_code(dv, fd.ty) }
emit(" store "); emit(lt); emit(" "); emit(v); emit(", ptr "); emit(addr); emit("\n")
f += 1
}
@ -42,7 +41,9 @@ function emit_init_component(e: pointer, comp: pointer, rec: Node) -> void {
let addr = nreg()
emit(" "); emit(addr); emit(" = getelementptr inbounds %Cmp_"); emit(comp); emit(", ptr "); emit(slot); emit(", i32 0, i32 "); emit(itoa(fidx)); emit("\n")
let dv = emit_expr(fi.a)
emit(" store "); emit(llty(field_type(c, fi.s))); emit(" "); emit(dv.code); emit(", ptr "); emit(addr); emit("\n")
let fty = field_type(c, fi.s)
let dcode = coerce_code(dv, fty)
emit(" store "); emit(llty(fty)); emit(" "); emit(dcode); emit(", ptr "); emit(addr); emit("\n")
}
j += 1
}