1------------------------------------------------------------------------------ 2-- -- 3-- GNAT COMPILER COMPONENTS -- 4-- -- 5-- E X P _ D I S T -- 6-- -- 7-- S p e c -- 8-- -- 9-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- 10-- -- 11-- GNAT is free software; you can redistribute it and/or modify it under -- 12-- terms of the GNU General Public License as published by the Free Soft- -- 13-- ware Foundation; either version 3, or (at your option) any later ver- -- 14-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- 15-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- 16-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- 17-- for more details. You should have received a copy of the GNU General -- 18-- Public License distributed with GNAT; see file COPYING3. If not, go to -- 19-- http://www.gnu.org/licenses for a complete copy of the license. -- 20-- -- 21-- GNAT was originally developed by the GNAT team at New York University. -- 22-- Extensive contributions were provided by Ada Core Technologies Inc. -- 23-- -- 24------------------------------------------------------------------------------ 25 26-- This package contains utility routines used for the generation of the 27-- stubs relevant to the distribution annex. 28 29with Namet; use Namet; 30with Snames; use Snames; 31with Types; use Types; 32 33package Exp_Dist is 34 35 PCS_Version_Number : constant array (PCS_Names) of Int := 36 (Name_No_DSA => 1, 37 Name_GARLIC_DSA => 1, 38 Name_PolyORB_DSA => 5); 39 -- PCS interface version. This is used to check for consistency between the 40 -- compiler used to generate distribution stubs and the PCS implementation. 41 -- It must be incremented whenever a change is made to the generated code 42 -- for distribution stubs that would result in the compiler being 43 -- incompatible with an older version of the PCS, or vice versa. 44 45 procedure Add_RAST_Features (Vis_Decl : Node_Id); 46 -- Build and add bodies for dereference and 'Access subprograms for a 47 -- remote access to subprogram type. Vis_Decl is the declaration node for 48 -- the RAS type. 49 50 procedure Add_RACW_Features (RACW_Type : Entity_Id); 51 -- Add RACW features. If the RACW and the designated type are not in the 52 -- same scope, then Add_RACW_Primitive_Declarations_And_Bodies is called 53 -- automatically since we do know the primitive list already. 54 55 procedure Add_RACW_Primitive_Declarations_And_Bodies 56 (Designated_Type : Entity_Id; 57 Insertion_Node : Node_Id; 58 Body_Decls : List_Id); 59 -- Add primitive for the stub type, and the RPC receiver. The declarations 60 -- are inserted after Insertion_Node, while the bodies are appended at the 61 -- end of Body_Decls. 62 63 procedure Remote_Types_Tagged_Full_View_Encountered 64 (Full_View : Entity_Id); 65 -- When a full view with a private view is encountered in a Remote_Types 66 -- package and corresponds to a tagged type, then this procedure is called 67 -- to generate the needed RACW features if it is needed. 68 69 procedure RACW_Type_Is_Asynchronous (RACW_Type : Entity_Id); 70 -- This subprogram must be called when it is detected that the RACW type 71 -- is asynchronous. 72 73 procedure Expand_Calling_Stubs_Bodies (Unit_Node : Node_Id); 74 -- Call the expansion phase for the calling stubs. The code will be added 75 -- at the end of the compilation unit, which is a package spec. 76 77 procedure Expand_Receiving_Stubs_Bodies (Unit_Node : Node_Id); 78 -- Call the expansion phase for the receiving stubs. The code will be added 79 -- at the end of the compilation unit, which may be either a package spec 80 -- or a package body. 81 82 procedure Expand_All_Calls_Remote_Subprogram_Call (N : Node_Id); 83 -- Rewrite a call to a subprogram located in a Remote_Call_Interface 84 -- package to which the pragma All_Calls_Remote applies so that it 85 -- goes through the PCS. N is either an N_Procedure_Call_Statement 86 -- or an N_Function_Call node. 87 88 procedure Build_Passive_Partition_Stub (U : Node_Id); 89 -- Build stub for a shared passive package. U is the analyzed 90 -- compilation unit for a package declaration. 91 92 function Build_Subprogram_Id 93 (Loc : Source_Ptr; 94 E : Entity_Id) return Node_Id; 95 -- Build a literal representing the remote subprogram identifier of E 96 97 function Copy_Specification 98 (Loc : Source_Ptr; 99 Spec : Node_Id; 100 Ctrl_Type : Entity_Id := Empty; 101 New_Name : Name_Id := No_Name) return Node_Id; 102 -- Build a subprogram specification from another one, or from an 103 -- access-to-subprogram definition. If Ctrl_Type is not Empty, and any 104 -- controlling formal of an anonymous access type is found, then it is 105 -- replaced by an access to Ctrl_Type. If New_Name is given, then it will 106 -- be used as the name for the newly created spec. 107 108 function Corresponding_Stub_Type (RACW_Type : Entity_Id) return Entity_Id; 109 -- Return the stub type associated with the given RACW type 110 111 function Underlying_RACW_Type (RAS_Typ : Entity_Id) return Entity_Id; 112 -- Given a remote access-to-subprogram type or its equivalent 113 -- record type, return the RACW type generated to implement it. 114 115 procedure Append_RACW_Bodies (Decls : List_Id; Spec_Id : Entity_Id); 116 -- Append the unanalyzed subprogram bodies generated to support RACWs 117 -- declared in the given package spec (RACW stream subprograms, calling 118 -- stubs primitive operations) to the given list (which is expected to be 119 -- the declarations list for the corresponding package body, if there is 120 -- one). In the case where a body is present, the subprogram bodies must 121 -- not be generated in the package spec because this would cause an 122 -- incorrect attempt to freeze Taft amendment types declared in the spec. 123 124 function Make_Transportable_Check 125 (Loc : Source_Ptr; 126 Expr : Node_Id) return Node_Id; 127 -- Generate a check that the given expression (an actual in a remote 128 -- subprogram call, or the return value of a function in the context of 129 -- a remote call) satisfies the requirements for being transportable 130 -- across partitions, raising Program_Error if it does not. 131 132 ---------------------------------------------------------------- 133 -- Functions for expansion of PolyORB/DSA specific attributes -- 134 ---------------------------------------------------------------- 135 136 function Build_From_Any_Call 137 (Typ : Entity_Id; 138 N : Node_Id; 139 Decls : List_Id) return Node_Id; 140 -- Build call to From_Any attribute function of type Typ with expression 141 -- N as actual parameter. Decls is the declarations list for an appropriate 142 -- enclosing scope of the point where the call will be inserted; if the 143 -- From_Any attribute for Typ needs to be generated at this point, its 144 -- declaration is appended to Decls. 145 146 function Build_To_Any_Call 147 (Loc : Source_Ptr; 148 N : Node_Id; 149 Decls : List_Id) return Node_Id; 150 -- Build call to To_Any attribute function with expression as actual 151 -- parameter. Loc is the reference location for generated nodes, Decls is 152 -- the declarations list for an appropriate enclosing scope of the point 153 -- where the call will be inserted; if the To_Any attribute for Typ needs 154 -- to be generated at this point, its declaration is appended to Decls. 155 156 function Build_TypeCode_Call 157 (Loc : Source_Ptr; 158 Typ : Entity_Id; 159 Decls : List_Id) return Node_Id; 160 -- Build call to TypeCode attribute function for Typ. Decls is the 161 -- declarations list for an appropriate enclosing scope of the point 162 -- where the call will be inserted; if the To_Any attribute for Typ 163 -- needs to be generated at this point, its declaration is appended 164 -- to Decls. 165 166end Exp_Dist; 167