DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦721d12038⟧ Ada Source

    Length: 13312 (0x3400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Find_Use_Clauses, seg_004419

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦this⟧ 

E3 Source Code



with Log;
with Profile;
with Common;
with Lrm_Utilities;
with Add_Hyper_Table;
with Create_Null_Document;
with Lrm_Renames;
use Lrm_Renames;
with Directory_Renames;
use Directory_Renames;
with Errors;
with Simple_Status;
package body Find_Use_Clauses is

    type Context_Data is
        record
            First_With              : Ada.Element;
            Number_Of_Withs         : Natural;
            First_Use               : Ada.Element;
            Number_Of_Uses          : Natural;
            Internal_Uses           : Ada.Element_List;
            Number_Of_Internal_Uses : Natural;
        end record;

    Nil_Data : constant Context_Data :=
       (Ada.Nil_Element, 0, Ada.Nil_Element, 0, Ada.Nil_List, 0);

    procedure Pre_Op (Program_Element :        Ada.Element;
                      State           : in out Context_Data;
                      Control         : in out Ada.Traversal_Control) is
        Referenced_Units : Ada.Element_Iterator;
    begin
        case Ada.Kind (Program_Element) is
            when Ada.A_Context_Clause =>
                case Comp_Units.Context_Clause_Kind (Program_Element) is
                    when Comp_Units.A_Use_Clause =>
                        Referenced_Units :=
                           Comp_Units.Referenced_Units (Program_Element);

                        case Ada.Kind (Ada.Parent (Program_Element)) is
                            when Ada.A_Compilation_Unit =>

                                if Ada.Is_Nil (State.First_Use) then
                                    State.First_Use := Program_Element;
                                end if;

                                while not Ada.Done (Referenced_Units) loop
                                    State.Number_Of_Uses :=
                                       State.Number_Of_Uses + 1;
                                    Ada.Next (Referenced_Units);
                                end loop;

                                -- this is an internal use clause
                            when others =>
                                Ada.Append (Program_Element,
                                            State.Internal_Uses);

                                while not Ada.Done (Referenced_Units) loop
                                    State.Number_Of_Internal_Uses :=
                                       State.Number_Of_Internal_Uses + 1;
                                    Ada.Next (Referenced_Units);
                                end loop;
                        end case;

                    when Comp_Units.A_With_Clause =>
                        if Ada.Is_Nil (State.First_With) then
                            State.First_With := Program_Element;
                        end if;

                        Referenced_Units :=
                           Comp_Units.Referenced_Units (Program_Element);

                        while not Ada.Done (Referenced_Units) loop
                            State.Number_Of_Withs := State.Number_Of_Withs + 1;
                            Ada.Next (Referenced_Units);
                        end loop;

                    when others =>
                        null;
                end case;
            when others =>
                null;
        end case;

        Control := Ada.Continue;
    end Pre_Op;

    procedure Post_Op (Program_Element :        Ada.Element;
                       State           : in out Context_Data;
                       Control         : in out Ada.Traversal_Control) is
    begin
        Control := Ada.Continue;
    end Post_Op;

    procedure Traverse_For_Clauses is
       new Ada.Depth_First_Traversal (Context_Data, Pre_Op, Post_Op);

    procedure Add (Units       :        String := "";
                   To_Document : in out Abstract_Document.Handle;
                   Response    :        String := "<PROFILE>") is


        Units_Iter : Object.Iterator := Naming.Resolution (Units);

        type Columns is (Uses, Internal_Uses, Withs, Compilation_Unit);

        Data : Context_Data;

        function Is_Integer_Column (C : Columns) return Boolean is
        begin
            case C is
                when Withs | Uses | Internal_Uses =>
                    return True;
                when Compilation_Unit =>
                    return False;
            end case;
        end Is_Integer_Column;

        function Is_Included (Elem : Ada.Element) return Boolean is
        begin
            case Ada.Kind (Elem) is
                when Ada.A_Compilation_Unit =>

                    Data := Nil_Data;

                    Traverse_For_Clauses (Root_Element        => Elem,
                                          State               => Data,
                                          Major_Elements_Only => True);

                    if Data.Number_Of_Uses > 0 or else
                       Data.Number_Of_Internal_Uses > 0 then
                        return True;
                    else
                        return False;
                    end if;
                when others =>
                    return False;
            end case;
        end Is_Included;

        function Explanation (C    : Columns;  
                              Elem : Ada.Element) return String is
        begin
            case C is
                when Compilation_Unit =>
                    return "Name of the compilation unit";
                when Uses =>
                    return "Number of use clauses in the context part";
                when Internal_Uses =>
                    return "Number of use clauses used internally in the unit";
                when Withs =>
                    return "Number of with clauses in the context part";
            end case;
        end Explanation;

        function Column_Image (C    : Columns;  
                               Elem : Ada.Element) return String is
        begin
            case C is
                when Compilation_Unit =>
                    return Decls.Name (Comp_Units.Unit_Declaration (Elem));
                when Uses =>
                    return Natural'Image (Data.Number_Of_Uses);
                when Internal_Uses =>
                    return Natural'Image (Data.Number_Of_Internal_Uses);
                when Withs =>
                    return Natural'Image (Data.Number_Of_Withs);

            end case;
        end Column_Image;

        procedure Linkage (C                :     Columns;
                           Elem             :     Ada.Element;
                           Linkage_Element  : out Ada.Element;
                           Linkage_Elements : out Ada.Element_List) is
        begin
            -- default values changed within the case statement as necessary
            Linkage_Element  := Ada.Nil_Element;
            Linkage_Elements := Ada.Nil_List;

           case C is
                when Compilation_Unit =>
                    Linkage_Element := Lrm_Utilities.Comp_Unit_Id (Elem);
                when Internal_Uses =>
                    Linkage_Elements := Data.Internal_Uses;
                when Withs =>
                    if Data.Number_Of_Withs > 0 then
                        Linkage_Element := Data.First_With;
                    else
                        Linkage_Element := Ada.Nil_Element;
                    end if;
                when Uses =>
                    if Data.Number_Of_Uses > 0 then
                        Linkage_Element := Data.First_Use;
                    else
                        Linkage_Element := Ada.Nil_Element;
                    end if;
            end case;

        end Linkage;

        procedure Add_Hyper_Table_To_Doc is
           new Add_Hyper_Table
                  (Is_Included,  
                   Columns,  
                   Is_Integer_Column, Column_Image, Explanation, Linkage,  
                   Table_Title => "UNITS CONTAINING USE CLAUSES");
    begin
        if Object.Is_Bad (Units_Iter) then
            Log.Put_Line (Units & " is not a valid pathname",
                          Profile.Error_Msg);
        else
            Add_Hyper_Table_To_Doc (Units_Iter, To_Document);
        end if;
    end Add;

    procedure Display (Units             : String := "";
                       To_Preview_Object : String := "Use_Clause_Info";
                       Response          : String := "<PROFILE>") is
        Document  : Abstract_Document.Handle;
        Condition : Errors.Condition;
    begin

        Create_Null_Document (Named           => To_Preview_Object,
                              Error_Info      => Condition,
                              Document_Handle => Document);

        case Errors.Severity (Condition) is
            when Simple_Status.Problem | Simple_Status.Fatal =>
                Log.Put_Line ("Problem creating object " & To_Preview_Object &
                              ".  " & Errors.Info (Condition),
                              Profile.Error_Msg);
            when others =>

                Add (Units, Document, Response);

                Abstract_Document.Close (Document);
                Common.Definition (To_Preview_Object);

        end case;
    end Display;
end Find_Use_Clauses;

E3 Meta Data

    nblk1=c
    nid=0
    hdr6=18
        [0x00] rec0=20 rec1=00 rec2=01 rec3=04c
        [0x01] rec0=02 rec1=00 rec2=0c rec3=03a
        [0x02] rec0=14 rec1=00 rec2=02 rec3=070
        [0x03] rec0=15 rec1=00 rec2=03 rec3=046
        [0x04] rec0=1d rec1=00 rec2=04 rec3=074
        [0x05] rec0=1c rec1=00 rec2=05 rec3=06e
        [0x06] rec0=1a rec1=00 rec2=06 rec3=060
        [0x07] rec0=18 rec1=00 rec2=07 rec3=008
        [0x08] rec0=00 rec1=00 rec2=0b rec3=002
        [0x09] rec0=19 rec1=00 rec2=08 rec3=058
        [0x0a] rec0=18 rec1=00 rec2=09 rec3=01c
        [0x0b] rec0=0d rec1=00 rec2=0a rec3=000
    tail 0x215003528815c63b6ac87 0x42a00088462061e03