|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 17294 (0x438e)
Types: TextFile
Names: »B«
└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
└─⟦124ff5788⟧ »DATA«
└─⟦this⟧
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
└─⟦6f12a12be⟧ »DATA«
└─⟦this⟧
with Context;
with Debugger;
with Instance;
with Tuple;
with Tuple_Collection;
with Unbounded_Array;
package body Engine_Lru is
package Utc is new Unbounded_Array (Element => Tuple.Object,
Content => Tuple_Collection.Object);
Max_Lru : constant Positive := Context.Max_Rule;
type Sorted_Rule is array (1 .. Max_Lru) of Context.Rule_Id;
type Lru_Resolution is
record
Rule_Array : Sorted_Rule := (others => 0);
Count : Natural := 0;
end record;
Lru_Strategy_Rules : Lru_Resolution;
Local_Context : Context.Reference;
------------------------------------------------------------------------------
function Evaluate_Tuple_Collection
(For_Rule : Context.Rule_Id) return Tuple_Collection.Object is
An_Object : Utc.Object;
begin
if not Context.Is_Masked (In_Context => Local_Context,
The_Rule => For_Rule) then
case For_Rule is
when 1 =>
An_Object := Utc.Create (Condition_1);
when 2 =>
An_Object := Utc.Create (Condition_2);
when 3 =>
An_Object := Utc.Create (Condition_3);
when 4 =>
An_Object := Utc.Create (Condition_4);
when 5 =>
An_Object := Utc.Create (Condition_5);
when 6 =>
An_Object := Utc.Create (Condition_6);
when 7 =>
An_Object := Utc.Create (Condition_7);
when 8 =>
An_Object := Utc.Create (Condition_8);
when 9 =>
An_Object := Utc.Create (Condition_9);
when 10 =>
An_Object := Utc.Create (Condition_10);
when 11 =>
An_Object := Utc.Create (Condition_11);
when 12 =>
An_Object := Utc.Create (Condition_12);
when 13 =>
An_Object := Utc.Create (Condition_13);
when 14 =>
An_Object := Utc.Create (Condition_14);
when 15 =>
An_Object := Utc.Create (Condition_15);
when 16 =>
An_Object := Utc.Create (Condition_16);
when 17 =>
An_Object := Utc.Create (Condition_17);
when 18 =>
An_Object := Utc.Create (Condition_18);
when 19 =>
An_Object := Utc.Create (Condition_19);
when 20 =>
An_Object := Utc.Create (Condition_20);
when 21 =>
An_Object := Utc.Create (Condition_21);
when 22 =>
An_Object := Utc.Create (Condition_22);
when 23 =>
An_Object := Utc.Create (Condition_23);
when 24 =>
An_Object := Utc.Create (Condition_24);
when 25 =>
An_Object := Utc.Create (Condition_25);
when 26 =>
An_Object := Utc.Create (Condition_26);
when 27 =>
An_Object := Utc.Create (Condition_27);
when 28 =>
An_Object := Utc.Create (Condition_28);
when 29 =>
An_Object := Utc.Create (Condition_29);
when 30 =>
An_Object := Utc.Create (Condition_30);
when others =>
null;
end case;
end if;
declare
A_Tuple_Collection : constant Tuple_Collection.Object :=
Utc.Get (An_Object);
begin
if Debugger_On then
if For_Rule /= Context.Null_Rule and then
Debugger.Is_Debugged (Debugger.Condition_Evalued) then
Debugger.Send_Condition_Evalued
(In_Context => Local_Context,
With_Rule => For_Rule,
Result => Tuple_Collection.Is_Not_Null
(A_Tuple_Collection),
Facts => A_Tuple_Collection);
end if;
end if;
Utc.Free (An_Object);
return A_Tuple_Collection;
end;
end Evaluate_Tuple_Collection;
------------------------------------------------------------------------------
procedure Execute_Tuple (For_Tuple : Tuple.Object;
For_Rule : Context.Rule_Id) is
begin
case For_Rule is
when 1 =>
Action_1 (For_Tuple);
when 2 =>
Action_2 (For_Tuple);
when 3 =>
Action_3 (For_Tuple);
when 4 =>
Action_4 (For_Tuple);
when 5 =>
Action_5 (For_Tuple);
when 6 =>
Action_6 (For_Tuple);
when 7 =>
Action_7 (For_Tuple);
when 8 =>
Action_8 (For_Tuple);
when 9 =>
Action_9 (For_Tuple);
when 10 =>
Action_10 (For_Tuple);
when 11 =>
Action_11 (For_Tuple);
when 12 =>
Action_12 (For_Tuple);
when 13 =>
Action_13 (For_Tuple);
when 14 =>
Action_14 (For_Tuple);
when 15 =>
Action_15 (For_Tuple);
when 16 =>
Action_16 (For_Tuple);
when 17 =>
Action_17 (For_Tuple);
when 18 =>
Action_18 (For_Tuple);
when 19 =>
Action_19 (For_Tuple);
when 20 =>
Action_20 (For_Tuple);
when 21 =>
Action_21 (For_Tuple);
when 22 =>
Action_22 (For_Tuple);
when 23 =>
Action_23 (For_Tuple);
when 24 =>
Action_24 (For_Tuple);
when 25 =>
Action_25 (For_Tuple);
when 26 =>
Action_26 (For_Tuple);
when 27 =>
Action_27 (For_Tuple);
when 28 =>
Action_28 (For_Tuple);
when 29 =>
Action_29 (For_Tuple);
when 30 =>
Action_30 (For_Tuple);
when others =>
null;
end case;
if Debugger_On then
if For_Rule /= Context.Null_Rule and then
(Debugger.Is_Debugged (Debugger.Choosed_Action) or
Debugger.Is_Debugged (Debugger.Action_Fact)) then
Debugger.Send_Choosed_Action (In_Context => Local_Context,
The_Rule => For_Rule,
The_Fact => For_Tuple);
end if;
Debugger.Send_New_Step;
if For_Rule = Context.Null_Rule then
Debugger.Send_Failed;
end if;
end if;
end Execute_Tuple;
------------------------------------------------------------------------------
procedure Lrureset is
begin
for I in 1 .. Max_Lru loop
Lru_Strategy_Rules.Rule_Array (I) := 0;
end loop;
Lru_Strategy_Rules.Count := 0;
end Lrureset;
------------------------------------------------------------------------------
function Lru_Infer return Boolean is
The_Rule : Context.Rule_Id := Context.Null_Rule;
Pos : Natural := 0;
Last_Pos : Natural := Integer'Last;
A_Tuple : Tuple.Object;
begin
for I in 1 .. Used_Rules loop
if Tuple_Collection.Is_Not_Null
(Evaluate_Tuple_Collection (Context.Rule_Id (I))) then
Pos := 0;
for J in 1 .. Lru_Strategy_Rules.Count loop
if Lru_Strategy_Rules.Rule_Array (J) = I then
Pos := J;
end if;
end loop;
if Pos = 0 then
The_Rule := Context.Rule_Id (I);
exit;
elsif Pos < Last_Pos then
Last_Pos := Pos;
The_Rule := Lru_Strategy_Rules.Rule_Array (Last_Pos);
end if;
end if;
end loop;
if The_Rule = Context.Null_Rule then
Lrureset;
return False;
end if;
Lru_Strategy_Rules.Count := Lru_Strategy_Rules.Count + 1;
if Lru_Strategy_Rules.Count > Max_Lru then
Lru_Strategy_Rules.Count := Max_Lru;
for I in 1 .. Max_Lru - 1 loop
Lru_Strategy_Rules.Rule_Array (I) :=
Lru_Strategy_Rules.Rule_Array (I + 1);
end loop;
end if;
Lru_Strategy_Rules.Rule_Array (Lru_Strategy_Rules.Count) :=
Context.Rule_Id (The_Rule);
A_Tuple := Tuple_Collection.First
(Of_Tuple_Collection =>
Evaluate_Tuple_Collection
(For_Rule => Context.Rule_Id (The_Rule)));
Execute_Tuple (A_Tuple, The_Rule);
return True;
end Lru_Infer;
------------------------------------------------------------------------------
function Lru_Infer_Debug return Boolean is
The_Rule : Context.Rule_Id := Context.Null_Rule;
Pos : Natural := 0;
Last_Pos : Natural := Integer'Last;
A_Tuple : Tuple.Object;
begin
Debugger.Send_Conflict_Set_Started;
for I in 1 .. Used_Rules loop
if Tuple_Collection.Is_Not_Null
(Evaluate_Tuple_Collection (Context.Rule_Id (I))) then
Debugger.Send_Conflict_Set_Finished;
Pos := 0;
for J in 1 .. Lru_Strategy_Rules.Count loop
if Lru_Strategy_Rules.Rule_Array (J) = I then
Pos := J;
end if;
end loop;
if Pos = 0 then
The_Rule := Context.Rule_Id (I);
exit;
elsif Pos < Last_Pos then
Last_Pos := Pos;
The_Rule := Lru_Strategy_Rules.Rule_Array (Last_Pos);
end if;
end if;
end loop;
if The_Rule = Context.Null_Rule then
Lrureset;
Debugger.Send_Failed;
return False;
end if;
Lru_Strategy_Rules.Count := Lru_Strategy_Rules.Count + 1;
if Lru_Strategy_Rules.Count > Max_Lru then
Lru_Strategy_Rules.Count := Max_Lru;
for I in 1 .. Max_Lru - 1 loop
Lru_Strategy_Rules.Rule_Array (I) :=
Lru_Strategy_Rules.Rule_Array (I + 1);
end loop;
end if;
Lru_Strategy_Rules.Rule_Array (Lru_Strategy_Rules.Count) :=
Context.Rule_Id (The_Rule);
A_Tuple := Tuple_Collection.First
(Of_Tuple_Collection =>
Evaluate_Tuple_Collection
(For_Rule => Context.Rule_Id (The_Rule)));
if Debugger.Is_Debugged (Debugger.Choosed_Rule) or
Debugger.Is_Debugged (Debugger.Rule_Facts) then
Debugger.Send_Choosed_Rule (In_Context => Local_Context,
The_Rule => The_Rule,
The_Fact => A_Tuple);
end if;
Execute_Tuple (A_Tuple, The_Rule);
Debugger.Send_New_Step;
return True;
end Lru_Infer_Debug;
------------------------------------------------------------------------------
generic
with function Inferstrategy return Boolean;
Strategynam : String := " ??? ";
function Stepnumber (Step : Natural) return Boolean;
function Stepnumber (Step : Natural) return Boolean is
A_Step : Boolean;
begin
if Debugger_On then
Debugger.Send_Strategy_Used (With_Name => Context.Lru);
end if;
if Step = Instance.Any then
loop
A_Step := Inferstrategy;
exit when not A_Step;
end loop;
else
for I in 1 .. Step loop
A_Step := Inferstrategy;
exit when not A_Step;
end loop;
end if;
return A_Step;
end Stepnumber;
function Lru_Strategy is new Stepnumber (Lru_Infer, "LRU");
function Lru_Strategy_Debug is new Stepnumber (Lru_Infer_Debug, "LRU");
function Inference (Step : Natural := 1) return Boolean is
begin
if Context."=" (Resolution, Context.Lru) then
if Debugger_On then
Debugger.Send_Context_Entered (With_Number => Local_Context);
return Lru_Strategy_Debug (Step);
else
return Lru_Strategy (Step);
end if;
else
raise Illegal_Strategy;
end if;
end Inference;
begin
Local_Context := Context.Create (With_Name => Context_Name);
Context.Add (In_Context => Local_Context,
The_Rule => 1,
With_Name => Name_1);
Context.Add (In_Context => Local_Context,
The_Rule => 2,
With_Name => Name_2);
Context.Add (In_Context => Local_Context,
The_Rule => 3,
With_Name => Name_3);
Context.Add (In_Context => Local_Context,
The_Rule => 4,
With_Name => Name_4);
Context.Add (In_Context => Local_Context,
The_Rule => 5,
With_Name => Name_5);
Context.Add (In_Context => Local_Context,
The_Rule => 6,
With_Name => Name_6);
Context.Add (In_Context => Local_Context,
The_Rule => 7,
With_Name => Name_7);
Context.Add (In_Context => Local_Context,
The_Rule => 8,
With_Name => Name_8);
Context.Add (In_Context => Local_Context,
The_Rule => 9,
With_Name => Name_9);
Context.Add (In_Context => Local_Context,
The_Rule => 10,
With_Name => Name_10);
Context.Add (In_Context => Local_Context,
The_Rule => 11,
With_Name => Name_11);
Context.Add (In_Context => Local_Context,
The_Rule => 12,
With_Name => Name_12);
Context.Add (In_Context => Local_Context,
The_Rule => 13,
With_Name => Name_13);
Context.Add (In_Context => Local_Context,
The_Rule => 14,
With_Name => Name_14);
Context.Add (In_Context => Local_Context,
The_Rule => 15,
With_Name => Name_15);
Context.Add (In_Context => Local_Context,
The_Rule => 16,
With_Name => Name_16);
Context.Add (In_Context => Local_Context,
The_Rule => 17,
With_Name => Name_17);
Context.Add (In_Context => Local_Context,
The_Rule => 18,
With_Name => Name_18);
Context.Add (In_Context => Local_Context,
The_Rule => 19,
With_Name => Name_19);
Context.Add (In_Context => Local_Context,
The_Rule => 20,
With_Name => Name_20);
Context.Add (In_Context => Local_Context,
The_Rule => 21,
With_Name => Name_21);
Context.Add (In_Context => Local_Context,
The_Rule => 22,
With_Name => Name_22);
Context.Add (In_Context => Local_Context,
The_Rule => 23,
With_Name => Name_23);
Context.Add (In_Context => Local_Context,
The_Rule => 24,
With_Name => Name_24);
Context.Add (In_Context => Local_Context,
The_Rule => 25,
With_Name => Name_25);
Context.Add (In_Context => Local_Context,
The_Rule => 26,
With_Name => Name_26);
Context.Add (In_Context => Local_Context,
The_Rule => 27,
With_Name => Name_27);
Context.Add (In_Context => Local_Context,
The_Rule => 28,
With_Name => Name_28);
Context.Add (In_Context => Local_Context,
The_Rule => 29,
With_Name => Name_29);
Context.Add (In_Context => Local_Context,
The_Rule => 30,
With_Name => Name_30);
if Debugger_On then
Debugger.Reset_Debug (Mode => Debugger.Text);
Debugger.Set_Debug_On (Item => Debugger.Context_Entered);
Debugger.Send_Context_Entered (With_Number => Local_Context);
end if;
end Engine_Lru;