implement new disjunction compilation

This commit is contained in:
Mark
2023-06-17 16:28:56 -06:00
parent b205abe949
commit 0e583d620a
32 changed files with 2877 additions and 2980 deletions

View File

@@ -1,10 +1,7 @@
use crate::parser::ast::*;
use crate::temp_v;
use crate::fixtures::*;
use crate::forms::*;
use crate::instructions::*;
use crate::machine::machine_indices::*;
use crate::targets::*;
use std::cell::Cell;
@@ -16,7 +13,7 @@ pub(crate) trait Allocator {
&mut self,
lvl: Level,
context: GenContext,
code: &mut Code,
code: &mut CodeDeque,
);
fn mark_non_var<'a, Target: CompilationTarget<'a>>(
@@ -24,40 +21,44 @@ pub(crate) trait Allocator {
lvl: Level,
context: GenContext,
cell: &'a Cell<RegType>,
code: &mut Code,
code: &mut CodeDeque,
);
fn mark_reserved_var<'a, Target: CompilationTarget<'a>>(
&mut self,
var_name: Var,
var_num: usize,
lvl: Level,
cell: &'a Cell<VarReg>,
term_loc: GenContext,
code: &mut Code,
code: &mut CodeDeque,
r: RegType,
is_new_var: bool,
);
fn mark_cut_var(&mut self, var_num: usize, chunk_num: usize) -> RegType;
fn mark_var<'a, Target: CompilationTarget<'a>>(
&mut self,
var_name: Var,
var_num: usize,
lvl: Level,
cell: &'a Cell<VarReg>,
context: GenContext,
code: &mut Code,
code: &mut CodeDeque,
);
fn reset(&mut self);
fn reset_contents(&mut self) {}
fn reset_arg(&mut self, arg_num: usize);
fn reset_at_head(&mut self, args: &Vec<Term>);
fn reset_contents(&mut self);
fn advance_arg(&mut self);
/*
fn bindings(&self) -> &AllocVarDict;
fn bindings_mut(&mut self) -> &mut AllocVarDict;
fn take_bindings(self) -> AllocVarDict;
*/
fn max_reg_allocated(&self) -> usize;
// TODO: wha.. why?? grrr. it drains the VarStatus data from vs (which it owns!)
@@ -87,21 +88,4 @@ pub(crate) trait Allocator {
perm_vs
}
*/
fn get(&self, var: Var) -> RegType {
self.bindings()
.get(&var)
.map_or(temp_v!(0), |v| v.as_reg_type())
}
fn is_unbound(&self, var: Var) -> bool {
self.get(var).reg_num() == 0
}
fn record_register(&mut self, var: Var, r: RegType) {
match self.bindings_mut().get_mut(&var).unwrap() {
&mut VarAlloc::Temp(_, ref mut s, _) => *s = r.reg_num(),
&mut VarAlloc::Perm(ref mut s) => *s = r.reg_num(),
}
}
}