feat(text): Text.to_float; a void function's return <value> is an error
Text.to_float reads a leading decimal number (strtod), the twin of Text.to_int, for data files. A return with a value in a function that returns nothing now says so where it is, instead of reaching clang as 'store void'. Seed regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f5ab5cf88a
commit
c57eafcacc
8 changed files with 38133 additions and 37958 deletions
|
|
@ -6,6 +6,7 @@
|
|||
function is_text_ns(meth: pointer) -> bool {
|
||||
if (meth == "length") or (meth == "char_at") or (meth == "slice") { return true }
|
||||
if (meth == "equals") or (meth == "concat") or (meth == "to_int") or (meth == "from_int") { return true }
|
||||
if (meth == "to_float") { return true }
|
||||
if (meth == "starts_with") or (meth == "ends_with") { return true }
|
||||
if (meth == "contains") or (meth == "index_of") { return true }
|
||||
if (meth == "upper") or (meth == "lower") or (meth == "trim") or (meth == "repeat") { return true }
|
||||
|
|
@ -47,6 +48,11 @@ function emit_text_ns(meth: pointer, e: Node) -> Val {
|
|||
let c = emit_bind(`load i8, ptr {a}`)
|
||||
return val(emit_bind(`zext i8 {c} to i32`), "int")
|
||||
}
|
||||
if (meth == "to_float") { # parse a leading decimal number, 0.0 if none
|
||||
fp_declare("declare double @strtod(ptr, ptr)\n")
|
||||
let d = emit_bind(`call double @strtod(ptr {s.code}, ptr null)`)
|
||||
return val(emit_bind(`fptrunc double {d} to float`), "float")
|
||||
}
|
||||
if (meth == "to_int") { # parse a leading integer, 0 if none
|
||||
return val(emit_bind(`call i32 @atoi(ptr {s.code})`), "int")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue