From 81677f223feda05f619128f562ec75d330730ae0 Mon Sep 17 00:00:00 2001 From: "Jose F. Morales" Date: Thu, 1 Aug 2024 20:41:34 +0200 Subject: [PATCH] (core) p_unit: save native/2 and regtype/2 info in lib cache Src-commit: 5db0586d103c9557be5c63b2c8f8138ef71e3e6b --- core/lib/compiler/p_unit/p_unit.pl | 8 ++++---- core/lib/compiler/p_unit/p_unit_db.pl | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/core/lib/compiler/p_unit/p_unit.pl b/core/lib/compiler/p_unit/p_unit.pl index 052961fc..725f2d32 100644 --- a/core/lib/compiler/p_unit/p_unit.pl +++ b/core/lib/compiler/p_unit/p_unit.pl @@ -1798,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(pgm_regtype(Prop,NProp0)), !, + prop_regtype(Prop,NProp0), !, NProp2=regtype(NProp), ( prop_to_native_(Prop,NProp) -> true % TODO: why? ; NProp=NProp0 @@ -1808,7 +1808,7 @@ % TODO: Creates choicepoints. Intended? prop_to_native_(Prop,NProp):- - current_fact(pgm_native(Prop,NProp)). + prop_native(Prop,NProp). prop_to_native_(Prop,NProp):- native_property(Prop,NProp). % builtin tables @@ -1821,9 +1821,9 @@ native_to_prop(NProp2,Prop) :- ( NProp2 = regtype(NProp) -> RegType=yes ; NProp=NProp2, RegType=no ), % - ( current_fact(pgm_native(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing + ( prop_native(Prop0,NProp) -> Prop=Prop0 % TODO: bad indexing ; native_property(Prop0,NProp) -> Prop=Prop0 % builtin tables % TODO: bad indexing - ; RegType=yes, current_fact(pgm_regtype(Prop0,NProp)) -> Prop=Prop0 % TODO: bad indexing + ; RegType=yes, prop_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 2402f882..0a7cd33a 100644 --- a/core/lib/compiler/p_unit/p_unit_db.pl +++ b/core/lib/compiler/p_unit/p_unit_db.pl @@ -15,6 +15,8 @@ removeall_assertion_read/9, ref_assertion_read/10, assertion_of/9, % TODO: DO NOT EXPORT! erase after normalization + prop_regtype/2, + prop_native/2, % ------ % (clause_db) clause_read/7, @@ -163,7 +165,10 @@ % retractall_fact(lib_assertion_read(_,_,_,_,_,_,_,_,_)), % - retractall_fact(lib_prop_clause_read(_,_,_,_,_,_,_)). + retractall_fact(lib_prop_clause_read(_,_,_,_,_,_,_)), + % + retractall_fact(lib_native(_,_)), + retractall_fact(lib_regtype(_,_)). % =========================================================================== %! # Module interface (itf) @@ -481,6 +486,16 @@ assertion_type(assertion_read(_,_,_,Type,_,_,_,_,_),Type). assertion_type(pgm_assertion_read(_,_,_,Type,_,_,_,_,_),Type). +prop_native(Goal,Prop) :- + pgm_native(Goal,Prop). +prop_native(Goal,Prop) :- + lib_native(Goal,Prop). + +prop_regtype(Goal,Prop) :- + pgm_regtype(Goal,Prop). +prop_regtype(Goal,Prop) :- + lib_regtype(Goal,Prop). + % =========================================================================== %! # Clauses (and other directives) @@ -574,6 +589,9 @@ % dump_lib_data(lib_prop_clause_read(M, Head, Body, VarNames, Source, LB, LE)) :- prop_clause_read(M, Head, Body, VarNames, Source, LB, LE). +% +dump_lib_data(lib_regtype(Goal,Prop)) :- prop_regtype(Goal,Prop), get_module_from_sg(Goal,M), \+ fake_module_name(M). % TODO: \+ fake needed here? +dump_lib_data(lib_native(Goal,Prop)) :- prop_native(Goal,Prop), get_module_from_sg(Goal,M), \+ fake_module_name(M). % TODO: \+ fake needed here? % Adding data (for restoring) add_lib_data(lib_defines_module(A,B)) :- !,