fix gen_dev

This commit is contained in:
Folkert 2021-01-01 16:20:27 +01:00
parent 0893aa7369
commit 5a6bd1e187

View file

@ -103,25 +103,30 @@ where
} }
Ok(()) Ok(())
} }
Expr::FunctionCall { Expr::Call(roc_mono::ir::Call {
call_type: CallType::ByName(func_sym), call_type,
args, arguments,
.. }) => {
} => { match call_type {
CallType::ByName { name: func_sym, .. } => {
match *func_sym { match *func_sym {
Symbol::NUM_ABS => { Symbol::NUM_ABS => {
// Instead of calling the function, just inline it. // Instead of calling the function, just inline it.
self.build_expr(sym, &Expr::RunLowLevel(LowLevel::NumAbs, args), layout) self.build_run_low_level(sym, &LowLevel::NumAbs, arguments, layout)
} }
Symbol::NUM_ADD => { Symbol::NUM_ADD => {
// Instead of calling the function, just inline it. // Instead of calling the function, just inline it.
self.build_expr(sym, &Expr::RunLowLevel(LowLevel::NumAdd, args), layout) self.build_run_low_level(sym, &LowLevel::NumAdd, arguments, layout)
} }
x => Err(format!("the function, {:?}, is not yet implemented", x)), x => Err(format!("the function, {:?}, is not yet implemented", x)),
} }
} }
Expr::RunLowLevel(lowlevel, args) => {
self.build_run_low_level(sym, lowlevel, args, layout) CallType::LowLevel { op: lowlevel } => {
self.build_run_low_level(sym, lowlevel, arguments, layout)
}
x => Err(format!("the call type, {:?}, is not yet implemented", x)),
}
} }
x => Err(format!("the expression, {:?}, is not yet implemented", x)), x => Err(format!("the expression, {:?}, is not yet implemented", x)),
} }
@ -244,36 +249,30 @@ where
match expr { match expr {
Expr::Literal(_) => {} Expr::Literal(_) => {}
Expr::FunctionPointer(sym, _) => self.set_last_seen(*sym, stmt), Expr::FunctionPointer(sym, _) => self.set_last_seen(*sym, stmt),
Expr::FunctionCall { Expr::Call(roc_mono::ir::Call {
call_type, args, .. call_type,
} => { arguments,
for sym in *args { }) => {
for sym in *arguments {
self.set_last_seen(*sym, stmt); self.set_last_seen(*sym, stmt);
} }
match call_type { match call_type {
CallType::ByName(sym) => { CallType::ByName { name: sym, .. } => {
// For functions that we won't inline, we should not be a leaf function. // For functions that we won't inline, we should not be a leaf function.
if !INLINED_SYMBOLS.contains(sym) { if !INLINED_SYMBOLS.contains(sym) {
self.set_not_leaf_function(); self.set_not_leaf_function();
} }
} }
CallType::ByPointer(sym) => { CallType::ByPointer { name: sym, .. } => {
self.set_not_leaf_function(); self.set_not_leaf_function();
self.set_last_seen(*sym, stmt); self.set_last_seen(*sym, stmt);
} }
CallType::LowLevel { .. } => {}
CallType::Foreign { .. } => self.set_not_leaf_function(),
} }
} }
Expr::RunLowLevel(_, args) => {
for sym in *args {
self.set_last_seen(*sym, stmt);
}
}
Expr::ForeignCall { arguments, .. } => {
for sym in *arguments {
self.set_last_seen(*sym, stmt);
}
self.set_not_leaf_function();
}
Expr::Tag { arguments, .. } => { Expr::Tag { arguments, .. } => {
for sym in *arguments { for sym in *arguments {
self.set_last_seen(*sym, stmt); self.set_last_seen(*sym, stmt);