remove skeletons from replaced modules
This commit is contained in:
@@ -459,7 +459,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
}
|
||||
|
||||
pub(super) fn remove_replaced_in_situ_module(&mut self, module_name: Atom) {
|
||||
let removed_module = match self.wam_prelude.indices.modules.remove(&module_name) {
|
||||
let mut removed_module = match self.wam_prelude.indices.modules.remove(&module_name) {
|
||||
Some(module) => module,
|
||||
None => return,
|
||||
};
|
||||
@@ -467,22 +467,29 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
for (key, code_index) in &removed_module.code_dir {
|
||||
match removed_module
|
||||
.local_extensible_predicates
|
||||
.get(&(CompilationTarget::User, key.clone()))
|
||||
.get(&(CompilationTarget::User, *key))
|
||||
{
|
||||
Some(skeleton) if skeleton.is_multifile => continue,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if code_index.get() != IndexPtr::Undefined {
|
||||
let old_index_ptr = code_index.replace(IndexPtr::Undefined);
|
||||
let old_index_ptr = code_index.replace(IndexPtr::Undefined);
|
||||
|
||||
self.payload.retraction_info
|
||||
.push_record(RetractionRecord::ReplacedModulePredicate(
|
||||
module_name.clone(),
|
||||
key.clone(),
|
||||
old_index_ptr,
|
||||
));
|
||||
}
|
||||
self.payload.retraction_info
|
||||
.push_record(RetractionRecord::ReplacedModulePredicate(
|
||||
module_name,
|
||||
*key,
|
||||
old_index_ptr,
|
||||
));
|
||||
}
|
||||
|
||||
for (key, skeleton) in removed_module.extensible_predicates.drain(..) {
|
||||
self.payload.retraction_info
|
||||
.push_record(RetractionRecord::RemovedSkeleton(
|
||||
CompilationTarget::Module(module_name),
|
||||
key,
|
||||
skeleton,
|
||||
));
|
||||
}
|
||||
|
||||
self.wam_prelude.indices.modules.insert(module_name, removed_module);
|
||||
@@ -861,7 +868,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
let mut module = Module::new(module_decl, listing_src);
|
||||
|
||||
self.import_builtins_in_module(
|
||||
module_name.clone(),
|
||||
module_name,
|
||||
&mut module.code_dir,
|
||||
&mut module.op_dir,
|
||||
&mut module.meta_predicates,
|
||||
@@ -904,10 +911,10 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
module_decl: ModuleDecl,
|
||||
listing_src: &ListingSource,
|
||||
) {
|
||||
let module_name = module_decl.name.clone();
|
||||
let module_name = module_decl.name;
|
||||
|
||||
self.remove_module_exports(module_name.clone());
|
||||
self.remove_replaced_in_situ_module(module_name.clone());
|
||||
self.remove_module_exports(module_name);
|
||||
self.remove_replaced_in_situ_module(module_name);
|
||||
|
||||
match self.wam_prelude.indices.modules.get_mut(&module_name) {
|
||||
Some(module) => {
|
||||
@@ -970,7 +977,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
||||
None => {
|
||||
self.payload
|
||||
.retraction_info
|
||||
.push_record(RetractionRecord::AddedModule(module_name.clone()));
|
||||
.push_record(RetractionRecord::AddedModule(module_name));
|
||||
|
||||
Module::new(module_decl, listing_src)
|
||||
}
|
||||
|
||||
@@ -1974,13 +1974,21 @@ impl Machine {
|
||||
loader
|
||||
.wam_prelude
|
||||
.indices
|
||||
.get_predicate_skeleton_mut(&compilation_target, &key)
|
||||
.map(|skeleton| skeleton.reset());
|
||||
.remove_predicate_skeleton(&compilation_target, &key);
|
||||
|
||||
let code_index = loader
|
||||
.get_or_insert_code_index(key, compilation_target);
|
||||
|
||||
code_index.set(IndexPtr::DynamicUndefined);
|
||||
code_index.set(IndexPtr::Undefined);
|
||||
|
||||
/*
|
||||
loader
|
||||
.wam_prelude
|
||||
.indices
|
||||
.get_predicate_skeleton_mut(&compilation_target, &key)
|
||||
.map(|skeleton| skeleton.reset());
|
||||
|
||||
*/
|
||||
|
||||
loader.payload.compilation_target = clause_clause_compilation_target;
|
||||
|
||||
@@ -2269,7 +2277,6 @@ impl Machine {
|
||||
ClauseType::Named(name, arity, _) => {
|
||||
if let Some(module) = self.indices.modules.get(&(atom!("builtins"))) {
|
||||
self.machine_st.fail = !module.code_dir.contains_key(&(name, arity));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3365,7 +3365,7 @@ impl MachineState {
|
||||
.unwrap_or(IndexPtr::DynamicUndefined);
|
||||
|
||||
match index {
|
||||
IndexPtr::DynamicUndefined => false,
|
||||
IndexPtr::DynamicUndefined | IndexPtr::Undefined => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user