shift to builtins
This commit is contained in:
@@ -141,6 +141,8 @@ impl MachineState {
|
||||
self.heap.append(err);
|
||||
|
||||
self.registers[1] = Addr::HeapCell(h);
|
||||
self.goto_throw();
|
||||
|
||||
self.set_ball();
|
||||
self.unwind_stack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,10 +434,16 @@ pub(crate) trait CallPolicy: Any {
|
||||
},
|
||||
&ClauseType::CallN =>
|
||||
if let Some((name, arity)) = machine_st.setup_call_n(arity) {
|
||||
if let Some(idx) = code_dirs.get(name.clone(), arity, clause_name!("user")) {
|
||||
self.context_call(machine_st, name, arity, idx, lco)
|
||||
} else {
|
||||
Err(machine_st.existence_error(name, arity))
|
||||
let user = clause_name!("user");
|
||||
|
||||
match ClauseType::from(name.clone(), arity, None) {
|
||||
ClauseType::Op(..) | ClauseType::Named(..) =>
|
||||
if let Some(idx) = code_dirs.get(name.clone(), arity, user) {
|
||||
self.context_call(machine_st, name, arity, idx, lco)
|
||||
} else {
|
||||
Err(machine_st.existence_error(name, arity))
|
||||
},
|
||||
ct => self.try_call_clause(machine_st, code_dirs, &ct, arity, lco),
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
|
||||
@@ -1041,7 +1041,15 @@ impl MachineState {
|
||||
self.p = CodePtr::DirEntry(59, clause_name!("builtin"));
|
||||
}
|
||||
|
||||
fn unwind_stack(&mut self) {
|
||||
pub(super) fn set_ball(&mut self) {
|
||||
let addr = self[temp_v!(1)].clone();
|
||||
self.ball.boundary = self.heap.h;
|
||||
|
||||
let mut duplicator = DuplicateBallTerm::new(self);
|
||||
duplicator.duplicate_term(addr);
|
||||
}
|
||||
|
||||
pub(super) fn unwind_stack(&mut self) {
|
||||
self.b = self.block;
|
||||
self.or_stack.truncate(self.b);
|
||||
|
||||
@@ -1614,14 +1622,7 @@ impl MachineState {
|
||||
self.p += 1;
|
||||
},
|
||||
&BuiltInInstruction::SetBall => {
|
||||
let addr = self[temp_v!(1)].clone();
|
||||
self.ball.boundary = self.heap.h;
|
||||
|
||||
{
|
||||
let mut duplicator = DuplicateBallTerm::new(self);
|
||||
duplicator.duplicate_term(addr);
|
||||
};
|
||||
|
||||
self.set_ball();
|
||||
self.p += 1;
|
||||
},
|
||||
&BuiltInInstruction::SetCutPoint(r) =>
|
||||
|
||||
@@ -70,14 +70,15 @@ impl<'a> SubModuleUser for MachineCodeIndex<'a> {
|
||||
impl Machine {
|
||||
pub fn new() -> Self {
|
||||
let atom_tbl = Rc::new(RefCell::new(HashSet::new()));
|
||||
let (code, code_dir, op_dir) = default_build();
|
||||
let op_dir = default_op_dir(); //TODO: change to the builtins module once it's done.
|
||||
//let (code, code_dir, op_dir) = default_build();
|
||||
|
||||
Machine {
|
||||
ms: MachineState::new(atom_tbl),
|
||||
call_policy: Box::new(DefaultCallPolicy {}),
|
||||
cut_policy: Box::new(DefaultCutPolicy {}),
|
||||
code,
|
||||
code_dir,
|
||||
code: Code::new(),
|
||||
code_dir: CodeDir::new(),
|
||||
term_dir: TermDir::new(),
|
||||
op_dir,
|
||||
modules: HashMap::new(),
|
||||
|
||||
Reference in New Issue
Block a user