|
|
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: 9216 (0x2400)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Subprogram_Analysis, seg_004563
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦cfc2e13cd⟧ »Space Info Vol 2«
└─⟦this⟧
with Id_Referencers;
with Lrm_Utilities;
with Branch_Utilities;
with Statement_Traversal;
with Lrm_Renames;
use Lrm_Renames;
package body Subprogram_Analysis is
package Ada renames Ada_Program;
procedure Stmt_Pre_Op (Program_Element : Ada.Element;
State : in out Subprogram_Data;
Control : in out Ada.Traversal_Control) is
begin
State.Num_Statements := State.Num_Statements + 1;
case Branch_Utilities.Kind (Program_Element) is
when Branch_Utilities.Not_A_Branch =>
Ada.Append (Program_Element, State.Exits);
when others =>
Ada.Append (Program_Element, State.Branches);
State.Current_Depth := State.Current_Depth + 1;
end case;
Control := Ada.Continue;
end Stmt_Pre_Op;
procedure Stmt_Post_Op (Program_Element : Ada.Element;
State : in out Subprogram_Data;
Control : in out Ada.Traversal_Control) is
begin
case Branch_Utilities.Kind (Program_Element) is
when Branch_Utilities.Not_A_Branch =>
null;
when others =>
if State.Current_Depth > State.Max_Depth then
State.Max_Depth := State.Current_Depth;
end if;
State.Current_Depth := State.Current_Depth - 1;
end case;
Control := Ada.Continue;
end Stmt_Post_Op;
procedure Traverse_Statements is
new Statement_Traversal (Subprogram_Data, Stmt_Pre_Op, Stmt_Post_Op);
procedure Pre_Op (Program_Element : Ada.Element;
State : in out Subprogram_Data;
Control : in out Ada.Traversal_Control) is
begin
case Ada.Id_Kind (Program_Element) is
when Ada.An_Identifier_Reference =>
if Id_Referencers.Is_Global_Reference (Program_Element) and then
Id_Referencers.Is_Variable_Reference
(Program_Element) and then
Lrm_Utilities.Is_Actual_Variable_Declaration
(Decls.Enclosing_Declaration
(Ada.Definition (Program_Element))) then
Ada.Append (Program_Element, State.Globals);
end if;
when others =>
null;
end case;
Control := Ada.Continue;
end Pre_Op;
procedure Post_Op (Program_Element : Ada.Element;
State : in out Subprogram_Data;
Control : in out Ada.Traversal_Control) is
begin
Control := Ada.Continue;
end Post_Op;
function Parameter_Count (Subprog : Ada.Element) return Natural is
Count : Natural := 0;
Params : Ada.Element_Iterator := Decls.Subprogram_Parameters (Subprog);
Ids : Ada.Element_List;
begin
while not Ada.Done (Params) loop
Ids := Decls.Identifiers (Ada.Value (Params));
while not Ada.Done (Ids) loop
Count := Count + 1;
Ada.Next (Ids);
end loop;
Ada.Next (Params);
end loop;
return Count;
end Parameter_Count;
procedure Traverse is new Ada.Depth_First_Traversal
(Subprogram_Data, Pre_Op, Post_Op);
function Analyze (Subprogram_Body : Ada_Program.Element)
return Subprogram_Data is
Data : Subprogram_Data;
Control : Ada.Traversal_Control := Ada.Continue;
begin
Traverse_Statements (Subprogram_Body, Data, Control);
Traverse (Subprogram_Body, Data, False);
Data.Num_Params := Parameter_Count (Subprogram_Body);
Data.Num_Locals := Lrm_Utilities.Count
(Stmts.Declarative_Items
(Decls.Subprogram_Block (Subprogram_Body)));
return Data;
end Analyze;
function Branches (In_Subprogram : Subprogram_Data)
return Ada_Program.Element_List is
begin
return In_Subprogram.Branches;
end Branches;
function Nesting_Depth
(In_Subprogram : Subprogram_Data) return Natural is
begin
return In_Subprogram.Max_Depth;
end Nesting_Depth;
function Number_Of_Parameters
(In_Subprogram : Subprogram_Data) return Natural is
begin
return In_Subprogram.Num_Params;
end Number_Of_Parameters;
function Number_Of_Statements
(In_Subprogram : Subprogram_Data) return Natural is
begin
return In_Subprogram.Num_Statements;
end Number_Of_Statements;
function Number_Of_Local_Declarations
(In_Subprogram : Subprogram_Data) return Natural is
begin
return In_Subprogram.Num_Locals;
end Number_Of_Local_Declarations;
function Exits (In_Subprogram : Subprogram_Data)
return Ada_Program.Element_List is
begin
return In_Subprogram.Exits;
end Exits;
function Global_References (In_Subprogram : Subprogram_Data)
return Ada_Program.Element_List is
begin
return In_Subprogram.Globals;
end Global_References;
end Subprogram_Analysis;
nblk1=8
nid=0
hdr6=10
[0x00] rec0=1d rec1=00 rec2=01 rec3=02c
[0x01] rec0=17 rec1=00 rec2=02 rec3=036
[0x02] rec0=17 rec1=00 rec2=03 rec3=056
[0x03] rec0=01 rec1=00 rec2=08 rec3=018
[0x04] rec0=1b rec1=00 rec2=04 rec3=014
[0x05] rec0=00 rec1=00 rec2=07 rec3=00c
[0x06] rec0=1f rec1=00 rec2=05 rec3=034
[0x07] rec0=14 rec1=00 rec2=06 rec3=000
tail 0x217001ef4815c64dd1386 0x42a00088462061e03