|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 14336 (0x3800)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Record_Analysis, seg_004423
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦cfc2e13cd⟧ »Space Info Vol 2«
└─⟦this⟧
with Log;
with Profile;
with Common;
with Add_Hyper_Table;
with Io;
with String_Utilities;
with Table_Formatter;
with Table_Sort_Generic;
with Bounded_String;
with Lrm_Renames;
use Lrm_Renames;
with Directory_Renames;
use Directory_Renames;
package body Record_Analysis is
function "<" (Left, Right : Record_Data) return Boolean;
procedure Sort_Records_By_Number_Of_Components is
new Table_Sort_Generic (Record_Data, Decl_Index, Record_Array, "<");
function Order_By_Name (Left, Right : Component_Data) return Boolean;
procedure Sort_Components_By_Label is
new Table_Sort_Generic (Component_Data, Component_Index,
Component_Array, Order_By_Name);
function Order_By_Quantity (Left, Right : Component_Data) return Boolean;
procedure Sort_Components_By_Frequency is
new Table_Sort_Generic (Component_Data, Component_Index,
Component_Array, Order_By_Quantity);
function "<" (Left, Right : Record_Data) return Boolean is
begin
if Ada.Is_Nil (Left.Record_Decl) and then
Ada.Is_Nil (Right.Record_Decl) then
return False;
elsif Ada.Is_Nil (Left.Record_Decl) then
return False;
elsif Ada.Is_Nil (Right.Record_Decl) then
return True;
else
return Left.Num < Right.Num;
end if;
end "<";
function Order_By_Name (Left, Right : Component_Data) return Boolean is
begin
if Ada.Is_Nil (Left.Component) and then
Ada.Is_Nil (Right.Component) then
return False;
elsif Ada.Is_Nil (Left.Component) then
return False;
elsif Ada.Is_Nil (Right.Component) then
return True;
else
return Left.Sequential_Label < Right.Sequential_Label;
end if;
end Order_By_Name;
function Order_By_Quantity (Left, Right : Component_Data) return Boolean is
begin
if Ada.Is_Nil (Left.Component) and then
Ada.Is_Nil (Right.Component) then
return False;
elsif Ada.Is_Nil (Left.Component) then
return False;
elsif Ada.Is_Nil (Right.Component) then
return True;
else
return Left.Count > Right.Count;
end if;
end Order_By_Quantity;
procedure Initialize (Db : in out Data_Base) is
begin
Sequential_Elements.Initialize (Db.Element_Map);
Element_Count.Initialize (Db.Counts);
end Initialize;
procedure Add (Record_Type_Decl : Ada_Program.Element;
To : in out Data_Base) is
The_Data : Record_Data;
Comp_Data : Component_Data;
Components : Ada.Element_Iterator :=
Types.Record_Components
(Decls.Type_Specification (Record_Type_Decl));
Component : Ada.Element;
Type_Decl : Ada.Element;
Ids : Ada.Element_List;
begin
if To.Num /= Decl_Index'Last then
The_Data.Record_Decl := Record_Type_Decl;
while not Ada.Done (Components) loop
Component := Ada.Value (Components);
case Types.Component_Kind (Component) is
when Types.A_Variable_Component =>
Type_Decl := Ada.Definition
(Decls.Object_Type (Component));
Sequential_Elements.Add (Type_Decl, To.Element_Map);
Element_Count.Add (Type_Decl, To.Counts);
Ids := Decls.Identifiers (Component);
while not Ada.Done (Ids) loop
Comp_Data.Component := Type_Decl;
Comp_Data.Sequential_Label :=
Sequential_Elements.Index
(Type_Decl, To.Element_Map);
The_Data.Components (The_Data.Num) := Comp_Data;
if The_Data.Num < Max_Components then
The_Data.Num := The_Data.Num + 1;
end if;
Ada.Next (Ids);
end loop;
when others =>
-- nothing recorded for null or variant part components
null;
end case;
Ada.Next (Components);
end loop;
To.Records (To.Num) := The_Data;
if To.Num < Max_Decls then
To.Num := To.Num + 1;
end if;
end if;
end Add;
procedure Display (Db : in out Data_Base;
Sort_Records : Record_Sort;
Sort_Components : Component_Sort;
To_Document : in out Abstract_Document.Handle) is
package Record_Table is new Table_Formatter (Max_Components + 1);
Sort_Fields : Record_Table.Field_List (1 .. Max_Components - 1);
D : Record_Data;
Component : Integer;
Comp_Data : Component_Array (Component_Index);
begin
case Sort_Components is
when By_Name =>
-- sort the component list by its sequential label
for I in 1 .. Db.Num - 1 loop
Sort_Components_By_Label (Db.Records (I).Components);
end loop;
when By_Component_Frequency =>
for I in 1 .. Db.Num - 1 loop
Comp_Data := Db.Records (I).Components;
-- fill in element counts
for J in 1 .. Db.Records (I).Num - 1 loop
Comp_Data (J).Count :=
Element_Count.Total
(Comp_Data (J).Component, Db.Counts);
end loop;
-- Sort by the overall quantity of each component
Sort_Components_By_Frequency (Comp_Data);
Db.Records (I).Components := Comp_Data;
end loop;
when In_Order =>
null;
end case;
case Sort_Records is
when By_Size =>
-- Sort each record by the number of its components
Sort_Records_By_Number_Of_Components (Db.Records);
when By_Record_Name =>
-- table sort will be done after the table is filled
null;
when By_Component_Name =>
-- set up fields to be (2, 3, 4, 5 ... max_components)
-- This will be used later in a table sort
for I in Sort_Fields'Range loop
Sort_Fields (I) := I + 1;
end loop;
end case;
Record_Table.Header ("TYPE NAME");
for I in 1 .. Max_Components loop
Record_Table.Header ("C_" &
String_Utilities.Strip (Integer'Image (I)),
Is_Integer => False);
end loop;
-- New fill a row of the table for each record
for I in 1 .. Db.Num - 1 loop
D := Db.Records (I);
Record_Table.Item (Decls.Name (D.Record_Decl),
Explanation => "Name of the type declaration",
Linkage => D.Record_Decl);
for J in Component_Index loop
Component := D.Components (J).Sequential_Label;
if Component = 0 then
Record_Table.Item ("");
else
Record_Table.Item
(String_Utilities.Strip (Integer'Image (Component)),
Explanation =>
"Integer reference to the component type",
Linkage => Sequential_Elements.Lookup
(Component, Db.Element_Map));
end if;
end loop;
end loop;
case Sort_Records is
when By_Size =>
null;
when By_Record_Name =>
Record_Table.Sort (1); -- first field is the name of the
-- record
when By_Component_Name =>
Record_Table.Sort (Sort_Fields);
end case;
Record_Table.Display (To_Document, "RECORD TYPE COMPONENTS");
end Display;
end Record_Analysis;
nblk1=d
nid=0
hdr6=1a
[0x00] rec0=1f rec1=00 rec2=01 rec3=06a
[0x01] rec0=00 rec1=00 rec2=0d rec3=004
[0x02] rec0=1f rec1=00 rec2=02 rec3=04e
[0x03] rec0=1d rec1=00 rec2=03 rec3=024
[0x04] rec0=00 rec1=00 rec2=0c rec3=004
[0x05] rec0=19 rec1=00 rec2=04 rec3=030
[0x06] rec0=00 rec1=00 rec2=0b rec3=03e
[0x07] rec0=1d rec1=00 rec2=05 rec3=04e
[0x08] rec0=1a rec1=00 rec2=06 rec3=00c
[0x09] rec0=00 rec1=00 rec2=0a rec3=010
[0x0a] rec0=1b rec1=00 rec2=07 rec3=008
[0x0b] rec0=18 rec1=00 rec2=08 rec3=042
[0x0c] rec0=19 rec1=00 rec2=09 rec3=000
tail 0x21700170a815c63d6e72e 0x42a00088462061e03