mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Have Stmt::new accept LayoutCache
This commit is contained in:
parent
8751e4bd00
commit
3f0b08a992
4 changed files with 21 additions and 13 deletions
|
@ -257,7 +257,9 @@ pub fn gen(src: &[u8], target: Triple, opt_level: OptLevel) -> Result<(String, S
|
||||||
ident_ids: &mut ident_ids,
|
ident_ids: &mut ident_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs);
|
let mut layout_cache = LayoutCache::default();
|
||||||
|
let main_body =
|
||||||
|
roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache);
|
||||||
let main_body =
|
let main_body =
|
||||||
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
||||||
let mut headers = {
|
let mut headers = {
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn helper_without_uniqueness<'a>(
|
||||||
use roc_gen::llvm::build::Scope;
|
use roc_gen::llvm::build::Scope;
|
||||||
use roc_gen::llvm::build::{build_proc, build_proc_header};
|
use roc_gen::llvm::build::{build_proc, build_proc_header};
|
||||||
use roc_gen::llvm::convert::basic_type_from_layout;
|
use roc_gen::llvm::convert::basic_type_from_layout;
|
||||||
use roc_mono::layout::Layout;
|
use roc_mono::layout::{Layout, LayoutCache};
|
||||||
|
|
||||||
let target = target_lexicon::Triple::host();
|
let target = target_lexicon::Triple::host();
|
||||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||||
|
@ -105,7 +105,9 @@ pub fn helper_without_uniqueness<'a>(
|
||||||
ident_ids: &mut ident_ids,
|
ident_ids: &mut ident_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs);
|
let mut layout_cache = LayoutCache::default();
|
||||||
|
let main_body =
|
||||||
|
roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache);
|
||||||
let main_body =
|
let main_body =
|
||||||
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
||||||
|
|
||||||
|
@ -214,7 +216,7 @@ pub fn helper_with_uniqueness<'a>(
|
||||||
use roc_gen::llvm::build::Scope;
|
use roc_gen::llvm::build::Scope;
|
||||||
use roc_gen::llvm::build::{build_proc, build_proc_header};
|
use roc_gen::llvm::build::{build_proc, build_proc_header};
|
||||||
use roc_gen::llvm::convert::basic_type_from_layout;
|
use roc_gen::llvm::convert::basic_type_from_layout;
|
||||||
use roc_mono::layout::Layout;
|
use roc_mono::layout::{Layout, LayoutCache};
|
||||||
|
|
||||||
let target = target_lexicon::Triple::host();
|
let target = target_lexicon::Triple::host();
|
||||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||||
|
@ -296,7 +298,9 @@ pub fn helper_with_uniqueness<'a>(
|
||||||
ident_ids: &mut ident_ids,
|
ident_ids: &mut ident_ids,
|
||||||
};
|
};
|
||||||
|
|
||||||
let main_body = roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs);
|
let mut layout_cache = LayoutCache::default();
|
||||||
|
let main_body =
|
||||||
|
roc_mono::ir::Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache);
|
||||||
let main_body =
|
let main_body =
|
||||||
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
roc_mono::inc_dec::visit_declaration(mono_env.arena, mono_env.arena.alloc(main_body));
|
||||||
let mut headers = {
|
let mut headers = {
|
||||||
|
|
|
@ -625,11 +625,11 @@ impl<'a> Stmt<'a> {
|
||||||
env: &mut Env<'a, '_>,
|
env: &mut Env<'a, '_>,
|
||||||
can_expr: roc_can::expr::Expr,
|
can_expr: roc_can::expr::Expr,
|
||||||
procs: &mut Procs<'a>,
|
procs: &mut Procs<'a>,
|
||||||
|
layout_cache: &mut LayoutCache<'a>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut layout_cache = LayoutCache::default();
|
from_can(env, can_expr, procs, layout_cache)
|
||||||
|
|
||||||
from_can(env, can_expr, procs, &mut layout_cache)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_doc<'b, D, A>(&'b self, alloc: &'b D) -> DocBuilder<'b, D, A>
|
pub fn to_doc<'b, D, A>(&'b self, alloc: &'b D) -> DocBuilder<'b, D, A>
|
||||||
where
|
where
|
||||||
D: DocAllocator<'b, A>,
|
D: DocAllocator<'b, A>,
|
||||||
|
|
|
@ -10,21 +10,21 @@ mod helpers;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_reporting {
|
mod test_reporting {
|
||||||
use crate::helpers::test_home;
|
use crate::helpers::test_home;
|
||||||
|
use crate::helpers::{can_expr, infer_expr, CanExprOut, ParseErrOut};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_module::symbol::{Interns, ModuleId};
|
use roc_module::symbol::{Interns, ModuleId};
|
||||||
use roc_mono::ir::{Procs, Stmt};
|
use roc_mono::ir::{Procs, Stmt};
|
||||||
|
use roc_mono::layout::LayoutCache;
|
||||||
use roc_reporting::report::{
|
use roc_reporting::report::{
|
||||||
can_problem, mono_problem, parse_problem, type_problem, Report, BLUE_CODE, BOLD_CODE,
|
can_problem, mono_problem, parse_problem, type_problem, Report, BLUE_CODE, BOLD_CODE,
|
||||||
CYAN_CODE, DEFAULT_PALETTE, GREEN_CODE, MAGENTA_CODE, RED_CODE, RESET_CODE, UNDERLINE_CODE,
|
CYAN_CODE, DEFAULT_PALETTE, GREEN_CODE, MAGENTA_CODE, RED_CODE, RESET_CODE, UNDERLINE_CODE,
|
||||||
WHITE_CODE, YELLOW_CODE,
|
WHITE_CODE, YELLOW_CODE,
|
||||||
};
|
};
|
||||||
|
use roc_reporting::report::{RocDocAllocator, RocDocBuilder};
|
||||||
|
use roc_solve::solve;
|
||||||
use roc_types::pretty_print::name_all_type_vars;
|
use roc_types::pretty_print::name_all_type_vars;
|
||||||
use roc_types::subs::Subs;
|
use roc_types::subs::Subs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
// use roc_region::all;
|
|
||||||
use crate::helpers::{can_expr, infer_expr, CanExprOut, ParseErrOut};
|
|
||||||
use roc_reporting::report::{RocDocAllocator, RocDocBuilder};
|
|
||||||
use roc_solve::solve;
|
|
||||||
|
|
||||||
fn filename_from_string(str: &str) -> PathBuf {
|
fn filename_from_string(str: &str) -> PathBuf {
|
||||||
let mut filename = PathBuf::new();
|
let mut filename = PathBuf::new();
|
||||||
|
@ -87,6 +87,7 @@ mod test_reporting {
|
||||||
let mut ident_ids = interns.all_ident_ids.remove(&home).unwrap();
|
let mut ident_ids = interns.all_ident_ids.remove(&home).unwrap();
|
||||||
|
|
||||||
// Populate Procs and Subs, and get the low-level Expr from the canonical Expr
|
// Populate Procs and Subs, and get the low-level Expr from the canonical Expr
|
||||||
|
let mut layout_cache = LayoutCache::default();
|
||||||
let mut mono_env = roc_mono::ir::Env {
|
let mut mono_env = roc_mono::ir::Env {
|
||||||
arena: &arena,
|
arena: &arena,
|
||||||
subs: &mut subs,
|
subs: &mut subs,
|
||||||
|
@ -94,7 +95,8 @@ mod test_reporting {
|
||||||
home,
|
home,
|
||||||
ident_ids: &mut ident_ids,
|
ident_ids: &mut ident_ids,
|
||||||
};
|
};
|
||||||
let _mono_expr = Stmt::new(&mut mono_env, loc_expr.value, &mut procs);
|
let _mono_expr =
|
||||||
|
Stmt::new(&mut mono_env, loc_expr.value, &mut procs, &mut layout_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((unify_problems, can_problems, mono_problems, home, interns))
|
Ok((unify_problems, can_problems, mono_problems, home, interns))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue