From 9b4f18b81c9709efe7bfdef1d44197e21931aa73 Mon Sep 17 00:00:00 2001 From: "Jose F. Morales" Date: Thu, 1 Aug 2024 19:29:19 +0200 Subject: [PATCH] (core) moved native/2 and regtype/2 info to p_unit_db Src-commit: 9d7e822b655e3c5fff44e733e47573aca97ab060 --- core/lib/compiler/p_unit/p_unit.pl | 24 +++++++++--------------- core/lib/compiler/p_unit/p_unit_db.pl | 11 ++++++++++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/core/lib/compiler/p_unit/p_unit.pl b/core/lib/compiler/p_unit/p_unit.pl index aef7ad940..052961fcb 100644 --- a/core/lib/compiler/p_unit/p_unit.pl +++ b/core/lib/compiler/p_unit/p_unit.pl @@ -1331,9 +1331,7 @@ retractall_fact(pl_output_op(_, _, _)), retractall_fact(pl_output_package(_)), % - retractall_fact(internal_pred_name(_,_,_)), - retractall_fact(p_unit:native(_,_)), - retractall_fact(regtype(_,_)). % local data + retractall_fact(internal_pred_name(_,_,_)). % assert_curr_files([],[]). % assert_curr_files([A|As],[M|Ms]):- @@ -1714,11 +1712,7 @@ :- use_module(library(compiler/p_unit/unexpand), [unexpand_meta_calls/2]). -:- redefining(native/2). % also in basic_props % TODO: rename? -:- data native/2. -:- data regtype/2. - -% Fill p_unit:native/2 and regtype/2 from assertions +% Fill pgm_native/2 and pgm_regtype/2 from assertions init_props :- % identify and assert native props (also fills pending init regtypes) ( % (failure-driven loop) @@ -1749,7 +1743,7 @@ ( % (failure-driven loop) builtin(native(Goal,Prop),Native), member(Native,Comp), - asserta_fact(p_unit:native(Goal,Prop)), + asserta_fact(pgm_native(Goal,Prop)), fail ; true ), @@ -1758,7 +1752,7 @@ member(Regtype,Comp), \+ pending_init_regtype(Goal,_) -> unexpand_meta_calls(Prop0,NProp0), % TODO: why? (JF) - asserta_fact(regtype(Goal,NProp0)), + asserta_fact(pgm_regtype(Goal,NProp0)), assertz_fact(pending_init_regtype(Goal,NProp0)) ; true ), @@ -1767,7 +1761,7 @@ % Fill regtype definition init_regtype(Head,NProp0) :- - %asserta_fact(regtype(Head,NProp0)), + %asserta_fact(pgm_regtype(Head,NProp0)), %display(user_error, rt(Head,NProp0)), nl(user_error), % TODO: equivalent to prop_to_native/2 in this case ( prop_to_native_(Head,NProp) -> true @@ -1804,7 +1798,7 @@ prop_to_native(Prop,_NProp):- var(Prop), !, throw(error(instantiation_error(Prop), prop_to_native/2)). prop_to_native(Prop,NProp2):- - current_fact(regtype(Prop,NProp0)), !, + current_fact(pgm_regtype(Prop,NProp0)), !, NProp2=regtype(NProp), ( prop_to_native_(Prop,NProp) -> true % TODO: why? ; NProp=NProp0 @@ -1814,7 +1808,7 @@ % TODO: Creates choicepoints. Intended? prop_to_native_(Prop,NProp):- - current_fact(p_unit:native(Prop,NProp)). + current_fact(pgm_native(Prop,NProp)). prop_to_native_(Prop,NProp):- native_property(Prop,NProp). % builtin tables @@ -1827,9 +1821,9 @@ native_to_prop(NProp2,Prop) :- ( NProp2 = regtype(NProp) -> RegType=yes ; NProp=NProp2, RegType=no ), % - ( current_fact(p_unit:native(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing + ( current_fact(pgm_native(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing ; native_property(Prop0,NProp) -> Prop=Prop0 % builtin tables % TODO: bad indexing - ; RegType=yes, current_fact(regtype(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing + ; RegType=yes, current_fact(pgm_regtype(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing ; fail ). diff --git a/core/lib/compiler/p_unit/p_unit_db.pl b/core/lib/compiler/p_unit/p_unit_db.pl index fc1c713b1..2402f882c 100644 --- a/core/lib/compiler/p_unit/p_unit_db.pl +++ b/core/lib/compiler/p_unit/p_unit_db.pl @@ -66,6 +66,8 @@ :- export(impl_defines/2). :- export(pgm_assertion_read/9). :- export(pgm_prop_clause_read/7). % (for abolish_related_info/1) +:- export(pgm_native/2). +:- export(pgm_regtype/2). :- data curr_module/1. :- data curr_file/2. @@ -84,6 +86,8 @@ :- data pgm_prop_clause_read/7. :- data source_clause/3. :- data locator/2. +:- data pgm_native/2. +:- data pgm_regtype/2. % (libcache) :- data lib_defines_module/2. @@ -97,6 +101,8 @@ :- data lib_impl_defines/2. :- data lib_assertion_read/9. :- data lib_prop_clause_read/7. +:- data lib_native/2. +:- data lib_regtype/2. % --------------------------------------------------------------------------- @@ -129,7 +135,10 @@ :- doc(cleanup_assrt_db, "Cleanups the assrt database."). cleanup_assrt_db :- retractall_fact(pgm_assertion_read(_,_,_,_,_,_,_,_,_)), - retractall_fact(assertion_of(_,_,_,_,_,_,_,_,_)). + retractall_fact(assertion_of(_,_,_,_,_,_,_,_,_)), + % (extracted from assertions) + retractall_fact(pgm_native(_,_)), + retractall_fact(pgm_regtype(_,_)). :- export(cleanup_clause_db/0). % TODO: needed for some clause rewrites :- doc(cleanup_clause_db,"Cleans up the clause_db database.").