use in situ code directory from metacall if conventional lookup fails (#238)
This commit is contained in:
@@ -107,13 +107,13 @@ impl SubModuleUser for IndexStore {
|
||||
&mut self.op_dir
|
||||
}
|
||||
|
||||
fn get_code_index(&self, key: PredicateKey, module: ClauseName) -> Option<CodeIndex> {
|
||||
match module.as_str() {
|
||||
fn get_code_index(&self, key: PredicateKey, module_name: ClauseName) -> Option<CodeIndex> {
|
||||
match module_name.as_str() {
|
||||
"user" | "builtin" => self.code_dir.get(&key).cloned(),
|
||||
_ => self
|
||||
.modules
|
||||
.get(&module)
|
||||
.and_then(|ref module| module.code_dir.get(&key).cloned().map(CodeIndex::from)),
|
||||
.modules
|
||||
.get(&module_name)
|
||||
.and_then(|ref module| module.code_dir.get(&key).cloned().map(CodeIndex::from))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ impl SubModuleUser for IndexStore {
|
||||
return;
|
||||
}
|
||||
|
||||
self.code_dir.insert((name, arity), idx);
|
||||
self.code_dir.insert((name.clone(), arity), idx.clone());
|
||||
}
|
||||
|
||||
fn use_qualified_module(
|
||||
@@ -241,7 +241,7 @@ impl Machine {
|
||||
|
||||
pub fn run_init_code(&mut self, code: Code) -> bool {
|
||||
let old_machine_st = self.sink_to_snapshot();
|
||||
self.machine_st.reset();
|
||||
self.machine_st.reset();
|
||||
|
||||
self.code_repo.cached_query = code;
|
||||
self.run_query();
|
||||
@@ -418,14 +418,14 @@ impl Machine {
|
||||
_ =>
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
|
||||
let arity = match &self.machine_st.heap[s+2] {
|
||||
&HeapCellValue::Addr(Addr::Con(Constant::Integer(ref arity))) =>
|
||||
arity.to_usize().unwrap(),
|
||||
_ =>
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
|
||||
exports.push(ModuleExport::PredicateKey((name, arity)));
|
||||
}
|
||||
HeapCellValue::NamedStr(arity, ref name, _)
|
||||
@@ -443,7 +443,7 @@ impl Machine {
|
||||
_ =>
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
|
||||
let prec = match &self.machine_st.heap[s+1] {
|
||||
&HeapCellValue::Addr(Addr::Con(Constant::Integer(ref arity))) =>
|
||||
arity.to_usize().unwrap(),
|
||||
@@ -593,7 +593,7 @@ impl Machine {
|
||||
|
||||
fn sink_to_snapshot(&mut self) -> MachineState {
|
||||
let mut snapshot = MachineState::with_capacity(0);
|
||||
|
||||
|
||||
snapshot.hb = self.machine_st.hb;
|
||||
snapshot.e = self.machine_st.e;
|
||||
snapshot.b = self.machine_st.b;
|
||||
@@ -619,7 +619,7 @@ impl Machine {
|
||||
snapshot
|
||||
}
|
||||
|
||||
fn absorb_snapshot(&mut self, mut snapshot: MachineState) {
|
||||
fn absorb_snapshot(&mut self, mut snapshot: MachineState) {
|
||||
self.machine_st.hb = snapshot.hb;
|
||||
self.machine_st.e = snapshot.e;
|
||||
self.machine_st.b = snapshot.b;
|
||||
@@ -667,7 +667,7 @@ impl Machine {
|
||||
// so hold onto it locally and restore it after the compiler has finished.
|
||||
self.machine_st.fail = false;
|
||||
let cached_query = mem::replace(&mut self.code_repo.cached_query, vec![]);
|
||||
|
||||
|
||||
self.dynamic_transaction(trans_type, p);
|
||||
self.code_repo.cached_query = cached_query;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user