summaryrefslogtreecommitdiff
path: root/src/kompsos.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/kompsos.ads')
-rw-r--r--src/kompsos.ads85
1 files changed, 75 insertions, 10 deletions
diff --git a/src/kompsos.ads b/src/kompsos.ads
index c25cf52..bca09b8 100644
--- a/src/kompsos.ads
+++ b/src/kompsos.ads
@@ -132,6 +132,28 @@ package Kompsos is
Right : in World);
+
+
+ function Recurse
+ (This : in World)
+ return World;
+
+ procedure Recurse
+ (This : in out World);
+
+
+
+
+ function Take
+ (This : in World;
+ Count : in Natural)
+ return World;
+
+ procedure Take
+ (This : in out World;
+ Count : in Natural);
+
+
private
@@ -151,7 +173,7 @@ private
- -- 2^32 possible variables per World is enough for anybody, right?
+ -- 2^32 possible Variables per World is enough for anybody, right?
type ID_Number is mod 2 ** 32;
type Variable is record
@@ -217,25 +239,68 @@ private
- -- obviously this World definition will need revision for delays and generators
+ type World_Access is access World;
- -- going to have to turn worlds into a similar sort of reference counted recursive
- -- controlled type along the lines of what terms are, in order to make them into generators
+ type Generator_Kind is (No_Gen, Fresh_Gen, Unify_Gen, Disjunct_Gen, Recurse_Gen);
+
+ type Generator (Kind : Generator_Kind := No_Gen) is record
+ case Kind is
+ when No_Gen =>
+ null;
+ when Fresh_Gen =>
+ FrG_World : World_Access;
+ FrG_Index : Positive;
+ FrG_Name : SU.Unbounded_String;
+ when Unify_Gen =>
+ UniG_World : World_Access;
+ UniG_Index : Positive;
+ UniG_Term1 : Term;
+ UniG_Term2 : Term;
+ when Disjunct_Gen =>
+ DisG_World1 : World_Access;
+ DisG_Index1 : Positive;
+ DisG_World2 : World_Access;
+ DisG_Index2 : Positive;
+ when Recurse_Gen =>
+ RecG_World : World_Access;
+ RecG_Index : Positive;
+ end case;
+ end record;
package State_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => State);
- use type State_Vectors.Vector;
-
- type World is tagged record
+ type World is new Ada.Finalization.Controlled with record
Possibles : State_Vectors.Vector;
Next_Ident : ID_Number;
+ Engine : Generator;
end record;
- Empty_World : constant World :=
- (Possibles => State_Vectors.Empty_Vector & Empty_State,
- Next_Ident => 0);
+ overriding procedure Adjust
+ (This : in out World);
+
+ overriding procedure Finalize
+ (This : in out World);
+
+ function Has_State
+ (This : in out World;
+ Index : in Positive)
+ return Boolean;
+
+ procedure Rollover
+ (This : in out World);
+
+ procedure Roll_Until
+ (This : in out World;
+ Index : in Positive);
+
+ use type State_Vectors.Vector;
+
+ Empty_World : constant World := (Ada.Finalization.Controlled with
+ Possibles => State_Vectors.Empty_Vector & Empty_State,
+ Next_Ident => 0,
+ Engine => (Kind => No_Gen));
end Kompsos;