From 0e3cb04b840c3ecc61b9e3efc77af5ebea585d17 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Mon, 17 Nov 2025 14:56:34 +1300 Subject: Refactor of Conjunct Generators --- src/kompsos.ads | 75 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'src/kompsos.ads') diff --git a/src/kompsos.ads b/src/kompsos.ads index ed5c664..7b79d60 100644 --- a/src/kompsos.ads +++ b/src/kompsos.ads @@ -96,16 +96,16 @@ package Kompsos is -- Junction Functions -- - type Conjunct_Zero_Func is access function + type Junction_Zero_Func is access function (This : in World) return World; - type Conjunct_One_Func is access function + type Junction_One_Func is access function (This : in World; Input : in Term'Class) return World; - type Conjunct_Many_Func is access function + type Junction_Many_Func is access function (This : in World; Inputs : in Term_Array) return World; @@ -199,33 +199,33 @@ package Kompsos is function Conjunct (This : in World; - Func : in Conjunct_Zero_Func) + Func : in Junction_Zero_Func) return World; procedure Conjunct (This : in out World; - Func : in Conjunct_Zero_Func); + Func : in Junction_Zero_Func); function Conjunct (This : in World; - Func : in Conjunct_One_Func; + Func : in Junction_One_Func; Input : in Term'Class) return World; procedure Conjunct (This : in out World; - Func : in Conjunct_One_Func; + Func : in Junction_One_Func; Input : in Term'Class); function Conjunct (This : in World; - Func : in Conjunct_Many_Func; + Func : in Junction_Many_Func; Inputs : in Term_Array) return World; procedure Conjunct (This : in out World; - Func : in Conjunct_Many_Func; + Func : in Junction_Many_Func; Inputs : in Term_Array); @@ -534,15 +534,30 @@ private (Left, Right : in out World_Holders.Holder) with Inline; + type Lazy_Kind is (Zero_Arg, One_Arg, Many_Arg); + + type Lazy_Data (Kind : Lazy_Kind) is record + case Kind is + when Zero_Arg => + ZFunc : Junction_Zero_Func; + when One_Arg => + OFunc : Junction_One_Func; + OInput : Term; + when Many_Arg => + MFunc : Junction_Many_Func; + MInput : Term_Array_Holders.Holder; + end case; + end record; + + package Lazy_Holders is new Ada.Containers.Indefinite_Holders (Lazy_Data); + type Generator_Kind is (No_Gen, Fresh_Gen, Unify_Gen, Buffer_Gen, Disjunct_Gen, - Conjunct_Zero_Gen, - Conjunct_One_Gen, - Conjunct_Many_Gen, + Conjunct_Gen, Recurse_Gen); type Generator (Kind : Generator_Kind := No_Gen) is record @@ -550,32 +565,24 @@ private when No_Gen => null; when Fresh_Gen => - Frs_Ident : Generator_ID_Number; - Frs_World : World_Holders.Holder; - Frs_Name : Nametag; + Frs_Ident : Generator_ID_Number; + Frs_World : World_Holders.Holder; + Frs_Name : Nametag; when Unify_Gen => - Uni_World : World_Holders.Holder; - Uni_Term1 : Term; - Uni_Term2 : Term; + Uni_World : World_Holders.Holder; + Uni_Term1 : Term; + Uni_Term2 : Term; when Buffer_Gen => - Buff_World : World_Holders.Holder; + Buff_World : World_Holders.Holder; when Disjunct_Gen => - Dis_World1 : World_Holders.Holder; - Dis_World2 : World_Holders.Holder; - when Conjunct_Zero_Gen => - ConZ_World : World_Holders.Holder; - ConZ_Func : Conjunct_Zero_Func; - when Conjunct_One_Gen => - ConO_World : World_Holders.Holder; - ConO_Func : Conjunct_One_Func; - ConO_Input : Term; - when Conjunct_Many_Gen => - ConM_World : World_Holders.Holder; - ConM_Func : Conjunct_Many_Func; - ConM_Inputs : Term_Array_Holders.Holder; + Dis_World1 : World_Holders.Holder; + Dis_World2 : World_Holders.Holder; + when Conjunct_Gen => + Con_World : World_Holders.Holder; + Con_Data : Lazy_Holders.Holder; when Recurse_Gen => - Rec_World : World_Holders.Holder; - Rec_Index : Positive; + Rec_World : World_Holders.Holder; + Rec_Index : Positive; end case; end record; -- cgit