fix(v1.0.2): Array grow from 0, Map/Set rehash, checked div/mod
ci / build (ubuntu) (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
ci / build (ubuntu) (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
- Array_Push grows from cap 0 (same min as Insert) to avoid segfault - Map/StringMap/Set: default min cap 8 and auto-rehash at ~50% load - Integer / and % emit bux_div_i64 / bux_mod_i64 (panic instead of SIGFPE) - Bump version to 1.0.2; stdlib golden regressions; fmt clean
This commit is contained in:
@@ -256,6 +256,12 @@ proc emitExpr(be: var CBackend, node: HirNode): string =
|
||||
of hBinary:
|
||||
let left = be.emitExpr(node.binaryLeft)
|
||||
let right = be.emitExpr(node.binaryRight)
|
||||
# Checked integer / and % (float keeps raw C operators)
|
||||
let isFloat = node.typ != nil and node.typ.kind in {tkFloat32, tkFloat64}
|
||||
if node.binaryOp == tkSlash and not isFloat:
|
||||
return &"bux_div_i64((int64_t)({left}), (int64_t)({right}))"
|
||||
if node.binaryOp == tkPercent and not isFloat:
|
||||
return &"bux_mod_i64((int64_t)({left}), (int64_t)({right}))"
|
||||
let op = operatorToC(node.binaryOp)
|
||||
return &"({left} {op} {right})"
|
||||
|
||||
@@ -658,6 +664,9 @@ proc emitModule*(be: var CBackend, module: HirModule): string =
|
||||
be.emitLine("#include <stdbool.h>")
|
||||
be.emitLine("#include <string.h>")
|
||||
be.emitLine("")
|
||||
be.emitLine("extern int64_t bux_div_i64(int64_t a, int64_t b);")
|
||||
be.emitLine("extern int64_t bux_mod_i64(int64_t a, int64_t b);")
|
||||
be.emitLine("")
|
||||
|
||||
# Pre-collect slice types so we can emit forward declarations early
|
||||
let sliceTypes = collectSliceTypes(module)
|
||||
|
||||
Reference in New Issue
Block a user