|
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: 22528 (0x5800) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Id_Referencers, seg_00462a
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Lrm_Utilities; with Ada_Program; with String_Utilities; with Lrm_Renames; use Lrm_Renames; package body Id_Referencers is type Referencer_Data is record Original_Id : Ada.Element; Refs : Object_References := Ada.Nil_List; end record; type Name_Data is record Original_Reference : Ada_Program.Element; Found : Boolean := False; end record; procedure Pre_Op (Program_Element : Ada_Program.Element; State : in out Name_Data; Control : in out Ada_Program.Traversal_Control) is begin if State.Original_Reference = Program_Element then State.Found := True; Control := Ada_Program.Terminate_Immediately; end if; end Pre_Op; procedure Post_Op (Program_Element : Ada_Program.Element; State : in out Name_Data; Control : in out Ada_Program.Traversal_Control) is begin Control := Ada_Program.Continue; end Post_Op; procedure Traverse_Name is new Ada_Program.Depth_First_Traversal (Name_Data, Pre_Op, Post_Op); procedure Pre_Op (Program_Element : Ada.Element; State : in out Referencer_Data; Control : in out Ada.Traversal_Control) is begin if Ada.Id_Kind (Program_Element) = Ada.An_Identifier_Reference and then State.Original_Id = Ada.Definition (Program_Element) then Ada.Append (Program_Element, State.Refs); -- add this reference_to_the list end if; end Pre_Op; procedure Post_Op (Program_Element : Ada.Element; State : in out Referencer_Data; Control : in out Ada.Traversal_Control) is begin Control := Ada.Continue; end Post_Op; procedure Traverse is new Ada.Depth_First_Traversal (Referencer_Data, Pre_Op, Post_Op); function Initialize_References (For_Id : Ada_Program.Element) return Object_References is Data : Referencer_Data; Iter : Ada.Element_List := Ada.Usage (Reference => For_Id, Global => True, Limit => "<ALL_WORLDS>", Closure => False); begin Data.Original_Id := For_Id; while not Ada.Done (Iter) loop Traverse (Ada.Value (Iter), Data, False); Ada.Next (Iter); end loop; return Data.Refs; end Initialize_References; function Done (Referencers : Object_References) return Boolean is begin return Ada.Done (Referencers); end Done; procedure Next (Referencers : in out Object_References) is begin Ada.Next (Referencers); end Next; function Value (Referencers : Object_References) return Ada_Program.Identifier_Reference is begin return Ada.Value (Referencers); end Value; -- function Is_Variable_Reference -- (Id_Ref : Ada_Program.Identifier_Reference) return Boolean is -- Id_Def : Ada.Identifier_Definition := Get_Referenced_Object_Id (Id_Ref); -- begin -- if Ada.Is_Nil (Id_Def) then -- return False; -- else -- return Decls.Kind (Id_Def) = Decls.A_Variable_Declaration; -- end if; -- end Is_Variable_Reference; -- -- function Is_Parameter_Reference -- (Id_Ref : Ada_Program.Identifier_Reference) return Boolean is -- Id_Def : Ada.Element := Get_Referenced_Object_Id (Id_Ref); -- begin -- if Ada.Is_Nil (Id_Def) then -- return False; -- else -- return Decls.Kind (Id_Def) = Decls.A_Subprogram_Formal_Parameter; -- end if; -- end Is_Parameter_Reference; -- function Is_Global_Reference (Id_Def : Ada_Program.Identifier_Definition; Id_Ref : Ada_Program.Identifier_Reference) return Boolean is begin if Ada.Is_Nil (Id_Def) then return False; else return Comp_Units.Parent_Compilation_Unit (Id_Def) /= Comp_Units.Parent_Compilation_Unit (Id_Ref); end if; end Is_Global_Reference; function Local_To_Package (Id_Def : Ada_Program.Identifier_Definition) return Boolean is Parent : Ada.Element := Ada.Parent (Decls.Enclosing_Declaration (Id_Def)); begin case Decls.Kind (Parent) is when Decls.A_Package_Body_Declaration => return True; when others => return False; end case; end Local_To_Package; function Reference_Type (Id_Ref : Ada_Program.Identifier_Reference) return Object_Reference_Types is Id_Def : Ada.Identifier_Definition := Get_Referenced_Object_Id (Id_Ref); begin if Ada.Is_Nil (Id_Def) then return Not_An_Object_Ref; else case Decls.Kind (Id_Def) is when Decls.A_Constant_Declaration | Decls.A_Deferred_Constant_Declaration | Decls.An_Integer_Number_Declaration | Decls.A_Real_Number_Declaration => if Is_Global_Reference (Id_Def, Id_Ref) then return Global_Constant; elsif Local_To_Package (Id_Def) then return Local_Package_Constant; else return Local_Procedure_Constant; end if; when Decls.A_Subprogram_Formal_Parameter => return Parameter; when Decls.A_Variable_Declaration | Decls.An_Object_Rename_Declaration => if Is_Global_Reference (Id_Def, Id_Ref) then return Global_Variable; elsif Local_To_Package (Id_Def) then return Local_Package_Variable; else return Local_Procedure_Variable; end if; when others => return Not_An_Object_Ref; end case; end if; end Reference_Type; function Get_Referenced_Object_Id (Id_Ref : Ada_Program.Identifier_Reference) return Ada_Program.Identifier_Definition is Reference : Ada.Element := Lrm_Utilities.Get_Full_Name (Id_Ref); Id_Def : Ada.Element; Parent : Ada.Element; begin if Lrm_Utilities.Is_Name_Id (Id_Ref) then return Ada.Nil_Element; else loop Id_Def := Ada.Definition (Reference); Parent := Ada.Parent (Decls.Enclosing_Declaration (Id_Def)); if Decls.Kind (Parent) = Decls.A_Type_Declaration then Reference := Exprs.Prefix (Reference); else case Decls.Kind (Id_Def) is when Decls.A_Variable_Declaration | Decls.A_Constant_Declaration | Decls.A_Deferred_Constant_Declaration | Decls.An_Integer_Number_Declaration | Decls.A_Real_Number_Declaration | Decls.A_Subprogram_Formal_Parameter | Decls.An_Object_Rename_Declaration => return Id_Def; when others => return Ada.Nil_Element; end case; end if; end loop; end if; end Get_Referenced_Object_Id; function Kind (Id_Reference : Ada_Program.Identifier_Reference) return Reference_Kind is Parent : Ada.Element := Ada.Parent (Id_Reference); Data : Name_Data; function Check_Parameters (Of_Call : Ada.Statement; For_Id : Ada.Identifier_Reference) return Reference_Kind is Called_Proc : Ada.Element := Stmts.Called_Procedure (Of_Call); Formal_Params : Ada.Element_Iterator := Decls.Subprogram_Parameters (Called_Proc); Actual_Params : Ada.Element_Iterator := Stmts.Procedure_Call_Parameters (Of_Call, Normalized => True); Actual_Ref : Ada.Element; Multiple_Ids : Boolean := False; Current_Ids : Ada.Element_List; procedure Set_Ids is begin if not Ada.Done (Formal_Params) then Current_Ids := Decls.Identifiers (Ada.Value (Formal_Params)); Ada.Next (Current_Ids); Multiple_Ids := not Ada.Done (Current_Ids); end if; end Set_Ids; procedure Next_Formal is begin if not Ada.Done (Formal_Params) then Ada.Next (Formal_Params); if not Ada.Done (Formal_Params) then Set_Ids; end if; end if; end Next_Formal; procedure Step_To_Next_Formal_Param is begin if Multiple_Ids then if Ada.Done (Current_Ids) then Next_Formal; else Ada.Next (Current_Ids); end if; else Next_Formal; end if; end Step_To_Next_Formal_Param; begin if Decls.Is_Generic_Instantiation (Called_Proc) then Formal_Params := Decls.Subprogram_Parameters (Ada.Definition (Called_Proc)); end if; Set_Ids; while not Ada.Done (Actual_Params) loop Data.Original_Reference := For_Id; Data.Found := False; Traverse_Name (Ada.Value (Actual_Params), Data, False); if Data.Found then case Decls.Subprogram_Parameter_Kind (Ada.Value (Formal_Params)) is when Decls.Out_Parameter => return Set; when Decls.In_Out_Parameter => return Set_And_Used; when others => return Used; end case; end if; Step_To_Next_Formal_Param; Ada.Next (Actual_Params); end loop; return Used; end Check_Parameters; begin case Ada.Kind (Parent) is when Ada.A_Statement => case Stmts.Kind (Parent) is when Stmts.An_Assignment_Statement => Data.Original_Reference := Id_Reference; Data.Found := False; Traverse_Name (Stmts.Object_Assigned_To (Parent), Data, False); -- check to see of the name is on the -- left hand side of the assignment if Data.Found then return Set; else return Used; end if; when Stmts.A_Procedure_Call_Statement | Stmts.An_Entry_Call_Statement | Stmts.A_Conditional_Entry_Call_Statement | Stmts.A_Timed_Entry_Call_Statement => return Check_Parameters (Of_Call => Parent, For_Id => Id_Reference); when others => return Used; end case; when others => return Used; end case; end Kind; procedure Pre_Op (Program_Element : Ada.Element; State : in out Object_References; Control : in out Ada.Traversal_Control) is Def : Ada.Element; begin case Ada.Id_Kind (Program_Element) is when Ada.An_Identifier_Reference => Def := Ada.Definition (Program_Element); case Decls.Kind (Def) is when Decls.A_Variable_Declaration | Decls.A_Subprogram_Formal_Parameter | Decls.A_Constant_Declaration | Decls.An_Integer_Number_Declaration | Decls.A_Real_Number_Declaration => Ada.Append (Program_Element, State); 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 Object_References; Control : in out Ada.Traversal_Control) is begin Control := Ada.Continue; end Post_Op; procedure Traverse is new Ada.Depth_First_Traversal (Object_References, Pre_Op, Post_Op); function Internal_References (In_Element : Ada_Program.Element) return Object_References is References : Object_References; begin Traverse (In_Element, References, False); Ada.Reset (References); return References; end Internal_References; function Reference_Type (Id_Reference : Ada_Program.Identifier_Reference) return Ada_Program.Type_Definition is Id_Def : Ada.Identifier_Definition := Ada.Definition (Id_Reference); begin case Decls.Kind (Id_Def) is when Decls.A_Variable_Declaration | Decls.A_Constant_Declaration => return Decls.Type_Specification (Ada.Definition (Decls.Object_Type (Id_Def))); when Decls.A_Subprogram_Formal_Parameter => return Decls.Type_Specification (Ada.Definition (Decls.Type_Mark (Id_Def))); when Decls.An_Integer_Number_Declaration | Decls.A_Real_Number_Declaration => return Ada.Nil_Element; when others => raise Not_An_Object_Reference; end case; end Reference_Type; end Id_Referencers;
nblk1=15 nid=0 hdr6=2a [0x00] rec0=20 rec1=00 rec2=01 rec3=042 [0x01] rec0=01 rec1=00 rec2=15 rec3=00c [0x02] rec0=17 rec1=00 rec2=02 rec3=00c [0x03] rec0=1b rec1=00 rec2=03 rec3=04c [0x04] rec0=1d rec1=00 rec2=04 rec3=010 [0x05] rec0=19 rec1=00 rec2=05 rec3=050 [0x06] rec0=18 rec1=00 rec2=06 rec3=028 [0x07] rec0=18 rec1=00 rec2=07 rec3=048 [0x08] rec0=14 rec1=00 rec2=08 rec3=040 [0x09] rec0=00 rec1=00 rec2=14 rec3=00c [0x0a] rec0=1a rec1=00 rec2=09 rec3=09a [0x0b] rec0=1d rec1=00 rec2=0a rec3=022 [0x0c] rec0=00 rec1=00 rec2=13 rec3=002 [0x0d] rec0=1b rec1=00 rec2=0b rec3=052 [0x0e] rec0=00 rec1=00 rec2=12 rec3=014 [0x0f] rec0=1a rec1=00 rec2=0c rec3=050 [0x10] rec0=00 rec1=00 rec2=11 rec3=01a [0x11] rec0=17 rec1=00 rec2=0d rec3=090 [0x12] rec0=18 rec1=00 rec2=0e rec3=05e [0x13] rec0=19 rec1=00 rec2=0f rec3=06c [0x14] rec0=0c rec1=00 rec2=10 rec3=000 tail 0x217002478815c65eb6420 0x42a00088462061e03