provide contextual information in the return value of try_in_situ_result

This commit is contained in:
Mark Thom
2020-03-19 20:41:58 -06:00
parent 487fe21e25
commit 057e2d8056
2 changed files with 10 additions and 16 deletions

View File

@@ -437,15 +437,15 @@ impl MachineState {
} }
} }
fn try_in_situ_lookup(name: ClauseName, arity: usize, indices: &IndexStore) -> Option<usize> fn try_in_situ_lookup(name: ClauseName, arity: usize, indices: &IndexStore) -> Option<LocalCodePtr>
{ {
match indices.in_situ_code_dir.get(&(name.clone(), arity)) { match indices.in_situ_code_dir.get(&(name.clone(), arity)) {
Some(p) => Some(*p), Some(p) => Some(LocalCodePtr::InSituDirEntry(*p)),
None => None =>
match indices.code_dir.get(&(name, arity)) { match indices.code_dir.get(&(name, arity)) {
Some(ref idx) => { Some(ref idx) => {
if let IndexPtr::Index(p) = idx.0.borrow().0 { if let IndexPtr::Index(p) = idx.0.borrow().0 {
Some(p) Some(LocalCodePtr::DirEntry(p))
} else { } else {
None None
} }
@@ -464,12 +464,12 @@ fn try_in_situ(
) -> CallResult { ) -> CallResult {
if let Some(p) = try_in_situ_lookup(name.clone(), arity, indices) { if let Some(p) = try_in_situ_lookup(name.clone(), arity, indices) {
if last_call { if last_call {
machine_st.execute_at_index(arity, LocalCodePtr::DirEntry(p)); machine_st.execute_at_index(arity, p);
} else { } else {
machine_st.call_at_index(arity, LocalCodePtr::DirEntry(p)); machine_st.call_at_index(arity, p);
} }
machine_st.p = in_situ_dir_entry!(p); machine_st.p = CodePtr::Local(p);
Ok(()) Ok(())
} else { } else {
let stub = MachineError::functor_stub(name.clone(), arity); let stub = MachineError::functor_stub(name.clone(), arity);

View File

@@ -211,12 +211,6 @@ macro_rules! dir_entry {
}; };
} }
macro_rules! in_situ_dir_entry {
($idx:expr) => {
CodePtr::Local(LocalCodePtr::InSituDirEntry($idx))
};
}
macro_rules! set_code_index { macro_rules! set_code_index {
($idx:expr, $ip:expr, $mod_name:expr) => {{ ($idx:expr, $ip:expr, $mod_name:expr) => {{
let mut idx = $idx.0.borrow_mut(); let mut idx = $idx.0.borrow_mut();