mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Improve debug stuff a bit
This commit is contained in:
parent
887ec9860a
commit
60e583fb78
4 changed files with 45 additions and 16 deletions
|
@ -88,14 +88,14 @@ fn int_is_even(var_store: &VarStore) -> Def {
|
|||
fn list_len(var_store: &VarStore) -> Def {
|
||||
use crate::expr::Expr::*;
|
||||
|
||||
// Polymorphic wrapper around LowLevel::ListGet
|
||||
// Polymorphic wrapper around LowLevel::ListLen
|
||||
let arg = Symbol::LIST_LEN_ARG;
|
||||
|
||||
defn(
|
||||
Symbol::LIST_LEN,
|
||||
vec![Symbol::LIST_LEN_ARG],
|
||||
vec![arg],
|
||||
var_store,
|
||||
RunLowLevel(LowLevel::ListLen {
|
||||
arg_from_scope: Symbol::LIST_LEN_ARG,
|
||||
}),
|
||||
RunLowLevel(LowLevel::ListLen { arg }),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -119,11 +119,9 @@ fn list_get(var_store: &VarStore) -> Def {
|
|||
Symbol::NUM_LT,
|
||||
vec![
|
||||
Var(Symbol::LIST_GET_ARG_INDEX),
|
||||
call(
|
||||
Symbol::LIST_LEN,
|
||||
vec![Var(Symbol::LIST_GET_ARG_LIST)],
|
||||
var_store,
|
||||
),
|
||||
RunLowLevel(LowLevel::ListLen {
|
||||
arg: Symbol::LIST_GET_ARG_LIST,
|
||||
}),
|
||||
],
|
||||
var_store,
|
||||
),
|
||||
|
|
|
@ -698,9 +698,9 @@ pub fn build_expr<'a, 'ctx, 'env>(
|
|||
todo!("LLVM build runtime error of {:?}", expr);
|
||||
}
|
||||
RunLowLevel(op) => match op {
|
||||
LowLevel::ListLen { arg_from_scope } => BasicValueEnum::IntValue(load_list_len(
|
||||
LowLevel::ListLen { arg } => BasicValueEnum::IntValue(load_list_len(
|
||||
env.builder,
|
||||
load_symbol(env, scope, arg_from_scope).into_struct_value(),
|
||||
load_symbol(env, scope, arg).into_struct_value(),
|
||||
)),
|
||||
},
|
||||
}
|
||||
|
@ -715,7 +715,7 @@ fn load_symbol<'a, 'ctx, 'env>(
|
|||
Some((_, ptr)) => env
|
||||
.builder
|
||||
.build_load(*ptr, symbol.ident_string(&env.interns)),
|
||||
None => panic!("Could not find a var for {:?} in scope {:?}", symbol, scope),
|
||||
None => panic!("There was no entry for {:?} in scope {:?}", symbol, scope),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ use crate::symbol::Symbol;
|
|||
/// into an Expr when added directly by can::builtins
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum LowLevel {
|
||||
ListLen { arg_from_scope: Symbol },
|
||||
ListLen { arg: Symbol },
|
||||
}
|
||||
|
|
|
@ -50,8 +50,22 @@ impl<'a> Procs<'a> {
|
|||
loc_args: std::vec::Vec<(Variable, Located<roc_can::pattern::Pattern>)>,
|
||||
loc_body: Located<roc_can::expr::Expr>,
|
||||
ret_var: Variable,
|
||||
layout_cache: &mut LayoutCache<'a>,
|
||||
) {
|
||||
let (_, pattern_symbols, body) = patterns_to_when(env, loc_args, ret_var, loc_body);
|
||||
let (pattern_vars, pattern_symbols, body) =
|
||||
patterns_to_when(env, loc_args, ret_var, loc_body);
|
||||
|
||||
let layout = layout_cache
|
||||
.from_var(env.arena, annotation, env.subs, env.pointer_size)
|
||||
.unwrap_or_else(|err| panic!("TODO turn fn_var into a RuntimeError {:?}", err));
|
||||
|
||||
let pending = PendingSpecialization {
|
||||
ret_var,
|
||||
fn_var: annotation,
|
||||
pattern_vars,
|
||||
};
|
||||
|
||||
self.add_pending_specialization(name, layout.clone(), pending);
|
||||
|
||||
// a named closure
|
||||
self.partial_procs.insert(
|
||||
|
@ -1075,7 +1089,15 @@ fn from_can_defs<'a>(
|
|||
|
||||
let (loc_body, ret_var) = *boxed_body;
|
||||
|
||||
procs.insert_named(env, *symbol, ann, loc_args, loc_body, ret_var);
|
||||
procs.insert_named(
|
||||
env,
|
||||
*symbol,
|
||||
ann,
|
||||
loc_args,
|
||||
loc_body,
|
||||
ret_var,
|
||||
layout_cache,
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -1454,8 +1476,15 @@ pub fn specialize_all<'a>(
|
|||
.unwrap_or_else(|| panic!("Could not find partial_proc for {:?}", name))
|
||||
.clone();
|
||||
|
||||
dbg!(
|
||||
"{:?} is specializing partial_proc {:?}",
|
||||
&name,
|
||||
&partial_proc
|
||||
);
|
||||
|
||||
match specialize(env, &mut procs, name, layout_cache, pending, partial_proc) {
|
||||
Ok(proc) => {
|
||||
dbg!("{:?} specialized to {:?}", &name, &proc);
|
||||
answer.push((name, layout, proc));
|
||||
}
|
||||
Err(()) => {
|
||||
|
@ -1505,6 +1534,8 @@ fn specialize<'a>(
|
|||
|
||||
let mut proc_args = Vec::with_capacity_in(pattern_vars.len(), &env.arena);
|
||||
|
||||
debug_assert!(pattern_vars.len() == pattern_symbols.len());
|
||||
|
||||
for (arg_var, arg_name) in pattern_vars.iter().zip(pattern_symbols.iter()) {
|
||||
let layout = layout_cache.from_var(&env.arena, *arg_var, env.subs, env.pointer_size)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue