clause_name!("$cpp_multifile_property"),
&SystemClauseType::REPL(REPLCodePtr::DiscontiguousProperty) =>
clause_name!("$cpp_discontiguous_property"),
- &SystemClauseType::REPL(REPLCodePtr::CompilePendingPredicates) =>
- clause_name!("$compile_pending_predicates"),
&SystemClauseType::REPL(REPLCodePtr::AbolishClause) =>
clause_name!("$abolish_clause"),
&SystemClauseType::Close => clause_name!("$close"),
("$cpp_dynamic_property", 3) => Some(SystemClauseType::REPL(REPLCodePtr::DynamicProperty)),
("$cpp_multifile_property", 3) => Some(SystemClauseType::REPL(REPLCodePtr::MultifileProperty)),
("$cpp_discontiguous_property", 3) => Some(SystemClauseType::REPL(REPLCodePtr::DiscontiguousProperty)),
- ("$compile_pending_predicates", 1) => Some(SystemClauseType::REPL(REPLCodePtr::CompilePendingPredicates)),
_ => None,
}
}
'$pop_load_state_payload'(Evacuable),
'$pop_load_context'.
+run_initialization_goals :-
+ prolog_load_context(module, Module),
+ ( predicate_property(Module:'$initialization_goals'(_), dynamic) ->
+ findall(Goal, '$call'(builtins:retract(Module:'$initialization_goals'(Goal))), Goals),
+ ( maplist(Module:call, Goals) ->
+ true
+ ; true %% initialization goals can fail without thwarting the load.
+ )
+ ; true
+ ).
file_load(Stream, Path) :-
file_load(Stream, Path, _).
catch(loader:load_loop(Stream, Evacuable),
E,
(loader:unload_evacuable(Evacuable), throw(E))),
+ run_initialization_goals,
'$pop_load_context'.
catch(loader:load_loop(Stream, Evacuable),
E,
(loader:unload_evacuable(Evacuable), throw(E))),
+ run_initialization_goals,
'$pop_load_context'.
load_loop(Stream, Evacuable) :-
'$add_dynamic_predicate'(Name, Arity, Evacuable).
compile_declaration(initialization(Goal), Evacuable) :-
prolog_load_context(module, Module),
- '$compile_pending_predicates'(Evacuable),
- expand_goal(call(Goal), Module, call(ExpandedGoal)),
- call(ExpandedGoal).
+ assertz(Module:'$initialization_goals'(Goal)).
+
compile_clause(Clause, Evacuable, VNs) :-
self.machine_st.fail = true;
}
-
- pub(crate)
- fn compile_pending_predicates(&mut self) {
- let (mut loader, evacuable_h) = self.loader_from_heap_evacuable(temp_v!(1));
-
- let compile_pending_predicates = || {
- if !loader.predicates.is_empty() {
- loader.compile_and_submit()?;
- }
-
- LiveTermStream::evacuate(loader)
- };
-
- let result = compile_pending_predicates();
- self.restore_load_state_payload(result, evacuable_h);
- }
}
impl<'a> Loader<'a, LiveTermStream> {
MultifileProperty,
DiscontiguousProperty,
DynamicProperty,
- CompilePendingPredicates,
AbolishClause,
Asserta,
Assertz,
REPLCodePtr::DynamicProperty => {
self.dynamic_property();
}
- REPLCodePtr::CompilePendingPredicates => {
- self.compile_pending_predicates();
- }
REPLCodePtr::Assertz => {
self.compile_assert(AppendOrPrepend::Append);
}
write!(f, "REPLCodePtr::MultifileProperty"),
REPLCodePtr::DiscontiguousProperty =>
write!(f, "REPLCodePtr::DiscontiguousProperty"),
- REPLCodePtr::CompilePendingPredicates =>
- write!(f, "REPLCodePtr::CompilePendingPredicates"),
}
}
}