mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
implement Num.toStr for the dev backend
This commit is contained in:
parent
f7e3254a35
commit
f45e4ed858
2 changed files with 12 additions and 1 deletions
|
@ -1109,6 +1109,17 @@ trait Backend<'a> {
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
),
|
),
|
||||||
|
LowLevel::NumToStr => {
|
||||||
|
let arg_layout = arg_layouts[0];
|
||||||
|
let intrinsic = match self.interner().get(arg_layout) {
|
||||||
|
Layout::Builtin(Builtin::Int(width)) => &bitcode::STR_FROM_INT[width],
|
||||||
|
Layout::Builtin(Builtin::Float(width)) => &bitcode::STR_FROM_FLOAT[width],
|
||||||
|
Layout::Builtin(Builtin::Decimal) => bitcode::DEC_TO_STR,
|
||||||
|
x => internal_error!("NumToStr is not defined for {:?}", x),
|
||||||
|
};
|
||||||
|
|
||||||
|
self.build_fn_call(sym, intrinsic.to_string(), args, arg_layouts, ret_layout)
|
||||||
|
}
|
||||||
x => todo!("low level, {:?}", x),
|
x => todo!("low level, {:?}", x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3113,7 +3113,7 @@ fn when_on_i16() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||||
fn num_to_str() {
|
fn num_to_str() {
|
||||||
use roc_std::RocStr;
|
use roc_std::RocStr;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue