mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-16 00:35:01 +00:00
add Str.appendScalar
This commit is contained in:
parent
92539fe3b0
commit
e48a604862
3 changed files with 30 additions and 1 deletions
|
@ -572,6 +572,20 @@ trait Backend<'a> {
|
||||||
internal_error!("bitwise xor on a non-integer")
|
internal_error!("bitwise xor on a non-integer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LowLevel::And => {
|
||||||
|
if let Layout::Builtin(Builtin::Bool) = self.interner().get(*ret_layout) {
|
||||||
|
self.build_int_bitwise_and(sym, &args[0], &args[1], IntWidth::U8)
|
||||||
|
} else {
|
||||||
|
internal_error!("bitwise and on a non-integer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LowLevel::Or => {
|
||||||
|
if let Layout::Builtin(Builtin::Bool) = self.interner().get(*ret_layout) {
|
||||||
|
self.build_int_bitwise_or(sym, &args[0], &args[1], IntWidth::U8)
|
||||||
|
} else {
|
||||||
|
internal_error!("bitwise or on a non-integer")
|
||||||
|
}
|
||||||
|
}
|
||||||
LowLevel::NumShiftLeftBy => {
|
LowLevel::NumShiftLeftBy => {
|
||||||
if let Layout::Builtin(Builtin::Int(int_width)) = self.interner().get(*ret_layout) {
|
if let Layout::Builtin(Builtin::Int(int_width)) = self.interner().get(*ret_layout) {
|
||||||
self.build_int_shift_left(sym, &args[0], &args[1], int_width)
|
self.build_int_shift_left(sym, &args[0], &args[1], int_width)
|
||||||
|
@ -812,6 +826,13 @@ trait Backend<'a> {
|
||||||
arg_layouts,
|
arg_layouts,
|
||||||
ret_layout,
|
ret_layout,
|
||||||
),
|
),
|
||||||
|
LowLevel::StrAppendScalar => self.build_fn_call(
|
||||||
|
sym,
|
||||||
|
bitcode::STR_APPEND_SCALAR.to_string(),
|
||||||
|
args,
|
||||||
|
arg_layouts,
|
||||||
|
ret_layout,
|
||||||
|
),
|
||||||
LowLevel::StrEndsWith => self.build_fn_call(
|
LowLevel::StrEndsWith => self.build_fn_call(
|
||||||
sym,
|
sym,
|
||||||
bitcode::STR_ENDS_WITH.to_string(),
|
bitcode::STR_ENDS_WITH.to_string(),
|
||||||
|
@ -1006,6 +1027,13 @@ trait Backend<'a> {
|
||||||
self.return_symbol(&Symbol::DEV_TMP, &bool_layout);
|
self.return_symbol(&Symbol::DEV_TMP, &bool_layout);
|
||||||
self.free_symbol(&Symbol::DEV_TMP)
|
self.free_symbol(&Symbol::DEV_TMP)
|
||||||
}
|
}
|
||||||
|
Symbol::STR_IS_VALID_SCALAR => {
|
||||||
|
let layout_id = LayoutIds::default().get(func_sym, ret_layout);
|
||||||
|
let fn_name = self.symbol_to_string(func_sym, layout_id);
|
||||||
|
// Now that the arguments are needed, load them if they are literals.
|
||||||
|
self.load_literal_symbols(args);
|
||||||
|
self.build_fn_call(sym, fn_name, args, arg_layouts, ret_layout)
|
||||||
|
}
|
||||||
_ => todo!("the function, {:?}", func_sym),
|
_ => todo!("the function, {:?}", func_sym),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1319,6 +1319,7 @@ define_builtins! {
|
||||||
53 STR_WITH_CAPACITY: "withCapacity"
|
53 STR_WITH_CAPACITY: "withCapacity"
|
||||||
54 STR_WITH_PREFIX: "withPrefix"
|
54 STR_WITH_PREFIX: "withPrefix"
|
||||||
55 STR_GRAPHEMES: "graphemes"
|
55 STR_GRAPHEMES: "graphemes"
|
||||||
|
56 STR_IS_VALID_SCALAR: "isValidScalar"
|
||||||
}
|
}
|
||||||
6 LIST: "List" => {
|
6 LIST: "List" => {
|
||||||
0 LIST_LIST: "List" exposed_apply_type=true // the List.List type alias
|
0 LIST_LIST: "List" exposed_apply_type=true // the List.List type alias
|
||||||
|
|
|
@ -1857,7 +1857,7 @@ fn str_walk_utf8_with_index() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||||
fn str_append_scalar() {
|
fn str_append_scalar() {
|
||||||
assert_evals_to!(
|
assert_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue