remove skeletons from replaced modules
This commit is contained in:
@@ -746,11 +746,11 @@ setof(Template, Goal, Solution) :-
|
|||||||
( var(H) ->
|
( var(H) ->
|
||||||
throw(error(instantiation_error, clause/2))
|
throw(error(instantiation_error, clause/2))
|
||||||
; callable(H), functor(H, Name, Arity) ->
|
; callable(H), functor(H, Name, Arity) ->
|
||||||
( '$head_is_dynamic'(Module, H) ->
|
( '$no_such_predicate'(Module, H) ->
|
||||||
|
'$fail'
|
||||||
|
; '$head_is_dynamic'(Module, H) ->
|
||||||
'$clause_body_is_valid'(B),
|
'$clause_body_is_valid'(B),
|
||||||
Module:'$clause'(H, B)
|
Module:'$clause'(H, B)
|
||||||
; '$no_such_predicate'(Module, H) ->
|
|
||||||
'$fail'
|
|
||||||
; throw(error(permission_error(access, private_procedure, Name/Arity),
|
; throw(error(permission_error(access, private_procedure, Name/Arity),
|
||||||
clause/2))
|
clause/2))
|
||||||
)
|
)
|
||||||
@@ -767,12 +767,11 @@ clause(H, B) :-
|
|||||||
arg(1, H, Module),
|
arg(1, H, Module),
|
||||||
arg(2, H, F),
|
arg(2, H, F),
|
||||||
'$module_clause'(F, B, Module)
|
'$module_clause'(F, B, Module)
|
||||||
|
; '$no_such_predicate'(user, H) ->
|
||||||
|
'$fail'
|
||||||
; '$head_is_dynamic'(user, H) ->
|
; '$head_is_dynamic'(user, H) ->
|
||||||
'$clause_body_is_valid'(B),
|
'$clause_body_is_valid'(B),
|
||||||
'$clause'(H, B)
|
'$clause'(H, B)
|
||||||
; '$no_such_predicate'(user, H) -> %% '$no_such_predicate' fails if
|
|
||||||
%% H is not callable.
|
|
||||||
'$fail'
|
|
||||||
; throw(error(permission_error(access, private_procedure, Name/Arity),
|
; throw(error(permission_error(access, private_procedure, Name/Arity),
|
||||||
clause/2))
|
clause/2))
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ unload_evacuable(Evacuable) :-
|
|||||||
|
|
||||||
run_initialization_goals(Module) :-
|
run_initialization_goals(Module) :-
|
||||||
( predicate_property(Module:'$initialization_goals'(_), dynamic) ->
|
( predicate_property(Module:'$initialization_goals'(_), dynamic) ->
|
||||||
|
% FIXME: failing here. also, see add_module.
|
||||||
|
'$debug_hook',
|
||||||
findall(Module:Goal, '$call'(builtins:retract(Module:'$initialization_goals'(Goal))), Goals),
|
findall(Module:Goal, '$call'(builtins:retract(Module:'$initialization_goals'(Goal))), Goals),
|
||||||
abolish(Module:'$initialization_goals'/1),
|
abolish(Module:'$initialization_goals'/1),
|
||||||
( maplist(Module:call, Goals) ->
|
( maplist(Module:call, Goals) ->
|
||||||
|
|||||||
@@ -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) {
|
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,
|
Some(module) => module,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
@@ -467,22 +467,29 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
|||||||
for (key, code_index) in &removed_module.code_dir {
|
for (key, code_index) in &removed_module.code_dir {
|
||||||
match removed_module
|
match removed_module
|
||||||
.local_extensible_predicates
|
.local_extensible_predicates
|
||||||
.get(&(CompilationTarget::User, key.clone()))
|
.get(&(CompilationTarget::User, *key))
|
||||||
{
|
{
|
||||||
Some(skeleton) if skeleton.is_multifile => continue,
|
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
|
self.payload.retraction_info
|
||||||
.push_record(RetractionRecord::ReplacedModulePredicate(
|
.push_record(RetractionRecord::ReplacedModulePredicate(
|
||||||
module_name.clone(),
|
module_name,
|
||||||
key.clone(),
|
*key,
|
||||||
old_index_ptr,
|
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);
|
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);
|
let mut module = Module::new(module_decl, listing_src);
|
||||||
|
|
||||||
self.import_builtins_in_module(
|
self.import_builtins_in_module(
|
||||||
module_name.clone(),
|
module_name,
|
||||||
&mut module.code_dir,
|
&mut module.code_dir,
|
||||||
&mut module.op_dir,
|
&mut module.op_dir,
|
||||||
&mut module.meta_predicates,
|
&mut module.meta_predicates,
|
||||||
@@ -904,10 +911,10 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
|||||||
module_decl: ModuleDecl,
|
module_decl: ModuleDecl,
|
||||||
listing_src: &ListingSource,
|
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_module_exports(module_name);
|
||||||
self.remove_replaced_in_situ_module(module_name.clone());
|
self.remove_replaced_in_situ_module(module_name);
|
||||||
|
|
||||||
match self.wam_prelude.indices.modules.get_mut(&module_name) {
|
match self.wam_prelude.indices.modules.get_mut(&module_name) {
|
||||||
Some(module) => {
|
Some(module) => {
|
||||||
@@ -970,7 +977,7 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
|
|||||||
None => {
|
None => {
|
||||||
self.payload
|
self.payload
|
||||||
.retraction_info
|
.retraction_info
|
||||||
.push_record(RetractionRecord::AddedModule(module_name.clone()));
|
.push_record(RetractionRecord::AddedModule(module_name));
|
||||||
|
|
||||||
Module::new(module_decl, listing_src)
|
Module::new(module_decl, listing_src)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1974,13 +1974,21 @@ impl Machine {
|
|||||||
loader
|
loader
|
||||||
.wam_prelude
|
.wam_prelude
|
||||||
.indices
|
.indices
|
||||||
.get_predicate_skeleton_mut(&compilation_target, &key)
|
.remove_predicate_skeleton(&compilation_target, &key);
|
||||||
.map(|skeleton| skeleton.reset());
|
|
||||||
|
|
||||||
let code_index = loader
|
let code_index = loader
|
||||||
.get_or_insert_code_index(key, compilation_target);
|
.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;
|
loader.payload.compilation_target = clause_clause_compilation_target;
|
||||||
|
|
||||||
@@ -2269,7 +2277,6 @@ impl Machine {
|
|||||||
ClauseType::Named(name, arity, _) => {
|
ClauseType::Named(name, arity, _) => {
|
||||||
if let Some(module) = self.indices.modules.get(&(atom!("builtins"))) {
|
if let Some(module) = self.indices.modules.get(&(atom!("builtins"))) {
|
||||||
self.machine_st.fail = !module.code_dir.contains_key(&(name, arity));
|
self.machine_st.fail = !module.code_dir.contains_key(&(name, arity));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3365,7 +3365,7 @@ impl MachineState {
|
|||||||
.unwrap_or(IndexPtr::DynamicUndefined);
|
.unwrap_or(IndexPtr::DynamicUndefined);
|
||||||
|
|
||||||
match index {
|
match index {
|
||||||
IndexPtr::DynamicUndefined => false,
|
IndexPtr::DynamicUndefined | IndexPtr::Undefined => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user