1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                             S E M _ 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--  Semantic processing for distribution annex facilities
27
28with Snames; use Snames;
29with Types;  use Types;
30
31package Sem_Dist is
32
33   function Get_PCS_Name return PCS_Names;
34   --  Return the name of a literal of type DSA_Implementation_Name in package
35   --  System.Partition_Interface indicating what PCS is currently in use.
36
37   function Get_PCS_Version return Int;
38   --  Return the version number of the PCS API implemented by the PCS.
39   --  The consistency of this version with the one expected by Exp_Dist
40   --  (Exp_Dist.PCS_Version_Number) in Rtsfind.RTE.Check_RPC.
41   --  If no PCS version information is available, 0 is returned.
42
43   function Is_Valid_Remote_Object_Type (E : Entity_Id) return Boolean;
44   --  True if tagged type E is a valid candidate as the root type of the
45   --  designated type for a RACW, i.e. a tagged limited private type, or a
46   --  limited interface type, or a private extension of such a type.
47
48   procedure Add_Stub_Constructs (N : Node_Id);
49   --  Create the stubs constructs for a remote call interface package
50   --  specification or body or for a shared passive specification. For caller
51   --  stubs, expansion takes place directly in the specification and no
52   --  additional compilation unit is created.
53
54   function Build_RAS_Primitive_Specification
55     (Subp_Spec          : Node_Id;
56      Remote_Object_Type : Node_Id) return Node_Id;
57   --  Build a subprogram specification for the primitive operation of the
58   --  Remote_Object_Type used to implement a remote access-to-subprogram
59   --  type whose parameter profile is given by specification Subp_Spec.
60
61   function Is_All_Remote_Call (N : Node_Id) return Boolean;
62   --  Check whether a function or procedure call should be expanded into
63   --  a remote call, because the entity is declared in a package decl that
64   --  is not currently in scope, and the proper pragmas apply.
65
66   procedure Process_Partition_Id (N : Node_Id);
67   --  Replace attribute reference with call to runtime function. The result
68   --  is converted to the context type, because the attribute yields a
69   --  universal integer value.
70
71   procedure Process_Remote_AST_Attribute (N : Node_Id; New_Type : Entity_Id);
72   --  Given N, an access attribute reference node whose prefix is a
73   --  remote subprogram, rewrite N with a call to a conversion function
74   --  whose return type is New_Type.
75
76   procedure Process_Remote_AST_Declaration (N : Node_Id);
77   --  Given N, an access to subprogram type declaration node in RCI or remote
78   --  types unit, build a new record (fat pointer) type declaration using the
79   --  old Defining_Identifier of N and a link to the old declaration node N
80   --  whose Defining_Identifier is changed. We also construct declarations of
81   --  two subprograms in the unit specification which handle remote access to
82   --  subprogram type (fat pointer) dereference and the unit receiver that
83   --  handles remote calls (from remote access to subprogram type values.)
84
85   function Remote_AST_E_Dereference (P : Node_Id) return Boolean;
86   --  If the prefix of an explicit dereference is a record type that
87   --  represent the fat pointer for an Remote access to subprogram, in the
88   --  context of a call, rewrite the enclosing call node into remote call,
89   --  the first actual of which is the fat pointer. Return true if the
90   --  context is correct and the transformation took place.
91
92   function Remote_AST_I_Dereference (P : Node_Id) return Boolean;
93   --  If P is a record type that represents the fat pointer for a remote
94   --  access to subprogram, and P is the prefix of a call, insert an explicit
95   --  dereference and perform the transformation described for the previous
96   --  function.
97
98   function Remote_AST_Null_Value
99     (N   : Node_Id;
100      Typ : Entity_Id) return Boolean;
101   --  If N is a null value and Typ a remote access to subprogram type, this
102   --  function will check if null needs to be replaced with an aggregate and
103   --  will return True in this case. Otherwise, it will return False.
104
105   function Package_Specification_Of_Scope (E : Entity_Id) return Node_Id;
106   --  Return the N_Package_Specification corresponding to a scope E
107
108   function Is_RACW_Stub_Type_Operation (Op : Entity_Id) return Boolean;
109   --  True when Op is a primitive operation of an RACW stub type
110
111end Sem_Dist;
112