mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
handle lambda set when passed as a function argument
This commit is contained in:
parent
fdffcc8b36
commit
67281b2712
6 changed files with 36 additions and 8 deletions
|
@ -769,6 +769,10 @@ impl<
|
|||
// Call function and generate reloc.
|
||||
ASM::call(&mut self.buf, &mut self.relocs, fn_name);
|
||||
|
||||
self.move_return_value(dst, ret_layout)
|
||||
}
|
||||
|
||||
fn move_return_value(&mut self, dst: &Symbol, ret_layout: &InLayout<'a>) {
|
||||
// move return value to dst.
|
||||
match *ret_layout {
|
||||
single_register_integers!() => {
|
||||
|
@ -786,6 +790,9 @@ impl<
|
|||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
ASM::mov_reg64_reg64(&mut self.buf, dst_reg, CC::GENERAL_RETURN_REGS[0]);
|
||||
}
|
||||
Layout::LambdaSet(lambda_set) => {
|
||||
self.move_return_value(dst, &lambda_set.runtime_representation())
|
||||
}
|
||||
_ => {
|
||||
CC::load_returned_complex_symbol(
|
||||
&mut self.buf,
|
||||
|
|
|
@ -1559,7 +1559,6 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
|
|||
src1: X86_64GeneralReg,
|
||||
src2: X86_64GeneralReg,
|
||||
) {
|
||||
dbg!(register_width);
|
||||
cmp_reg64_reg64(buf, register_width, src1, src2);
|
||||
sete_reg64(buf, dst);
|
||||
}
|
||||
|
@ -1572,7 +1571,6 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
|
|||
src1: X86_64GeneralReg,
|
||||
src2: X86_64GeneralReg,
|
||||
) {
|
||||
dbg!(register_width);
|
||||
cmp_reg64_reg64(buf, register_width, src1, src2);
|
||||
setne_reg64(buf, dst);
|
||||
}
|
||||
|
|
|
@ -1131,6 +1131,9 @@ trait Backend<'a> {
|
|||
ret_layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// Move a returned value into `dst`
|
||||
fn move_return_value(&mut self, dst: &Symbol, ret_layout: &InLayout<'a>);
|
||||
|
||||
/// build_num_abs stores the absolute value of src into dst.
|
||||
fn build_num_abs(&mut self, dst: &Symbol, src: &Symbol, layout: &InLayout<'a>);
|
||||
|
||||
|
|
|
@ -4124,7 +4124,7 @@ fn int_let_generalization() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
manyAux : {} -> I32
|
||||
manyAux : {} -> I32
|
||||
manyAux = \_ ->
|
||||
output = \_ -> 42
|
||||
|
||||
|
@ -4403,17 +4403,17 @@ fn layout_cache_structure_with_multiple_recursive_structures() {
|
|||
LinkedList : [Nil, Cons { first : Chain, rest : LinkedList }]
|
||||
|
||||
main =
|
||||
base : LinkedList
|
||||
base : LinkedList
|
||||
base = Nil
|
||||
|
||||
walker : LinkedList, Chain -> LinkedList
|
||||
walker = \rest, first -> Cons { first, rest }
|
||||
walker = \rest, first -> Cons { first, rest }
|
||||
|
||||
list : List Chain
|
||||
list = []
|
||||
|
||||
r = List.walk list base walker
|
||||
|
||||
|
||||
if r == base then 11u8 else 22u8
|
||||
"#
|
||||
),
|
||||
|
@ -4460,3 +4460,23 @@ fn reset_recursive_type_wraps_in_named_type() {
|
|||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn pass_lambda_set_to_function() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
instr = if Bool.true then Num.mul else Num.add
|
||||
|
||||
fn = \a -> instr a a
|
||||
|
||||
main = fn 3
|
||||
"#
|
||||
),
|
||||
3 * 3,
|
||||
i64
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2010,7 +2010,7 @@ fn unify_types_with_fixed_fixpoints_outside_fixing_region() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
|
||||
fn lambda_set_with_imported_toplevels_issue_4733() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
|
|
|
@ -210,7 +210,7 @@ pub fn helper(
|
|||
let builtins_host_tempfile =
|
||||
roc_bitcode::host_tempfile().expect("failed to write host builtins object to tempfile");
|
||||
|
||||
if true {
|
||||
if false {
|
||||
std::fs::copy(&app_o_file, "/tmp/app.o").unwrap();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue