Passed result layout down build expr function

This commit is contained in:
Chad Stearns 2020-09-13 13:31:57 -04:00
parent 5da2d78cb9
commit 0a1e297b0f
2 changed files with 7 additions and 3 deletions

View file

@ -298,6 +298,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
layout_ids: &mut LayoutIds<'a>,
scope: &Scope<'a, 'ctx>,
parent: FunctionValue<'ctx>,
layout: &Layout<'a>,
expr: &roc_mono::ir::Expr<'a>,
) -> BasicValueEnum<'ctx> {
use roc_mono::ir::CallType::*;
@ -305,7 +306,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
match expr {
Literal(literal) => build_exp_literal(env, literal),
RunLowLevel(op, symbols) => run_low_level(env, scope, parent, *op, symbols),
RunLowLevel(op, symbols) => run_low_level(env, scope, parent, layout, *op, symbols),
FunctionCall {
call_type: ByName(name),
@ -832,7 +833,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
Let(symbol, expr, layout, cont) => {
let context = &env.context;
let val = build_exp_expr(env, layout_ids, &scope, parent, &expr);
let val = build_exp_expr(env, layout_ids, &scope, parent, layout, &expr);
let expr_bt = if let Layout::RecursivePointer = layout {
match expr {
Expr::AccessAtIndex { field_layouts, .. } => {
@ -1496,6 +1497,7 @@ fn run_low_level<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
scope: &Scope<'a, 'ctx>,
parent: FunctionValue<'ctx>,
layout: &Layout<'a>,
op: LowLevel,
args: &[Symbol],
) -> BasicValueEnum<'ctx> {
@ -1526,7 +1528,7 @@ fn run_low_level<'a, 'ctx, 'env>(
let (arg, arg_layout) = load_symbol_and_layout(env, scope, &args[0]);
list_single(env, arg, arg_layout)
list_single(env, layout, arg, arg_layout)
}
ListRepeat => {
// List.repeat : Int, elem -> List elem

View file

@ -17,6 +17,7 @@ fn get_list_element_type<'a, 'b>(layout: &'b Layout<'a>) -> Option<&'b Layout<'a
/// List.single : a -> List a
pub fn list_single<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
layout: &Layout<'a>,
elem: BasicValueEnum<'ctx>,
elem_layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
@ -1631,6 +1632,7 @@ pub fn clone_list<'a, 'ctx, 'env>(
pub fn allocate_list<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
// in_place: InPlace,
elem_layout: &Layout<'a>,
length: IntValue<'ctx>,
) -> PointerValue<'ctx> {