File : a-tags.ads


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT RUN-TIME COMPONENTS                         --
   4 --                                                                          --
   5 --                             A D A . T A G S                              --
   6 --                                                                          --
   7 --                                 S p e c                                  --
   8 --                                                                          --
   9 --          Copyright (C) 1992-2015, Free Software Foundation, Inc.         --
  10 --                                                                          --
  11 -- This specification is derived from the Ada Reference Manual for use with --
  12 -- GNAT. The copyright notice above, and the license provisions that follow --
  13 -- apply solely to the  contents of the part following the private keyword. --
  14 --                                                                          --
  15 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  16 -- terms of the  GNU General Public License as published  by the Free Soft- --
  17 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
  18 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  19 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  20 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
  21 --                                                                          --
  22 --                                                                          --
  23 --                                                                          --
  24 --                                                                          --
  25 --                                                                          --
  26 -- You should have received a copy of the GNU General Public License and    --
  27 -- a copy of the GCC Runtime Library Exception along with this program;     --
  28 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
  29 -- <http://www.gnu.org/licenses/>.                                          --
  30 --                                                                          --
  31 -- GNAT was originally developed  by the GNAT team at  New York University. --
  32 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
  33 --                                                                          --
  34 ------------------------------------------------------------------------------
  35 
  36 --  For performance analysis, take into account that the operations in this
  37 --  package provide the guarantee that all dispatching calls on primitive
  38 --  operations of tagged types and interfaces take constant time (in terms
  39 --  of source lines executed), that is to say, the cost of these calls is
  40 --  independent of the number of primitives of the type or interface, and
  41 --  independent of the number of ancestors or interface progenitors that a
  42 --  tagged type may have.
  43 
  44 --  The following subprograms of the public part of this package take constant
  45 --  time (in terms of source lines executed):
  46 
  47 --    Expanded_Name, Wide_Expanded_Name, Wide_Wide_Expanded_Name, External_Tag,
  48 --    Is_Descendant_At_Same_Level, Parent_Tag, Type_Is_Abstract
  49 --    Descendant_Tag (when used with a library-level tagged type),
  50 --    Internal_Tag (when used with a library-level tagged type).
  51 
  52 --  The following subprograms of the public part of this package execute in
  53 --  time that is not constant (in terms of sources line executed):
  54 
  55 --    Internal_Tag (when used with a locally defined tagged type), because in
  56 --    such cases this routine processes the external tag, extracts from it an
  57 --    address available there, and converts it into the tag value returned by
  58 --    this function. The number of instructions executed is not constant since
  59 --    it depends on the length of the external tag string.
  60 
  61 --    Descendant_Tag (when used with a locally defined tagged type), because
  62 --    it relies on the subprogram Internal_Tag() to provide its functionality.
  63 
  64 --    Interface_Ancestor_Tags, because this function returns a table whose
  65 --    length depends on the number of interfaces covered by a tagged type.
  66 
  67 with System.Storage_Elements;
  68 
  69 package Ada.Tags is
  70    pragma Preelaborate;
  71    --  In accordance with Ada 2005 AI-362
  72 
  73    type Tag is private;
  74    pragma Preelaborable_Initialization (Tag);
  75 
  76    No_Tag : constant Tag;
  77 
  78    function Expanded_Name (T : Tag) return String;
  79 
  80    function Wide_Expanded_Name (T : Tag) return Wide_String;
  81    pragma Ada_05 (Wide_Expanded_Name);
  82 
  83    function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String;
  84    pragma Ada_05 (Wide_Wide_Expanded_Name);
  85 
  86    function External_Tag (T : Tag) return String;
  87 
  88    function Internal_Tag (External : String) return Tag;
  89 
  90    function Descendant_Tag
  91      (External : String;
  92       Ancestor : Tag) return Tag;
  93    pragma Ada_05 (Descendant_Tag);
  94 
  95    function Is_Descendant_At_Same_Level
  96      (Descendant : Tag;
  97       Ancestor   : Tag) return Boolean;
  98    pragma Ada_05 (Is_Descendant_At_Same_Level);
  99 
 100    function Parent_Tag (T : Tag) return Tag;
 101    pragma Ada_05 (Parent_Tag);
 102 
 103    type Tag_Array is array (Positive range <>) of Tag;
 104 
 105    function Interface_Ancestor_Tags (T : Tag) return Tag_Array;
 106    pragma Ada_05 (Interface_Ancestor_Tags);
 107 
 108    function Type_Is_Abstract (T : Tag) return Boolean;
 109    pragma Ada_2012 (Type_Is_Abstract);
 110 
 111    Tag_Error : exception;
 112 
 113 private
 114    --  Structure of the GNAT Primary Dispatch Table
 115 
 116    --           +--------------------+
 117    --           |      Signature     |
 118    --           +--------------------+
 119    --           |     Tagged_Kind    |
 120    --           +--------------------+                            Predef Prims
 121    --           |    Predef_Prims -----------------------------> +------------+
 122    --           +--------------------+                           |  table of  |
 123    --           |    Offset_To_Top   |                           | predefined |
 124    --           +--------------------+                           | primitives |
 125    --           |Typeinfo_Ptr/TSD_Ptr---> Type Specific Data     +------------+
 126    --  Tag ---> +--------------------+   +-------------------+
 127    --           |      table of      |   | inheritance depth |
 128    --           :   primitive ops    :   +-------------------+
 129    --           |      pointers      |   |   access level    |
 130    --           +--------------------+   +-------------------+
 131    --                                    |     alignment     |
 132    --                                    +-------------------+
 133    --                                    |   expanded name   |
 134    --                                    +-------------------+
 135    --                                    |   external tag    |
 136    --                                    +-------------------+
 137    --                                    |   hash table link |
 138    --                                    +-------------------+
 139    --                                    |   transportable   |
 140    --                                    +-------------------+
 141    --                                    |  type_is_abstract |
 142    --                                    +-------------------+
 143    --                                    | needs finalization|
 144    --                                    +-------------------+
 145    --                                    |   Ifaces_Table   ---> Interface Data
 146    --                                    +-------------------+   +------------+
 147    --         Select Specific Data  <----        SSD         |   |  Nb_Ifaces |
 148    --         +------------------+       +-------------------+   +------------+
 149    --         |table of primitive|       | table of          |   |  table     |
 150    --         :   operation      :       :    ancestor       :   :    of      :
 151    --         |      kinds       |       |       tags        |   | interfaces |
 152    --         +------------------+       +-------------------+   +------------+
 153    --         |table of          |
 154    --         :   entry          :
 155    --         |      indexes     |
 156    --         +------------------+
 157 
 158    --  Structure of the GNAT Secondary Dispatch Table
 159 
 160    --           +--------------------+
 161    --           |      Signature     |
 162    --           +--------------------+
 163    --           |     Tagged_Kind    |
 164    --           +--------------------+                            Predef Prims
 165    --           |    Predef_Prims -----------------------------> +------------+
 166    --           +--------------------+                           |  table of  |
 167    --           |    Offset_To_Top   |                           | predefined |
 168    --           +--------------------+                           | primitives |
 169    --           |       OSD_Ptr      |---> Object Specific Data  |   thunks   |
 170    --  Tag ---> +--------------------+      +---------------+    +------------+
 171    --           |      table of      |      | num prim ops  |
 172    --           :    primitive op    :      +---------------+
 173    --           |   thunk pointers   |      | table of      |
 174    --           +--------------------+      +   primitive   |
 175    --                                       |    op offsets |
 176    --                                       +---------------+
 177 
 178    --  The runtime information kept for each tagged type is separated into two
 179    --  objects: the Dispatch Table and the Type Specific Data record.
 180 
 181    package SSE renames System.Storage_Elements;
 182 
 183    subtype Cstring is String (Positive);
 184    type Cstring_Ptr is access all Cstring;
 185    pragma No_Strict_Aliasing (Cstring_Ptr);
 186 
 187    --  Declarations for the table of interfaces
 188 
 189    type Offset_To_Top_Function_Ptr is
 190      access function (This : System.Address) return SSE.Storage_Offset;
 191    --  Type definition used to call the function that is generated by the
 192    --  expander in case of tagged types with discriminants that have secondary
 193    --  dispatch tables. This function provides the Offset_To_Top value in this
 194    --  specific case.
 195 
 196    type Interface_Data_Element is record
 197       Iface_Tag            : Tag;
 198       Static_Offset_To_Top : Boolean;
 199       Offset_To_Top_Value  : SSE.Storage_Offset;
 200       Offset_To_Top_Func   : Offset_To_Top_Function_Ptr;
 201       Secondary_DT         : Tag;
 202    end record;
 203    --  If some ancestor of the tagged type has discriminants the field
 204    --  Static_Offset_To_Top is False and the field Offset_To_Top_Func
 205    --  is used to store the access to the function generated by the
 206    --  expander which provides this value; otherwise Static_Offset_To_Top
 207    --  is True and such value is stored in the Offset_To_Top_Value field.
 208    --  Secondary_DT references a secondary dispatch table whose contents
 209    --  are pointers to the primitives of the tagged type that cover the
 210    --  interface primitives. Secondary_DT gives support to dispatching
 211    --  calls through interface types associated with Generic Dispatching
 212    --  Constructors.
 213 
 214    type Interfaces_Array is array (Natural range <>) of Interface_Data_Element;
 215 
 216    type Interface_Data (Nb_Ifaces : Positive) is record
 217       Ifaces_Table : Interfaces_Array (1 .. Nb_Ifaces);
 218    end record;
 219 
 220    type Interface_Data_Ptr is access all Interface_Data;
 221    --  Table of abstract interfaces used to give support to backward interface
 222    --  conversions and also to IW_Membership.
 223 
 224    --  Primitive operation kinds. These values differentiate the kinds of
 225    --  callable entities stored in the dispatch table. Certain kinds may
 226    --  not be used, but are added for completeness.
 227 
 228    type Prim_Op_Kind is
 229      (POK_Function,
 230       POK_Procedure,
 231       POK_Protected_Entry,
 232       POK_Protected_Function,
 233       POK_Protected_Procedure,
 234       POK_Task_Entry,
 235       POK_Task_Function,
 236       POK_Task_Procedure);
 237 
 238    --  Select specific data types
 239 
 240    type Select_Specific_Data_Element is record
 241       Index : Positive;
 242       Kind  : Prim_Op_Kind;
 243    end record;
 244 
 245    type Select_Specific_Data_Array is
 246      array (Positive range <>) of Select_Specific_Data_Element;
 247 
 248    type Select_Specific_Data (Nb_Prim : Positive) is record
 249       SSD_Table : Select_Specific_Data_Array (1 .. Nb_Prim);
 250       --  NOTE: Nb_Prim is the number of non-predefined primitive operations
 251    end record;
 252 
 253    type Select_Specific_Data_Ptr is access all Select_Specific_Data;
 254    --  A table used to store the primitive operation kind and entry index of
 255    --  primitive subprograms of a type that implements a limited interface.
 256    --  The Select Specific Data table resides in the Type Specific Data of a
 257    --  type. This construct is used in the handling of dispatching triggers
 258    --  in select statements.
 259 
 260    type Prim_Ptr is access procedure;
 261    type Address_Array is array (Positive range <>) of Prim_Ptr;
 262 
 263    subtype Dispatch_Table is Address_Array (1 .. 1);
 264    --  Used by GDB to identify the _tags and traverse the run-time structure
 265    --  associated with tagged types. For compatibility with older versions of
 266    --  gdb, its name must not be changed.
 267 
 268    type Tag is access all Dispatch_Table;
 269    pragma No_Strict_Aliasing (Tag);
 270 
 271    type Interface_Tag is access all Dispatch_Table;
 272 
 273    No_Tag : constant Tag := null;
 274 
 275    --  The expander ensures that Tag objects reference the Prims_Ptr component
 276    --  of the wrapper.
 277 
 278    type Tag_Ptr is access all Tag;
 279    pragma No_Strict_Aliasing (Tag_Ptr);
 280 
 281    type Offset_To_Top_Ptr is access all SSE.Storage_Offset;
 282    pragma No_Strict_Aliasing (Offset_To_Top_Ptr);
 283 
 284    type Tag_Table is array (Natural range <>) of Tag;
 285 
 286    type Size_Ptr is
 287      access function (A : System.Address) return Long_Long_Integer;
 288 
 289    type Type_Specific_Data (Idepth : Natural) is record
 290    --  The discriminant Idepth is the Inheritance Depth Level: Used to
 291    --  implement the membership test associated with single inheritance of
 292    --  tagged types in constant-time. It also indicates the size of the
 293    --  Tags_Table component.
 294 
 295       Access_Level : Natural;
 296       --  Accessibility level required to give support to Ada 2005 nested type
 297       --  extensions. This feature allows safe nested type extensions by
 298       --  shifting the accessibility checks to certain operations, rather than
 299       --  being enforced at the type declaration. In particular, by performing
 300       --  run-time accessibility checks on class-wide allocators, class-wide
 301       --  function return, and class-wide stream I/O, the danger of objects
 302       --  outliving their type declaration can be eliminated (Ada 2005: AI-344)
 303 
 304       Alignment     : Natural;
 305       Expanded_Name : Cstring_Ptr;
 306       External_Tag  : Cstring_Ptr;
 307       HT_Link       : Tag_Ptr;
 308       --  Components used to support to the Ada.Tags subprograms in RM 3.9
 309 
 310       --  Note: Expanded_Name is referenced by GDB to determine the actual name
 311       --  of the tagged type. Its requirements are: 1) it must have this exact
 312       --  name, and 2) its contents must point to a C-style Nul terminated
 313       --  string containing its expanded name. GDB has no requirement on a
 314       --  given position inside the record.
 315 
 316       Transportable : Boolean;
 317       --  Used to check RM E.4(18), set for types that satisfy the requirements
 318       --  for being used in remote calls as actuals for classwide formals or as
 319       --  return values for classwide functions.
 320 
 321       Type_Is_Abstract : Boolean;
 322       --  True if the type is abstract (Ada 2012: AI05-0173)
 323 
 324       Needs_Finalization : Boolean;
 325       --  Used to dynamically check whether an object is controlled or not
 326 
 327       Size_Func : Size_Ptr;
 328       --  Pointer to the subprogram computing the _size of the object. Used by
 329       --  the run-time whenever a call to the 'size primitive is required. We
 330       --  cannot assume that the contents of dispatch tables are addresses
 331       --  because in some architectures the ABI allows descriptors.
 332 
 333       Interfaces_Table : Interface_Data_Ptr;
 334       --  Pointer to the table of interface tags. It is used to implement the
 335       --  membership test associated with interfaces and also for backward
 336       --  abstract interface type conversions (Ada 2005:AI-251)
 337 
 338       SSD : Select_Specific_Data_Ptr;
 339       --  Pointer to a table of records used in dispatching selects. This field
 340       --  has a meaningful value for all tagged types that implement a limited,
 341       --  protected, synchronized or task interfaces and have non-predefined
 342       --  primitive operations.
 343 
 344       Tags_Table : Tag_Table (0 .. Idepth);
 345       --  Table of ancestor tags. Its size actually depends on the inheritance
 346       --  depth level of the tagged type.
 347    end record;
 348 
 349    type Type_Specific_Data_Ptr is access all Type_Specific_Data;
 350    pragma No_Strict_Aliasing (Type_Specific_Data_Ptr);
 351 
 352    --  Declarations for the dispatch table record
 353 
 354    type Signature_Kind is
 355       (Unknown,
 356        Primary_DT,
 357        Secondary_DT);
 358 
 359    --  Tagged type kinds with respect to concurrency and limitedness
 360 
 361    type Tagged_Kind is
 362      (TK_Abstract_Limited_Tagged,
 363       TK_Abstract_Tagged,
 364       TK_Limited_Tagged,
 365       TK_Protected,
 366       TK_Tagged,
 367       TK_Task);
 368 
 369    type Dispatch_Table_Wrapper (Num_Prims : Natural) is record
 370       Signature     : Signature_Kind;
 371       Tag_Kind      : Tagged_Kind;
 372       Predef_Prims  : System.Address;
 373       --  Pointer to the dispatch table of predefined Ada primitives
 374 
 375       --  According to the C++ ABI the components Offset_To_Top and TSD are
 376       --  stored just "before" the dispatch table, and they are referenced with
 377       --  negative offsets referring to the base of the dispatch table. The
 378       --   _Tag (or the VTable_Ptr in C++ terminology) must point to the base
 379       --  of the virtual table, just after these components, to point to the
 380       --  Prims_Ptr table.
 381 
 382       Offset_To_Top : SSE.Storage_Offset;
 383       TSD           : System.Address;
 384 
 385       Prims_Ptr : aliased Address_Array (1 .. Num_Prims);
 386       --  The size of the Prims_Ptr array actually depends on the tagged type
 387       --  to which it applies. For each tagged type, the expander computes the
 388       --  actual array size, allocates the Dispatch_Table record accordingly.
 389    end record;
 390 
 391    type Dispatch_Table_Ptr is access all Dispatch_Table_Wrapper;
 392    pragma No_Strict_Aliasing (Dispatch_Table_Ptr);
 393 
 394    --  The following type declaration is used by the compiler when the program
 395    --  is compiled with restriction No_Dispatching_Calls. It is also used with
 396    --  interface types to generate the tag and run-time information associated
 397    --  with them.
 398 
 399    type No_Dispatch_Table_Wrapper is record
 400       NDT_TSD       : System.Address;
 401       NDT_Prims_Ptr : Natural;
 402    end record;
 403 
 404    DT_Predef_Prims_Size : constant SSE.Storage_Count :=
 405                             SSE.Storage_Count
 406                               (1 * (Standard'Address_Size /
 407                                       System.Storage_Unit));
 408    --  Size of the Predef_Prims field of the Dispatch_Table
 409 
 410    DT_Offset_To_Top_Size : constant SSE.Storage_Count :=
 411                              SSE.Storage_Count
 412                                (1 * (Standard'Address_Size /
 413                                        System.Storage_Unit));
 414    --  Size of the Offset_To_Top field of the Dispatch Table
 415 
 416    DT_Typeinfo_Ptr_Size : constant SSE.Storage_Count :=
 417                             SSE.Storage_Count
 418                               (1 * (Standard'Address_Size /
 419                                       System.Storage_Unit));
 420    --  Size of the Typeinfo_Ptr field of the Dispatch Table
 421 
 422    use type System.Storage_Elements.Storage_Offset;
 423 
 424    DT_Offset_To_Top_Offset : constant SSE.Storage_Count :=
 425                                DT_Typeinfo_Ptr_Size
 426                                  + DT_Offset_To_Top_Size;
 427 
 428    DT_Predef_Prims_Offset : constant SSE.Storage_Count :=
 429                               DT_Typeinfo_Ptr_Size
 430                                 + DT_Offset_To_Top_Size
 431                                 + DT_Predef_Prims_Size;
 432    --  Offset from Prims_Ptr to Predef_Prims component
 433 
 434    --  Object Specific Data record of secondary dispatch tables
 435 
 436    type Object_Specific_Data_Array is array (Positive range <>) of Positive;
 437 
 438    type Object_Specific_Data (OSD_Num_Prims : Positive) is record
 439       OSD_Table : Object_Specific_Data_Array (1 .. OSD_Num_Prims);
 440       --  Table used in secondary DT to reference their counterpart in the
 441       --  select specific data (in the TSD of the primary DT). This construct
 442       --  is used in the handling of dispatching triggers in select statements.
 443       --  Nb_Prim is the number of non-predefined primitive operations.
 444    end record;
 445 
 446    type Object_Specific_Data_Ptr is access all Object_Specific_Data;
 447    pragma No_Strict_Aliasing (Object_Specific_Data_Ptr);
 448 
 449    --  The following subprogram specifications are placed here instead of the
 450    --  package body to see them from the frontend through rtsfind.
 451 
 452    function Base_Address (This : System.Address) return System.Address;
 453    --  Ada 2005 (AI-251): Displace "This" to point to the base address of the
 454    --  object (that is, the address of the primary tag of the object).
 455 
 456    procedure Check_TSD (TSD : Type_Specific_Data_Ptr);
 457    --  Ada 2012 (AI-113): Raise Program_Error if the external tag of this TSD
 458    --  is the same as the external tag for some other tagged type declaration.
 459 
 460    function Displace (This : System.Address; T : Tag) return System.Address;
 461    --  Ada 2005 (AI-251): Displace "This" to point to the secondary dispatch
 462    --  table of T.
 463 
 464    function Secondary_Tag (T, Iface : Tag) return Tag;
 465    --  Ada 2005 (AI-251): Given a primary tag T associated with a tagged type
 466    --  Typ, search for the secondary tag of the interface type Iface covered
 467    --  by Typ.
 468 
 469    function DT (T : Tag) return Dispatch_Table_Ptr;
 470    --  Return the pointer to the TSD record associated with T
 471 
 472    function Get_Entry_Index (T : Tag; Position : Positive) return Positive;
 473    --  Ada 2005 (AI-251): Return a primitive operation's entry index (if entry)
 474    --  given a dispatch table T and a position of a primitive operation in T.
 475 
 476    function Get_Offset_Index
 477      (T        : Tag;
 478       Position : Positive) return Positive;
 479    --  Ada 2005 (AI-251): Given a pointer to a secondary dispatch table (T)
 480    --  and a position of an operation in the DT, retrieve the corresponding
 481    --  operation's position in the primary dispatch table from the Offset
 482    --  Specific Data table of T.
 483 
 484    function Get_Prim_Op_Kind
 485      (T        : Tag;
 486       Position : Positive) return Prim_Op_Kind;
 487    --  Ada 2005 (AI-251): Return a primitive operation's kind given a dispatch
 488    --  table T and a position of a primitive operation in T.
 489 
 490    function Get_Tagged_Kind (T : Tag) return Tagged_Kind;
 491    --  Ada 2005 (AI-345): Given a pointer to either a primary or a secondary
 492    --  dispatch table, return the tagged kind of a type in the context of
 493    --  concurrency and limitedness.
 494 
 495    function IW_Membership (This : System.Address; T : Tag) return Boolean;
 496    --  Ada 2005 (AI-251): General routine that checks if a given object
 497    --  implements a tagged type. Its common usage is to check if Obj is in
 498    --  Iface'Class, but it is also used to check if a class-wide interface
 499    --  implements a given type (Iface_CW_Typ in T'Class). For example:
 500    --
 501    --      type I is interface;
 502    --      type T is tagged ...
 503    --
 504    --      function Test (O : I'Class) is
 505    --      begin
 506    --         return O in T'Class.
 507    --      end Test;
 508 
 509    function Offset_To_Top
 510      (This : System.Address) return SSE.Storage_Offset;
 511    --  Ada 2005 (AI-251): Returns the current value of the Offset_To_Top
 512    --  component available in the prologue of the dispatch table. If the parent
 513    --  of the tagged type has discriminants this value is stored in a record
 514    --  component just immediately after the tag component.
 515 
 516    function Needs_Finalization (T : Tag) return Boolean;
 517    --  A helper routine used in conjunction with finalization collections which
 518    --  service class-wide types. The function dynamically determines whether an
 519    --  object is controlled or has controlled components.
 520 
 521    function Parent_Size
 522      (Obj : System.Address;
 523       T   : Tag) return SSE.Storage_Count;
 524    --  Computes the size the ancestor part of a tagged extension object whose
 525    --  address is 'obj' by calling indirectly the ancestor _size function. The
 526    --  ancestor is the parent of the type represented by tag T. This function
 527    --  assumes that _size is always in slot one of the dispatch table.
 528 
 529    procedure Register_Interface_Offset
 530      (This         : System.Address;
 531       Interface_T  : Tag;
 532       Is_Static    : Boolean;
 533       Offset_Value : SSE.Storage_Offset;
 534       Offset_Func  : Offset_To_Top_Function_Ptr);
 535    --  Register in the table of interfaces of the tagged type associated with
 536    --  "This" object the offset of the record component associated with the
 537    --  progenitor Interface_T (that is, the distance from "This" to the object
 538    --  component containing the tag of the secondary dispatch table). In case
 539    --  of constant offset, Is_Static is true and Offset_Value has such value.
 540    --  In case of variable offset, Is_Static is false and Offset_Func is an
 541    --  access to function that must be called to evaluate the offset.
 542 
 543    procedure Register_Tag (T : Tag);
 544    --  Insert the Tag and its associated external_tag in a table for the sake
 545    --  of Internal_Tag.
 546 
 547    procedure Set_Dynamic_Offset_To_Top
 548      (This         : System.Address;
 549       Interface_T  : Tag;
 550       Offset_Value : SSE.Storage_Offset;
 551       Offset_Func  : Offset_To_Top_Function_Ptr);
 552    --  Ada 2005 (AI-251): The compiler generates calls to this routine only
 553    --  when initializing the Offset_To_Top field of dispatch tables associated
 554    --  with tagged type whose parent has variable size components. "This" is
 555    --  the object whose dispatch table is being initialized. Interface_T is the
 556    --  interface for which the secondary dispatch table is being initialized,
 557    --  and Offset_Value is the distance from "This" to the object component
 558    --  containing the tag of the secondary dispatch table (a zero value means
 559    --  that this interface shares the primary dispatch table). Offset_Func
 560    --  references a function that must be called to evaluate the offset at
 561    --  runtime. This routine also takes care of registering these values in
 562    --  the table of interfaces of the type.
 563 
 564    procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive);
 565    --  Ada 2005 (AI-345): Set the entry index of a primitive operation in T's
 566    --  TSD table indexed by Position.
 567 
 568    procedure Set_Prim_Op_Kind
 569      (T        : Tag;
 570       Position : Positive;
 571       Value    : Prim_Op_Kind);
 572    --  Ada 2005 (AI-251): Set the kind of a primitive operation in T's TSD
 573    --  table indexed by Position.
 574 
 575    procedure Unregister_Tag (T : Tag);
 576    --  Remove a particular tag from the external tag hash table
 577 
 578    Max_Predef_Prims : constant Positive := 15;
 579    --  Number of reserved slots for the following predefined ada primitives:
 580    --
 581    --    1. Size
 582    --    2. Read
 583    --    3. Write
 584    --    4. Input
 585    --    5. Output
 586    --    6. "="
 587    --    7. assignment
 588    --    8. deep adjust
 589    --    9. deep finalize
 590    --   10. async select
 591    --   11. conditional select
 592    --   12. prim_op kind
 593    --   13. task_id
 594    --   14. dispatching requeue
 595    --   15. timed select
 596    --
 597    --  The compiler checks that the value here is correct
 598 
 599    subtype Predef_Prims_Table  is Address_Array (1 .. Max_Predef_Prims);
 600    type Predef_Prims_Table_Ptr is access Predef_Prims_Table;
 601    pragma No_Strict_Aliasing (Predef_Prims_Table_Ptr);
 602 
 603    type Addr_Ptr is access System.Address;
 604    pragma No_Strict_Aliasing (Addr_Ptr);
 605    --  This type is used by the frontend to generate the code that handles
 606    --  dispatch table slots of types declared at the local level.
 607 
 608 end Ada.Tags;