fix incremental compilation and multifile bugs
This commit is contained in:
@@ -834,8 +834,13 @@ asserta_clause(Head, Body) :-
|
|||||||
( Name == (:),
|
( Name == (:),
|
||||||
Arity =:= 2 ->
|
Arity =:= 2 ->
|
||||||
arg(1, Head, Module),
|
arg(1, Head, Module),
|
||||||
arg(2, Head, F),
|
arg(2, Head, HeadAndBody),
|
||||||
module_asserta_clause(F, Body, Module)
|
( HeadAndBody = (F :- Body1) ->
|
||||||
|
true
|
||||||
|
; F = HeadAndBody,
|
||||||
|
Body1 = true
|
||||||
|
),
|
||||||
|
module_asserta_clause(F, Body1, Module)
|
||||||
; '$head_is_dynamic'(user, Head) ->
|
; '$head_is_dynamic'(user, Head) ->
|
||||||
call_asserta(Head, Body, Name, Arity, user)
|
call_asserta(Head, Body, Name, Arity, user)
|
||||||
; '$no_such_predicate'(user, Head) ->
|
; '$no_such_predicate'(user, Head) ->
|
||||||
@@ -883,8 +888,13 @@ assertz_clause(Head, Body) :-
|
|||||||
( Name == (:),
|
( Name == (:),
|
||||||
Arity =:= 2 ->
|
Arity =:= 2 ->
|
||||||
arg(1, Head, Module),
|
arg(1, Head, Module),
|
||||||
arg(2, Head, F),
|
arg(2, Head, HeadAndBody),
|
||||||
module_assertz_clause(F, Body, Module)
|
( HeadAndBody = (F :- Body1) ->
|
||||||
|
true
|
||||||
|
; F = HeadAndBody,
|
||||||
|
Body1 = true
|
||||||
|
),
|
||||||
|
module_assertz_clause(F, Body1, Module)
|
||||||
; '$head_is_dynamic'(user, Head) ->
|
; '$head_is_dynamic'(user, Head) ->
|
||||||
call_assertz(Head, Body, Name, Arity, user)
|
call_assertz(Head, Body, Name, Arity, user)
|
||||||
; '$no_such_predicate'(user, Head) ->
|
; '$no_such_predicate'(user, Head) ->
|
||||||
@@ -973,8 +983,13 @@ retract_clause(Head, Body) :-
|
|||||||
( Name == (:),
|
( Name == (:),
|
||||||
Arity =:= 2 ->
|
Arity =:= 2 ->
|
||||||
arg(1, Head, Module),
|
arg(1, Head, Module),
|
||||||
arg(2, Head, F),
|
arg(2, Head, HeadAndBody),
|
||||||
retract_module_clause(F, Body, Module)
|
( HeadAndBody = (F :- Body1) ->
|
||||||
|
true
|
||||||
|
; F = HeadAndBody,
|
||||||
|
Body1 = true
|
||||||
|
),
|
||||||
|
retract_module_clause(F, Body1, Module)
|
||||||
; '$no_such_predicate'(user, Head) ->
|
; '$no_such_predicate'(user, Head) ->
|
||||||
'$fail'
|
'$fail'
|
||||||
; '$head_is_dynamic'(user, Head) ->
|
; '$head_is_dynamic'(user, Head) ->
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Predicates for reasoning about the operating system (OS) environment.
|
Predicates for reasoning about the operating system (OS) environment.
|
||||||
Written July 2020 by Markus Triska (triska@metalevel.at).
|
Written July 2020 by Markus Triska (triska@metalevel.at).
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ unload_evacuable(Evacuable) :-
|
|||||||
run_initialization_goals :-
|
run_initialization_goals :-
|
||||||
prolog_load_context(module, Module),
|
prolog_load_context(module, Module),
|
||||||
( predicate_property(Module:'$initialization_goals'(_), dynamic) ->
|
( predicate_property(Module:'$initialization_goals'(_), dynamic) ->
|
||||||
findall(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) ->
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -103,12 +103,28 @@ fn lower_bound_of_target_clause(skeleton: &PredicateSkeleton, target_pos: usize)
|
|||||||
return target_pos - 1;
|
return target_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for index in (0..target_pos - 1).rev() {
|
let mut index_loc_opt = None;
|
||||||
|
|
||||||
|
for index in (0..target_pos).rev() {
|
||||||
let current_arg_num = skeleton.clauses[index].opt_arg_index_key.arg_num();
|
let current_arg_num = skeleton.clauses[index].opt_arg_index_key.arg_num();
|
||||||
|
|
||||||
if current_arg_num == 0 || current_arg_num != arg_num {
|
if current_arg_num == 0 || current_arg_num != arg_num {
|
||||||
return index + 1;
|
return index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(index_loc) = index_loc_opt {
|
||||||
|
let current_index_loc = skeleton.clauses[index]
|
||||||
|
.opt_arg_index_key
|
||||||
|
.switch_on_term_loc();
|
||||||
|
|
||||||
|
if Some(index_loc) != current_index_loc {
|
||||||
|
return index + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
index_loc_opt = skeleton.clauses[index]
|
||||||
|
.opt_arg_index_key
|
||||||
|
.switch_on_term_loc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
@@ -1195,7 +1211,7 @@ fn append_compiled_clause(
|
|||||||
retraction_info,
|
retraction_info,
|
||||||
);
|
);
|
||||||
|
|
||||||
if lower_bound == 0 {
|
if lower_bound == 0 && !skeleton.core.is_dynamic {
|
||||||
code_ptr_opt = Some(target_pos_clause_start);
|
code_ptr_opt = Some(target_pos_clause_start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,13 +461,21 @@ impl<'a> LoadState<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn remove_replaced_module(&mut self, module_name: ClauseName) {
|
pub(super) fn remove_replaced_in_situ_module(&mut self, module_name: ClauseName) {
|
||||||
let removed_module = match self.wam.indices.modules.remove(&module_name) {
|
let removed_module = match self.wam.indices.modules.remove(&module_name) {
|
||||||
Some(module) => module,
|
Some(module) => module,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (key, code_index) in &removed_module.code_dir {
|
for (key, code_index) in &removed_module.code_dir {
|
||||||
|
match removed_module
|
||||||
|
.local_extensible_predicates
|
||||||
|
.get(&(CompilationTarget::User, key.clone()))
|
||||||
|
{
|
||||||
|
Some(skeleton) if skeleton.is_multifile => continue,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
if code_index.get() != IndexPtr::Undefined {
|
if code_index.get() != IndexPtr::Undefined {
|
||||||
let old_index_ptr = code_index.replace(IndexPtr::Undefined);
|
let old_index_ptr = code_index.replace(IndexPtr::Undefined);
|
||||||
|
|
||||||
@@ -919,7 +927,7 @@ impl<'a> LoadState<'a> {
|
|||||||
let module_name = module_decl.name.clone();
|
let module_name = module_decl.name.clone();
|
||||||
|
|
||||||
self.remove_module_exports(module_name.clone());
|
self.remove_module_exports(module_name.clone());
|
||||||
self.remove_replaced_module(module_name.clone());
|
self.remove_replaced_in_situ_module(module_name.clone());
|
||||||
|
|
||||||
match self.wam.indices.modules.get_mut(&module_name) {
|
match self.wam.indices.modules.get_mut(&module_name) {
|
||||||
Some(module) => {
|
Some(module) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user