aboutsummaryrefslogtreecommitdiff
path: root/src/kompsos.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/kompsos.adb')
-rw-r--r--src/kompsos.adb61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/kompsos.adb b/src/kompsos.adb
index f7f0ba9..2efa69b 100644
--- a/src/kompsos.adb
+++ b/src/kompsos.adb
@@ -53,6 +53,40 @@ package body Kompsos is
+ -- States --
+
+ procedure Free is new Ada.Unchecked_Deallocation (State_Component, State_Component_Access);
+
+
+ procedure Initialize
+ (This : in out State_Control) is
+ begin
+ This.Actual := null;
+ end Initialize;
+
+
+ procedure Adjust
+ (This : in out State_Control) is
+ begin
+ if This.Actual /= null then
+ This.Actual.Counter := This.Actual.Counter + 1;
+ end if;
+ end Adjust;
+
+
+ procedure Finalize
+ (This : in out State_Control) is
+ begin
+ if This.Actual /= null then
+ This.Actual.Counter := This.Actual.Counter - 1;
+ if This.Actual.Counter = 0 then
+ Free (This.Actual);
+ end if;
+ end if;
+ end Finalize;
+
+
+
-- Goal Graphs --
procedure Free is new Ada.Unchecked_Deallocation (Graph_Component, Graph_Component_Access);
@@ -213,13 +247,16 @@ package body Kompsos is
(This : in State;
Key : in Variable;
Value : out Term'Class)
- return Boolean is
+ return Boolean
+ is
+ Ptr : State_Component_Access := This.Ctrl.Actual;
begin
- for Bind of This.Actual loop
- if Bind.Key = Key then
- Value := Term'Class (Bind.Elem);
+ while Ptr /= null loop
+ if Ptr.Key = Key then
+ Value := Term'Class (Ptr.Value);
return True;
end if;
+ Ptr := Ptr.Next.Ctrl.Actual;
end loop;
return False;
end Lookup;
@@ -569,20 +606,20 @@ package body Kompsos is
(Subst : in State)
return Term is
begin
- if Subst.Actual.Is_Empty then
+ if Subst.Ctrl.Actual = null then
return Empty_Term;
else
declare
- Min_Pos : Long_Positive := Subst.Actual.First_Index;
- Min_Var : Variable := Subst.Actual.First_Element.Key;
+ Min_Pos : State_Component_Access := Subst.Ctrl.Actual;
+ Marker : State_Component_Access := Min_Pos.Next.Ctrl.Actual;
begin
- for Index in Subst.Actual.First_Index + 1 .. Subst.Actual.Last_Index loop
- if Subst.Actual (Index).Key < Min_Var then
- Min_Pos := Index;
- Min_Var := Subst.Actual (Index).Key;
+ while Marker /= null loop
+ if Marker.Key < Min_Pos.Key then
+ Min_Pos := Marker;
end if;
+ Marker := Marker.Next.Ctrl.Actual;
end loop;
- return Subst.Actual (Min_Pos).Elem.Resolve (Subst);
+ return Min_Pos.Value.Resolve (Subst);
end;
end if;
end Resolve_First;