add max arity checks at various stages (#1459)

This commit is contained in:
Mark Thom
2022-05-21 12:32:48 -06:00
parent b6f77f4e6f
commit 4d23542ef3
8 changed files with 48 additions and 65 deletions

View File

@@ -151,16 +151,13 @@ impl DebrayAllocator {
};
}
fn alloc_reg_to_var<'a, Target>(
fn alloc_reg_to_var<'a, Target: CompilationTarget<'a>>(
&mut self,
var: &String,
lvl: Level,
term_loc: GenContext,
target: &mut Vec<Instruction>,
) -> usize
where
Target: CompilationTarget<'a>,
{
) -> usize {
match term_loc {
GenContext::Head => {
if let Level::Shallow = lvl {
@@ -404,4 +401,9 @@ impl Allocator for DebrayAllocator {
self.arg_c = 1;
self.temp_lb = arity + 1;
}
#[inline(always)]
fn max_reg_allocated(&self) -> usize {
std::cmp::max(self.temp_lb, self.arg_c)
}
}