1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Einfo
; use Einfo
;
28 with Elists
; use Elists
;
29 with Exp_Atag
; use Exp_Atag
;
30 with Exp_Strm
; use Exp_Strm
;
31 with Exp_Tss
; use Exp_Tss
;
32 with Exp_Util
; use Exp_Util
;
34 with Nlists
; use Nlists
;
35 with Nmake
; use Nmake
;
37 with Rtsfind
; use Rtsfind
;
39 with Sem_Aux
; use Sem_Aux
;
40 with Sem_Cat
; use Sem_Cat
;
41 with Sem_Ch3
; use Sem_Ch3
;
42 with Sem_Ch8
; use Sem_Ch8
;
43 with Sem_Ch12
; use Sem_Ch12
;
44 with Sem_Dist
; use Sem_Dist
;
45 with Sem_Eval
; use Sem_Eval
;
46 with Sem_Util
; use Sem_Util
;
47 with Sinfo
; use Sinfo
;
48 with Stand
; use Stand
;
49 with Stringt
; use Stringt
;
50 with Tbuild
; use Tbuild
;
51 with Ttypes
; use Ttypes
;
52 with Uintp
; use Uintp
;
54 with GNAT
.HTable
; use GNAT
.HTable
;
56 package body Exp_Dist
is
58 -- The following model has been used to implement distributed objects:
59 -- given a designated type D and a RACW type R, then a record of the form:
61 -- type Stub is tagged record
62 -- [...declaration similar to s-parint.ads RACW_Stub_Type...]
65 -- is built. This type has two properties:
67 -- 1) Since it has the same structure as RACW_Stub_Type, it can
68 -- be converted to and from this type to make it suitable for
69 -- System.Partition_Interface.Get_Unique_Remote_Pointer in order
70 -- to avoid memory leaks when the same remote object arrives on the
71 -- same partition through several paths;
73 -- 2) It also has the same dispatching table as the designated type D,
74 -- and thus can be used as an object designated by a value of type
75 -- R on any partition other than the one on which the object has
76 -- been created, since only dispatching calls will be performed and
77 -- the fields themselves will not be used. We call Derive_Subprograms
78 -- to fake half a derivation to ensure that the subprograms do have
79 -- the same dispatching table.
81 First_RCI_Subprogram_Id
: constant := 2;
82 -- RCI subprograms are numbered starting at 2. The RCI receiver for
83 -- an RCI package can thus identify calls received through remote
84 -- access-to-subprogram dereferences by the fact that they have a
85 -- (primitive) subprogram id of 0, and 1 is used for the internal RAS
86 -- information lookup operation. (This is for the Garlic code generation,
87 -- where subprograms are identified by numbers; in the PolyORB version,
88 -- they are identified by name, with a numeric suffix for homonyms.)
90 type Hash_Index
is range 0 .. 50;
92 -----------------------
93 -- Local subprograms --
94 -----------------------
96 function Hash
(F
: Entity_Id
) return Hash_Index
;
97 -- DSA expansion associates stubs to distributed object types using a hash
98 -- table on entity ids.
100 function Hash
(F
: Name_Id
) return Hash_Index
;
101 -- The generation of subprogram identifiers requires an overload counter
102 -- to be associated with each remote subprogram name. These counters are
103 -- maintained in a hash table on name ids.
105 type Subprogram_Identifiers
is record
106 Str_Identifier
: String_Id
;
107 Int_Identifier
: Int
;
110 package Subprogram_Identifier_Table
is
111 new Simple_HTable
(Header_Num
=> Hash_Index
,
112 Element
=> Subprogram_Identifiers
,
113 No_Element
=> (No_String
, 0),
117 -- Mapping between a remote subprogram and the corresponding subprogram
120 package Overload_Counter_Table
is
121 new Simple_HTable
(Header_Num
=> Hash_Index
,
127 -- Mapping between a subprogram name and an integer that counts the number
128 -- of defining subprogram names with that Name_Id encountered so far in a
129 -- given context (an interface).
131 function Get_Subprogram_Ids
(Def
: Entity_Id
) return Subprogram_Identifiers
;
132 function Get_Subprogram_Id
(Def
: Entity_Id
) return String_Id
;
133 function Get_Subprogram_Id
(Def
: Entity_Id
) return Int
;
134 -- Given a subprogram defined in a RCI package, get its distribution
135 -- subprogram identifiers (the distribution identifiers are a unique
136 -- subprogram number, and the non-qualified subprogram name, in the
137 -- casing used for the subprogram declaration; if the name is overloaded,
138 -- a double underscore and a serial number are appended.
140 -- The integer identifier is used to perform remote calls with GARLIC;
141 -- the string identifier is used in the case of PolyORB.
143 -- Although the PolyORB DSA receiving stubs will make a caseless comparison
144 -- when receiving a call, the calling stubs will create requests with the
145 -- exact casing of the defining unit name of the called subprogram, so as
146 -- to allow calls to subprograms on distributed nodes that do distinguish
149 -- NOTE: Another design would be to allow a representation clause on
150 -- subprogram specs: for Subp'Distribution_Identifier use "fooBar";
152 pragma Warnings
(Off
, Get_Subprogram_Id
);
153 -- One homonym only is unreferenced (specific to the GARLIC version)
155 procedure Add_RAS_Dereference_TSS
(N
: Node_Id
);
156 -- Add a subprogram body for RAS Dereference TSS
158 procedure Add_RAS_Proxy_And_Analyze
161 All_Calls_Remote_E
: Entity_Id
;
162 Proxy_Object_Addr
: out Entity_Id
);
163 -- Add the proxy type required, on the receiving (server) side, to handle
164 -- calls to the subprogram declared by Vis_Decl through a remote access
165 -- to subprogram type. All_Calls_Remote_E must be Standard_True if a pragma
166 -- All_Calls_Remote applies, Standard_False otherwise. The new proxy type
167 -- is appended to Decls. Proxy_Object_Addr is a constant of type
168 -- System.Address that designates an instance of the proxy object.
170 function Build_Remote_Subprogram_Proxy_Type
172 ACR_Expression
: Node_Id
) return Node_Id
;
173 -- Build and return a tagged record type definition for an RCI subprogram
174 -- proxy type. ACR_Expression is used as the initialization value for the
175 -- All_Calls_Remote component.
177 function Build_Get_Unique_RP_Call
180 Stub_Type
: Entity_Id
) return List_Id
;
181 -- Build a call to Get_Unique_Remote_Pointer (Pointer), followed by a
182 -- tag fixup (Get_Unique_Remote_Pointer may have changed Pointer'Tag to
183 -- RACW_Stub_Type'Tag, while the desired tag is that of Stub_Type).
185 function Build_Stub_Tag
187 RACW_Type
: Entity_Id
) return Node_Id
;
188 -- Return an expression denoting the tag of the stub type associated with
191 function Build_Subprogram_Calling_Stubs
194 Asynchronous
: Boolean;
195 Dynamically_Asynchronous
: Boolean := False;
196 Stub_Type
: Entity_Id
:= Empty
;
197 RACW_Type
: Entity_Id
:= Empty
;
198 Locator
: Entity_Id
:= Empty
;
199 New_Name
: Name_Id
:= No_Name
) return Node_Id
;
200 -- Build the calling stub for a given subprogram with the subprogram ID
201 -- being Subp_Id. If Stub_Type is given, then the "addr" field of
202 -- parameters of this type will be marshalled instead of the object itself.
203 -- It will then be converted into Stub_Type before performing the real
204 -- call. If Dynamically_Asynchronous is True, then it will be computed at
205 -- run time whether the call is asynchronous or not. Otherwise, the value
206 -- of the formal Asynchronous will be used. If Locator is not Empty, it
207 -- will be used instead of RCI_Cache. If New_Name is given, then it will
208 -- be used instead of the original name.
210 function Build_RPC_Receiver_Specification
211 (RPC_Receiver
: Entity_Id
;
212 Request_Parameter
: Entity_Id
) return Node_Id
;
213 -- Make a subprogram specification for an RPC receiver, with the given
214 -- defining unit name and formal parameter.
216 function Build_Ordered_Parameters_List
(Spec
: Node_Id
) return List_Id
;
217 -- Return an ordered parameter list: unconstrained parameters are put
218 -- at the beginning of the list and constrained ones are put after. If
219 -- there are no parameters, an empty list is returned. Special case:
220 -- the controlling formal of the equivalent RACW operation for a RAS
221 -- type is always left in first position.
223 function Transmit_As_Unconstrained
(Typ
: Entity_Id
) return Boolean;
224 -- True when Typ is an unconstrained type, or a null-excluding access type.
225 -- In either case, this means stubs cannot contain a default-initialized
226 -- object declaration of such type.
228 procedure Add_Calling_Stubs_To_Declarations
(Pkg_Spec
: Node_Id
);
229 -- Add calling stubs to the declarative part
231 function Could_Be_Asynchronous
(Spec
: Node_Id
) return Boolean;
232 -- Return True if nothing prevents the program whose specification is
233 -- given to be asynchronous (i.e. no [IN] OUT parameters).
235 function Pack_Entity_Into_Stream_Access
239 Etyp
: Entity_Id
:= Empty
) return Node_Id
;
240 -- Pack Object (of type Etyp) into Stream. If Etyp is not given,
241 -- then Etype (Object) will be used if present. If the type is
242 -- constrained, then 'Write will be used to output the object,
243 -- If the type is unconstrained, 'Output will be used.
245 function Pack_Node_Into_Stream
249 Etyp
: Entity_Id
) return Node_Id
;
250 -- Similar to above, with an arbitrary node instead of an entity
252 function Pack_Node_Into_Stream_Access
256 Etyp
: Entity_Id
) return Node_Id
;
257 -- Similar to above, with Stream instead of Stream'Access
259 function Make_Selected_Component
262 Selector_Name
: Name_Id
) return Node_Id
;
263 -- Return a selected_component whose prefix denotes the given entity, and
264 -- with the given Selector_Name.
266 function Scope_Of_Spec
(Spec
: Node_Id
) return Entity_Id
;
267 -- Return the scope represented by a given spec
269 procedure Set_Renaming_TSS
272 TSS_Nam
: TSS_Name_Type
);
273 -- Create a renaming declaration of subprogram Nam, and register it as a
274 -- TSS for Typ with name TSS_Nam.
276 function Need_Extra_Constrained
(Parameter
: Node_Id
) return Boolean;
277 -- Return True if the current parameter needs an extra formal to reflect
278 -- its constrained status.
280 function Is_RACW_Controlling_Formal
281 (Parameter
: Node_Id
;
282 Stub_Type
: Entity_Id
) return Boolean;
283 -- Return True if the current parameter is a controlling formal argument
284 -- of type Stub_Type or access to Stub_Type.
286 procedure Declare_Create_NVList
291 -- Append the declaration of NVList to Decls, and its
292 -- initialization to Stmts.
294 function Add_Parameter_To_NVList
297 Parameter
: Entity_Id
;
298 Constrained
: Boolean;
299 RACW_Ctrl
: Boolean := False;
300 Any
: Entity_Id
) return Node_Id
;
301 -- Return a call to Add_Item to add the Any corresponding to the designated
302 -- formal Parameter (with the indicated Constrained status) to NVList.
303 -- RACW_Ctrl must be set to True for controlling formals of distributed
304 -- object primitive operations.
310 -- This record describes various tree fragments associated with the
311 -- generation of RACW calling stubs. One such record exists for every
312 -- distributed object type, i.e. each tagged type that is the designated
313 -- type of one or more RACW type.
315 type Stub_Structure
is record
316 Stub_Type
: Entity_Id
;
317 -- Stub type: this type has the same primitive operations as the
318 -- designated types, but the provided bodies for these operations
319 -- a remote call to an actual target object potentially located on
320 -- another partition; each value of the stub type encapsulates a
321 -- reference to a remote object.
323 Stub_Type_Access
: Entity_Id
;
324 -- A local access type designating the stub type (this is not an RACW
327 RPC_Receiver_Decl
: Node_Id
;
328 -- Declaration for the RPC receiver entity associated with the
329 -- designated type. As an exception, in the case of GARLIC, for an RACW
330 -- that implements a RAS, no object RPC receiver is generated. Instead,
331 -- RPC_Receiver_Decl is the declaration after which the RPC receiver
332 -- would have been inserted.
334 Body_Decls
: List_Id
;
335 -- List of subprogram bodies to be included in generated code: bodies
336 -- for the RACW's stream attributes, and for the primitive operations
339 RACW_Type
: Entity_Id
;
340 -- One of the RACW types designating this distributed object type
341 -- (they are all interchangeable; we use any one of them in order to
342 -- avoid having to create various anonymous access types).
346 Empty_Stub_Structure
: constant Stub_Structure
:=
347 (Empty
, Empty
, Empty
, No_List
, Empty
);
349 package Stubs_Table
is
350 new Simple_HTable
(Header_Num
=> Hash_Index
,
351 Element
=> Stub_Structure
,
352 No_Element
=> Empty_Stub_Structure
,
356 -- Mapping between a RACW designated type and its stub type
358 package Asynchronous_Flags_Table
is
359 new Simple_HTable
(Header_Num
=> Hash_Index
,
360 Element
=> Entity_Id
,
365 -- Mapping between a RACW type and a constant having the value True
366 -- if the RACW is asynchronous and False otherwise.
368 package RCI_Locator_Table
is
369 new Simple_HTable
(Header_Num
=> Hash_Index
,
370 Element
=> Entity_Id
,
375 -- Mapping between a RCI package on which All_Calls_Remote applies and
376 -- the generic instantiation of RCI_Locator for this package.
378 package RCI_Calling_Stubs_Table
is
379 new Simple_HTable
(Header_Num
=> Hash_Index
,
380 Element
=> Entity_Id
,
385 -- Mapping between a RCI subprogram and the corresponding calling stubs
387 function Get_Stub_Elements
(RACW_Type
: Entity_Id
) return Stub_Structure
;
388 -- Return the stub information associated with the given RACW type
390 procedure Add_Stub_Type
391 (Designated_Type
: Entity_Id
;
392 RACW_Type
: Entity_Id
;
394 Stub_Type
: out Entity_Id
;
395 Stub_Type_Access
: out Entity_Id
;
396 RPC_Receiver_Decl
: out Node_Id
;
397 Body_Decls
: out List_Id
;
398 Existing
: out Boolean);
399 -- Add the declaration of the stub type, the access to stub type and the
400 -- object RPC receiver at the end of Decls. If these already exist,
401 -- then nothing is added in the tree but the right values are returned
402 -- anyhow and Existing is set to True.
404 function Get_And_Reset_RACW_Bodies
(RACW_Type
: Entity_Id
) return List_Id
;
405 -- Retrieve the Body_Decls list associated to RACW_Type in the stub
406 -- structure table, reset it to No_List, and return the previous value.
408 procedure Add_RACW_Asynchronous_Flag
409 (Declarations
: List_Id
;
410 RACW_Type
: Entity_Id
);
411 -- Declare a boolean constant associated with RACW_Type whose value
412 -- indicates at run time whether a pragma Asynchronous applies to it.
414 procedure Assign_Subprogram_Identifier
418 -- Determine the distribution subprogram identifier to
419 -- be used for remote subprogram Def, return it in Id and
420 -- store it in a hash table for later retrieval by
421 -- Get_Subprogram_Id. Spn is the subprogram number.
423 function RCI_Package_Locator
425 Package_Spec
: Node_Id
) return Node_Id
;
426 -- Instantiate the generic package RCI_Locator in order to locate the
427 -- RCI package whose spec is given as argument.
429 function Make_Tag_Check
(Loc
: Source_Ptr
; N
: Node_Id
) return Node_Id
;
430 -- Surround a node N by a tag check, as in:
434 -- when E : Ada.Tags.Tag_Error =>
435 -- Raise_Exception (Program_Error'Identity,
436 -- Exception_Message (E));
439 function Input_With_Tag_Check
441 Var_Type
: Entity_Id
;
442 Stream
: Node_Id
) return Node_Id
;
443 -- Return a function with the following form:
444 -- function R return Var_Type is
446 -- return Var_Type'Input (S);
448 -- when E : Ada.Tags.Tag_Error =>
449 -- Raise_Exception (Program_Error'Identity,
450 -- Exception_Message (E));
453 procedure Build_Actual_Object_Declaration
459 -- Build the declaration of an object with the given defining identifier,
460 -- initialized with Expr if provided, to serve as actual parameter in a
461 -- server stub. If Variable is true, the declared object will be a variable
462 -- (case of an out or in out formal), else it will be a constant. Object's
463 -- Ekind is set accordingly. The declaration, as well as any other
464 -- declarations it requires, are appended to Decls.
466 --------------------------------------------
467 -- Hooks for PCS-specific code generation --
468 --------------------------------------------
470 -- Part of the code generation circuitry for distribution needs to be
471 -- tailored for each implementation of the PCS. For each routine that
472 -- needs to be specialized, a Specific_<routine> wrapper is created,
473 -- which calls the corresponding <routine> in package
474 -- <pcs_implementation>_Support.
476 procedure Specific_Add_RACW_Features
477 (RACW_Type
: Entity_Id
;
479 Stub_Type
: Entity_Id
;
480 Stub_Type_Access
: Entity_Id
;
481 RPC_Receiver_Decl
: Node_Id
;
482 Body_Decls
: List_Id
);
483 -- Add declaration for TSSs for a given RACW type. The declarations are
484 -- added just after the declaration of the RACW type itself. If the RACW
485 -- appears in the main unit, Body_Decls is a list of declarations to which
486 -- the bodies are appended. Else Body_Decls is No_List.
487 -- PCS-specific ancillary subprogram for Add_RACW_Features.
489 procedure Specific_Add_RAST_Features
491 RAS_Type
: Entity_Id
);
492 -- Add declaration for TSSs for a given RAS type. PCS-specific ancillary
493 -- subprogram for Add_RAST_Features.
495 -- An RPC_Target record is used during construction of calling stubs
496 -- to pass PCS-specific tree fragments corresponding to the information
497 -- necessary to locate the target of a remote subprogram call.
499 type RPC_Target
(PCS_Kind
: PCS_Names
) is record
501 when Name_PolyORB_DSA
=>
503 -- An expression whose value is a PolyORB reference to the target
507 Partition
: Entity_Id
;
508 -- A variable containing the Partition_ID of the target partition
510 RPC_Receiver
: Node_Id
;
511 -- An expression whose value is the address of the target RPC
516 procedure Specific_Build_General_Calling_Stubs
518 Statements
: List_Id
;
520 Subprogram_Id
: Node_Id
;
521 Asynchronous
: Node_Id
:= Empty
;
522 Is_Known_Asynchronous
: Boolean := False;
523 Is_Known_Non_Asynchronous
: Boolean := False;
524 Is_Function
: Boolean;
526 Stub_Type
: Entity_Id
:= Empty
;
527 RACW_Type
: Entity_Id
:= Empty
;
529 -- Build calling stubs for general purpose. The parameters are:
530 -- Decls : A place to put declarations
531 -- Statements : A place to put statements
532 -- Target : PCS-specific target information (see details in
533 -- RPC_Target declaration).
534 -- Subprogram_Id : A node containing the subprogram ID
535 -- Asynchronous : True if an APC must be made instead of an RPC.
536 -- The value needs not be supplied if one of the
537 -- Is_Known_... is True.
538 -- Is_Known_Async... : True if we know that this is asynchronous
539 -- Is_Known_Non_A... : True if we know that this is not asynchronous
540 -- Spec : Node with a Parameter_Specifications and a
541 -- Result_Definition if applicable
542 -- Stub_Type : For case of RACW stubs, parameters of type access
543 -- to Stub_Type will be marshalled using the address
544 -- address of the object (the addr field) rather
545 -- than using the 'Write on the stub itself
546 -- Nod : Used to provide sloc for generated code
548 function Specific_Build_Stub_Target
551 RCI_Locator
: Entity_Id
;
552 Controlling_Parameter
: Entity_Id
) return RPC_Target
;
553 -- Build call target information nodes for use within calling stubs. In the
554 -- RCI case, RCI_Locator is the entity for the instance of RCI_Locator. If
555 -- for an RACW, Controlling_Parameter is the entity for the controlling
556 -- formal parameter used to determine the location of the target of the
557 -- call. Decls provides a location where variable declarations can be
558 -- appended to construct the necessary values.
560 function Specific_RPC_Receiver_Decl
561 (RACW_Type
: Entity_Id
) return Node_Id
;
562 -- Build the RPC receiver, for RACW, if applicable, else return Empty
564 procedure Specific_Build_RPC_Receiver_Body
565 (RPC_Receiver
: Entity_Id
;
566 Request
: out Entity_Id
;
567 Subp_Id
: out Entity_Id
;
568 Subp_Index
: out Entity_Id
;
571 -- Make a subprogram body for an RPC receiver, with the given
572 -- defining unit name. On return:
573 -- - Subp_Id is the subprogram identifier from the PCS.
574 -- - Subp_Index is the index in the list of subprograms
575 -- used for dispatching (a variable of type Subprogram_Id).
576 -- - Stmts is the place where the request dispatching
577 -- statements can occur,
578 -- - Decl is the subprogram body declaration.
580 function Specific_Build_Subprogram_Receiving_Stubs
582 Asynchronous
: Boolean;
583 Dynamically_Asynchronous
: Boolean := False;
584 Stub_Type
: Entity_Id
:= Empty
;
585 RACW_Type
: Entity_Id
:= Empty
;
586 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
;
587 -- Build the receiving stub for a given subprogram. The subprogram
588 -- declaration is also built by this procedure, and the value returned
589 -- is a N_Subprogram_Body. If a parameter of type access to Stub_Type is
590 -- found in the specification, then its address is read from the stream
591 -- instead of the object itself and converted into an access to
592 -- class-wide type before doing the real call using any of the RACW type
593 -- pointing on the designated type.
595 procedure Specific_Add_Obj_RPC_Receiver_Completion
598 RPC_Receiver
: Entity_Id
;
599 Stub_Elements
: Stub_Structure
);
600 -- Add the necessary code to Decls after the completion of generation
601 -- of the RACW RPC receiver described by Stub_Elements.
603 procedure Specific_Add_Receiving_Stubs_To_Declarations
607 -- Add receiving stubs to the declarative part of an RCI unit
613 package GARLIC_Support
is
615 -- Support for generating DSA code that uses the GARLIC PCS
617 -- The subprograms below provide the GARLIC versions of the
618 -- corresponding Specific_<subprogram> routine declared above.
620 procedure Add_RACW_Features
621 (RACW_Type
: Entity_Id
;
622 Stub_Type
: Entity_Id
;
623 Stub_Type_Access
: Entity_Id
;
624 RPC_Receiver_Decl
: Node_Id
;
625 Body_Decls
: List_Id
);
627 procedure Add_RAST_Features
629 RAS_Type
: Entity_Id
);
631 procedure Build_General_Calling_Stubs
633 Statements
: List_Id
;
634 Target_Partition
: Entity_Id
; -- From RPC_Target
635 Target_RPC_Receiver
: Node_Id
; -- From RPC_Target
636 Subprogram_Id
: Node_Id
;
637 Asynchronous
: Node_Id
:= Empty
;
638 Is_Known_Asynchronous
: Boolean := False;
639 Is_Known_Non_Asynchronous
: Boolean := False;
640 Is_Function
: Boolean;
642 Stub_Type
: Entity_Id
:= Empty
;
643 RACW_Type
: Entity_Id
:= Empty
;
646 function Build_Stub_Target
649 RCI_Locator
: Entity_Id
;
650 Controlling_Parameter
: Entity_Id
) return RPC_Target
;
652 function RPC_Receiver_Decl
(RACW_Type
: Entity_Id
) return Node_Id
;
654 function Build_Subprogram_Receiving_Stubs
656 Asynchronous
: Boolean;
657 Dynamically_Asynchronous
: Boolean := False;
658 Stub_Type
: Entity_Id
:= Empty
;
659 RACW_Type
: Entity_Id
:= Empty
;
660 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
;
662 procedure Add_Obj_RPC_Receiver_Completion
665 RPC_Receiver
: Entity_Id
;
666 Stub_Elements
: Stub_Structure
);
668 procedure Add_Receiving_Stubs_To_Declarations
673 procedure Build_RPC_Receiver_Body
674 (RPC_Receiver
: Entity_Id
;
675 Request
: out Entity_Id
;
676 Subp_Id
: out Entity_Id
;
677 Subp_Index
: out Entity_Id
;
683 ---------------------
684 -- PolyORB_Support --
685 ---------------------
687 package PolyORB_Support
is
689 -- Support for generating DSA code that uses the PolyORB PCS
691 -- The subprograms below provide the PolyORB versions of the
692 -- corresponding Specific_<subprogram> routine declared above.
694 procedure Add_RACW_Features
695 (RACW_Type
: Entity_Id
;
697 Stub_Type
: Entity_Id
;
698 Stub_Type_Access
: Entity_Id
;
699 RPC_Receiver_Decl
: Node_Id
;
700 Body_Decls
: List_Id
);
702 procedure Add_RAST_Features
704 RAS_Type
: Entity_Id
);
706 procedure Build_General_Calling_Stubs
708 Statements
: List_Id
;
709 Target_Object
: Node_Id
; -- From RPC_Target
710 Subprogram_Id
: Node_Id
;
711 Asynchronous
: Node_Id
:= Empty
;
712 Is_Known_Asynchronous
: Boolean := False;
713 Is_Known_Non_Asynchronous
: Boolean := False;
714 Is_Function
: Boolean;
716 Stub_Type
: Entity_Id
:= Empty
;
717 RACW_Type
: Entity_Id
:= Empty
;
720 function Build_Stub_Target
723 RCI_Locator
: Entity_Id
;
724 Controlling_Parameter
: Entity_Id
) return RPC_Target
;
726 function RPC_Receiver_Decl
(RACW_Type
: Entity_Id
) return Node_Id
;
728 function Build_Subprogram_Receiving_Stubs
730 Asynchronous
: Boolean;
731 Dynamically_Asynchronous
: Boolean := False;
732 Stub_Type
: Entity_Id
:= Empty
;
733 RACW_Type
: Entity_Id
:= Empty
;
734 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
;
736 procedure Add_Obj_RPC_Receiver_Completion
739 RPC_Receiver
: Entity_Id
;
740 Stub_Elements
: Stub_Structure
);
742 procedure Add_Receiving_Stubs_To_Declarations
747 procedure Build_RPC_Receiver_Body
748 (RPC_Receiver
: Entity_Id
;
749 Request
: out Entity_Id
;
750 Subp_Id
: out Entity_Id
;
751 Subp_Index
: out Entity_Id
;
755 procedure Reserve_NamingContext_Methods
;
756 -- Mark the method names for interface NamingContext as already used in
757 -- the overload table, so no clashes occur with user code (with the
758 -- PolyORB PCS, RCIs Implement The NamingContext interface to allow
759 -- their methods to be accessed as objects, for the implementation of
760 -- remote access-to-subprogram types).
768 -- Routines to build distribution helper subprograms for user-defined
769 -- types. For implementation of the Distributed systems annex (DSA)
770 -- over the PolyORB generic middleware components, it is necessary to
771 -- generate several supporting subprograms for each application data
772 -- type used in inter-partition communication. These subprograms are:
774 -- A Typecode function returning a high-level description of the
777 -- Two conversion functions allowing conversion of values of the
778 -- type from and to the generic data containers used by PolyORB.
779 -- These generic containers are called 'Any' type values after the
780 -- CORBA terminology, and hence the conversion subprograms are
781 -- named To_Any and From_Any.
783 function Build_From_Any_Call
786 Decls
: List_Id
) return Node_Id
;
787 -- Build call to From_Any attribute function of type Typ with
788 -- expression N as actual parameter. Decls is the declarations list
789 -- for an appropriate enclosing scope of the point where the call
790 -- will be inserted; if the From_Any attribute for Typ needs to be
791 -- generated at this point, its declaration is appended to Decls.
793 procedure Build_From_Any_Function
797 Fnam
: out Entity_Id
);
798 -- Build From_Any attribute function for Typ. Loc is the reference
799 -- location for generated nodes, Typ is the type for which the
800 -- conversion function is generated. On return, Decl and Fnam contain
801 -- the declaration and entity for the newly-created function.
803 function Build_To_Any_Call
807 Constrained
: Boolean := False) return Node_Id
;
808 -- Build call to To_Any attribute function with expression as actual
809 -- parameter. Loc is the reference location of generated nodes,
810 -- Decls is the declarations list for an appropriate enclosing scope
811 -- of the point where the call will be inserted; if the To_Any
812 -- attribute for the type of N needs to be generated at this point,
813 -- its declaration is appended to Decls. For the case of a limited
814 -- type, there is an additional parameter Constrained indicating
815 -- whether 'Write (when True) or 'Output (when False) is used.
817 procedure Build_To_Any_Function
821 Fnam
: out Entity_Id
);
822 -- Build To_Any attribute function for Typ. Loc is the reference
823 -- location for generated nodes, Typ is the type for which the
824 -- conversion function is generated. On return, Decl and Fnam contain
825 -- the declaration and entity for the newly-created function.
827 function Build_TypeCode_Call
830 Decls
: List_Id
) return Node_Id
;
831 -- Build call to TypeCode attribute function for Typ. Decls is the
832 -- declarations list for an appropriate enclosing scope of the point
833 -- where the call will be inserted; if the To_Any attribute for Typ
834 -- needs to be generated at this point, its declaration is appended
837 procedure Build_TypeCode_Function
841 Fnam
: out Entity_Id
);
842 -- Build TypeCode attribute function for Typ. Loc is the reference
843 -- location for generated nodes, Typ is the type for which the
844 -- typecode function is generated. On return, Decl and Fnam contain
845 -- the declaration and entity for the newly-created function.
847 procedure Build_Name_And_Repository_Id
849 Name_Str
: out String_Id
;
850 Repo_Id_Str
: out String_Id
);
851 -- In the PolyORB distribution model, each distributed object type
852 -- and each distributed operation has a globally unique identifier,
853 -- its Repository Id. This subprogram builds and returns two strings
854 -- for entity E (a distributed object type or operation): one
855 -- containing the name of E, the second containing its repository id.
857 procedure Assign_Opaque_From_Any
863 Constrained
: Boolean := False);
864 -- For a Target object of type Typ, which has opaque representation
865 -- as a sequence of octets determined by stream attributes (which
866 -- includes all limited types), append code to Stmts performing the
868 -- Target := Typ'From_Any (N)
870 -- or, if Target is Empty:
871 -- return Typ'From_Any (N)
873 -- Constrained determines whether 'Input (when False) or 'Read
874 -- (when True) is used.
880 -- The following PolyORB-specific subprograms are made visible to Exp_Attr:
882 function Build_From_Any_Call
885 Decls
: List_Id
) return Node_Id
886 renames PolyORB_Support
.Helpers
.Build_From_Any_Call
;
888 function Build_To_Any_Call
892 Constrained
: Boolean := False) return Node_Id
893 renames PolyORB_Support
.Helpers
.Build_To_Any_Call
;
895 function Build_TypeCode_Call
898 Decls
: List_Id
) return Node_Id
899 renames PolyORB_Support
.Helpers
.Build_TypeCode_Call
;
901 ------------------------------------
902 -- Local variables and structures --
903 ------------------------------------
906 -- Needs comments ???
908 Output_From_Constrained
: constant array (Boolean) of Name_Id
:=
909 (False => Name_Output
,
911 -- The attribute to choose depending on the fact that the parameter
912 -- is constrained or not. There is no such thing as Input_From_Constrained
913 -- since this require separate mechanisms ('Input is a function while
914 -- 'Read is a procedure).
917 with procedure Process_Subprogram_Declaration
(Decl
: Node_Id
);
918 -- Generate calling or receiving stub for this subprogram declaration
920 procedure Build_Package_Stubs
(Pkg_Spec
: Node_Id
);
921 -- Recursively visit the given RCI Package_Specification, calling
922 -- Process_Subprogram_Declaration for each remote subprogram.
924 -------------------------
925 -- Build_Package_Stubs --
926 -------------------------
928 procedure Build_Package_Stubs
(Pkg_Spec
: Node_Id
) is
929 Decls
: constant List_Id
:= Visible_Declarations
(Pkg_Spec
);
932 procedure Visit_Nested_Pkg
(Nested_Pkg_Decl
: Node_Id
);
933 -- Recurse for the given nested package declaration
935 ----------------------
936 -- Visit_Nested_Pkg --
937 ----------------------
939 procedure Visit_Nested_Pkg
(Nested_Pkg_Decl
: Node_Id
) is
940 Nested_Pkg_Spec
: constant Node_Id
:= Specification
(Nested_Pkg_Decl
);
942 Push_Scope
(Scope_Of_Spec
(Nested_Pkg_Spec
));
943 Build_Package_Stubs
(Nested_Pkg_Spec
);
945 end Visit_Nested_Pkg
;
947 -- Start of processing for Build_Package_Stubs
950 Decl
:= First
(Decls
);
951 while Present
(Decl
) loop
953 when N_Subprogram_Declaration
=>
955 -- Note: we test Comes_From_Source on Spec, not Decl, because
956 -- in the case of a subprogram instance, only the specification
957 -- (not the declaration) is marked as coming from source.
959 if Comes_From_Source
(Specification
(Decl
)) then
960 Process_Subprogram_Declaration
(Decl
);
963 when N_Package_Declaration
=>
965 -- Case of a nested package or package instantiation coming
966 -- from source. Note that the anonymous wrapper package for
967 -- subprogram instances is not flagged Is_Generic_Instance at
968 -- this point, so there is a distinct circuit to handle them
969 -- (see case N_Subprogram_Instantiation below).
972 Pkg_Ent
: constant Entity_Id
:=
973 Defining_Unit_Name
(Specification
(Decl
));
975 if Comes_From_Source
(Decl
)
977 (Is_Generic_Instance
(Pkg_Ent
)
978 and then Comes_From_Source
979 (Get_Unit_Instantiation_Node
(Pkg_Ent
)))
981 Visit_Nested_Pkg
(Decl
);
985 when N_Subprogram_Instantiation
=>
987 -- The subprogram declaration for an instance of a generic
988 -- subprogram is wrapped in a package that does not come from
989 -- source, so we need to explicitly traverse it here.
991 if Comes_From_Source
(Decl
) then
992 Visit_Nested_Pkg
(Instance_Spec
(Decl
));
1001 end Build_Package_Stubs
;
1003 ---------------------------------------
1004 -- Add_Calling_Stubs_To_Declarations --
1005 ---------------------------------------
1007 procedure Add_Calling_Stubs_To_Declarations
(Pkg_Spec
: Node_Id
) is
1008 Loc
: constant Source_Ptr
:= Sloc
(Pkg_Spec
);
1010 Current_Subprogram_Number
: Int
:= First_RCI_Subprogram_Id
;
1011 -- Subprogram id 0 is reserved for calls received from
1012 -- remote access-to-subprogram dereferences.
1014 RCI_Instantiation
: Node_Id
;
1016 procedure Visit_Subprogram
(Decl
: Node_Id
);
1017 -- Generate calling stub for one remote subprogram
1019 ----------------------
1020 -- Visit_Subprogram --
1021 ----------------------
1023 procedure Visit_Subprogram
(Decl
: Node_Id
) is
1024 Loc
: constant Source_Ptr
:= Sloc
(Decl
);
1025 Spec
: constant Node_Id
:= Specification
(Decl
);
1026 Subp_Stubs
: Node_Id
;
1028 Subp_Str
: String_Id
;
1029 pragma Warnings
(Off
, Subp_Str
);
1032 -- Disable expansion of stubs if serious errors have been diagnosed,
1033 -- because otherwise some illegal remote subprogram declarations
1034 -- could cause cascaded errors in stubs.
1036 if Serious_Errors_Detected
/= 0 then
1040 Assign_Subprogram_Identifier
1041 (Defining_Unit_Name
(Spec
), Current_Subprogram_Number
, Subp_Str
);
1044 Build_Subprogram_Calling_Stubs
1047 Build_Subprogram_Id
(Loc
, Defining_Unit_Name
(Spec
)),
1049 Nkind
(Spec
) = N_Procedure_Specification
1050 and then Is_Asynchronous
(Defining_Unit_Name
(Spec
)));
1052 Append_To
(List_Containing
(Decl
), Subp_Stubs
);
1053 Analyze
(Subp_Stubs
);
1055 Current_Subprogram_Number
:= Current_Subprogram_Number
+ 1;
1056 end Visit_Subprogram
;
1058 procedure Visit_Spec
is new Build_Package_Stubs
(Visit_Subprogram
);
1060 -- Start of processing for Add_Calling_Stubs_To_Declarations
1063 Push_Scope
(Scope_Of_Spec
(Pkg_Spec
));
1065 -- The first thing added is an instantiation of the generic package
1066 -- System.Partition_Interface.RCI_Locator with the name of this remote
1067 -- package. This will act as an interface with the name server to
1068 -- determine the Partition_ID and the RPC_Receiver for the receiver
1071 RCI_Instantiation
:= RCI_Package_Locator
(Loc
, Pkg_Spec
);
1072 RCI_Cache
:= Defining_Unit_Name
(RCI_Instantiation
);
1074 Append_To
(Visible_Declarations
(Pkg_Spec
), RCI_Instantiation
);
1075 Analyze
(RCI_Instantiation
);
1077 -- For each subprogram declaration visible in the spec, we do build a
1078 -- body. We also increment a counter to assign a different Subprogram_Id
1079 -- to each subprogram. The receiving stubs processing uses the same
1080 -- mechanism and will thus assign the same Id and do the correct
1083 Overload_Counter_Table
.Reset
;
1084 PolyORB_Support
.Reserve_NamingContext_Methods
;
1086 Visit_Spec
(Pkg_Spec
);
1089 end Add_Calling_Stubs_To_Declarations
;
1091 -----------------------------
1092 -- Add_Parameter_To_NVList --
1093 -----------------------------
1095 function Add_Parameter_To_NVList
1098 Parameter
: Entity_Id
;
1099 Constrained
: Boolean;
1100 RACW_Ctrl
: Boolean := False;
1101 Any
: Entity_Id
) return Node_Id
1103 Parameter_Name_String
: String_Id
;
1104 Parameter_Mode
: Node_Id
;
1106 function Parameter_Passing_Mode
1108 Parameter
: Entity_Id
;
1109 Constrained
: Boolean) return Node_Id
;
1110 -- Return an expression that denotes the parameter passing mode to be
1111 -- used for Parameter in distribution stubs, where Constrained is
1112 -- Parameter's constrained status.
1114 ----------------------------
1115 -- Parameter_Passing_Mode --
1116 ----------------------------
1118 function Parameter_Passing_Mode
1120 Parameter
: Entity_Id
;
1121 Constrained
: Boolean) return Node_Id
1126 if Out_Present
(Parameter
) then
1127 if In_Present
(Parameter
)
1128 or else not Constrained
1130 -- Unconstrained formals must be translated
1131 -- to 'in' or 'inout', not 'out', because
1132 -- they need to be constrained by the actual.
1134 Lib_RE
:= RE_Mode_Inout
;
1136 Lib_RE
:= RE_Mode_Out
;
1140 Lib_RE
:= RE_Mode_In
;
1143 return New_Occurrence_Of
(RTE
(Lib_RE
), Loc
);
1144 end Parameter_Passing_Mode
;
1146 -- Start of processing for Add_Parameter_To_NVList
1149 if Nkind
(Parameter
) = N_Defining_Identifier
then
1150 Get_Name_String
(Chars
(Parameter
));
1152 Get_Name_String
(Chars
(Defining_Identifier
(Parameter
)));
1155 Parameter_Name_String
:= String_From_Name_Buffer
;
1157 if RACW_Ctrl
or else Nkind
(Parameter
) = N_Defining_Identifier
then
1159 -- When the parameter passed to Add_Parameter_To_NVList is an
1160 -- Extra_Constrained parameter, Parameter is an N_Defining_
1161 -- Identifier, instead of a complete N_Parameter_Specification.
1162 -- Thus, we explicitly set 'in' mode in this case.
1164 Parameter_Mode
:= New_Occurrence_Of
(RTE
(RE_Mode_In
), Loc
);
1168 Parameter_Passing_Mode
(Loc
, Parameter
, Constrained
);
1172 Make_Procedure_Call_Statement
(Loc
,
1174 New_Occurrence_Of
(RTE
(RE_NVList_Add_Item
), Loc
),
1175 Parameter_Associations
=> New_List
(
1176 New_Occurrence_Of
(NVList
, Loc
),
1177 Make_Function_Call
(Loc
,
1179 New_Occurrence_Of
(RTE
(RE_To_PolyORB_String
), Loc
),
1180 Parameter_Associations
=> New_List
(
1181 Make_String_Literal
(Loc
, Strval
=> Parameter_Name_String
))),
1182 New_Occurrence_Of
(Any
, Loc
),
1184 end Add_Parameter_To_NVList
;
1186 --------------------------------
1187 -- Add_RACW_Asynchronous_Flag --
1188 --------------------------------
1190 procedure Add_RACW_Asynchronous_Flag
1191 (Declarations
: List_Id
;
1192 RACW_Type
: Entity_Id
)
1194 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
1196 Asynchronous_Flag
: constant Entity_Id
:=
1197 Make_Defining_Identifier
(Loc
,
1198 New_External_Name
(Chars
(RACW_Type
), 'A'));
1201 -- Declare the asynchronous flag. This flag will be changed to True
1202 -- whenever it is known that the RACW type is asynchronous.
1204 Append_To
(Declarations
,
1205 Make_Object_Declaration
(Loc
,
1206 Defining_Identifier
=> Asynchronous_Flag
,
1207 Constant_Present
=> True,
1208 Object_Definition
=> New_Occurrence_Of
(Standard_Boolean
, Loc
),
1209 Expression
=> New_Occurrence_Of
(Standard_False
, Loc
)));
1211 Asynchronous_Flags_Table
.Set
(RACW_Type
, Asynchronous_Flag
);
1212 end Add_RACW_Asynchronous_Flag
;
1214 -----------------------
1215 -- Add_RACW_Features --
1216 -----------------------
1218 procedure Add_RACW_Features
(RACW_Type
: Entity_Id
) is
1219 Desig
: constant Entity_Id
:= Etype
(Designated_Type
(RACW_Type
));
1220 Same_Scope
: constant Boolean := Scope
(Desig
) = Scope
(RACW_Type
);
1224 Body_Decls
: List_Id
;
1226 Stub_Type
: Entity_Id
;
1227 Stub_Type_Access
: Entity_Id
;
1228 RPC_Receiver_Decl
: Node_Id
;
1231 -- True when appropriate stubs have already been generated (this is the
1232 -- case when another RACW with the same designated type has already been
1233 -- encountered), in which case we reuse the previous stubs rather than
1234 -- generating new ones.
1237 if not Expander_Active
then
1241 -- Mark the current package declaration as containing an RACW, so that
1242 -- the bodies for the calling stubs and the RACW stream subprograms
1243 -- are attached to the tree when the corresponding body is encountered.
1245 Set_Has_RACW
(Current_Scope
);
1247 -- Look for place to declare the RACW stub type and RACW operations
1253 -- Case of declaring the RACW in the same package as its designated
1254 -- type: we know that the designated type is a private type, so we
1255 -- use the private declarations list.
1257 Pkg_Spec
:= Package_Specification_Of_Scope
(Current_Scope
);
1259 if Present
(Private_Declarations
(Pkg_Spec
)) then
1260 Decls
:= Private_Declarations
(Pkg_Spec
);
1262 Decls
:= Visible_Declarations
(Pkg_Spec
);
1266 -- Case of declaring the RACW in another package than its designated
1267 -- type: use the private declarations list if present; otherwise
1268 -- use the visible declarations.
1270 Decls
:= List_Containing
(Declaration_Node
(RACW_Type
));
1274 -- If we were unable to find the declarations, that means that the
1275 -- completion of the type was missing. We can safely return and let the
1276 -- error be caught by the semantic analysis.
1283 (Designated_Type
=> Desig
,
1284 RACW_Type
=> RACW_Type
,
1286 Stub_Type
=> Stub_Type
,
1287 Stub_Type_Access
=> Stub_Type_Access
,
1288 RPC_Receiver_Decl
=> RPC_Receiver_Decl
,
1289 Body_Decls
=> Body_Decls
,
1290 Existing
=> Existing
);
1292 -- If this RACW is not in the main unit, do not generate primitive or
1295 if not Entity_Is_In_Main_Unit
(RACW_Type
) then
1296 Body_Decls
:= No_List
;
1299 Add_RACW_Asynchronous_Flag
1300 (Declarations
=> Decls
,
1301 RACW_Type
=> RACW_Type
);
1303 Specific_Add_RACW_Features
1304 (RACW_Type
=> RACW_Type
,
1306 Stub_Type
=> Stub_Type
,
1307 Stub_Type_Access
=> Stub_Type_Access
,
1308 RPC_Receiver_Decl
=> RPC_Receiver_Decl
,
1309 Body_Decls
=> Body_Decls
);
1311 -- If we already have stubs for this designated type, nothing to do
1317 if Is_Frozen
(Desig
) then
1318 Validate_RACW_Primitives
(RACW_Type
);
1319 Add_RACW_Primitive_Declarations_And_Bodies
1320 (Designated_Type
=> Desig
,
1321 Insertion_Node
=> RPC_Receiver_Decl
,
1322 Body_Decls
=> Body_Decls
);
1325 -- Validate_RACW_Primitives requires the list of all primitives of
1326 -- the designated type, so defer processing until Desig is frozen.
1327 -- See Exp_Ch3.Freeze_Type.
1329 Add_Access_Type_To_Process
(E
=> Desig
, A
=> RACW_Type
);
1331 end Add_RACW_Features
;
1333 ------------------------------------------------
1334 -- Add_RACW_Primitive_Declarations_And_Bodies --
1335 ------------------------------------------------
1337 procedure Add_RACW_Primitive_Declarations_And_Bodies
1338 (Designated_Type
: Entity_Id
;
1339 Insertion_Node
: Node_Id
;
1340 Body_Decls
: List_Id
)
1342 Loc
: constant Source_Ptr
:= Sloc
(Insertion_Node
);
1343 -- Set Sloc of generated declaration copy of insertion node Sloc, so
1344 -- the declarations are recognized as belonging to the current package.
1346 Stub_Elements
: constant Stub_Structure
:=
1347 Stubs_Table
.Get
(Designated_Type
);
1349 pragma Assert
(Stub_Elements
/= Empty_Stub_Structure
);
1351 Is_RAS
: constant Boolean :=
1352 not Comes_From_Source
(Stub_Elements
.RACW_Type
);
1353 -- Case of the RACW generated to implement a remote access-to-
1356 Build_Bodies
: constant Boolean :=
1357 In_Extended_Main_Code_Unit
(Stub_Elements
.Stub_Type
);
1358 -- True when bodies must be prepared in Body_Decls. Bodies are generated
1359 -- only when the main unit is the unit that contains the stub type.
1361 Current_Insertion_Node
: Node_Id
:= Insertion_Node
;
1363 RPC_Receiver
: Entity_Id
;
1364 RPC_Receiver_Statements
: List_Id
;
1365 RPC_Receiver_Case_Alternatives
: constant List_Id
:= New_List
;
1366 RPC_Receiver_Elsif_Parts
: List_Id
:= No_List
;
1367 RPC_Receiver_Request
: Entity_Id
:= Empty
;
1368 RPC_Receiver_Subp_Id
: Entity_Id
:= Empty
;
1369 RPC_Receiver_Subp_Index
: Entity_Id
:= Empty
;
1371 Subp_Str
: String_Id
;
1373 Current_Primitive_Elmt
: Elmt_Id
;
1374 Current_Primitive
: Entity_Id
;
1375 Current_Primitive_Body
: Node_Id
;
1376 Current_Primitive_Spec
: Node_Id
;
1377 Current_Primitive_Decl
: Node_Id
;
1378 Current_Primitive_Number
: Int
:= 0;
1379 Current_Primitive_Alias
: Node_Id
;
1380 Current_Receiver
: Entity_Id
;
1381 Current_Receiver_Body
: Node_Id
;
1382 RPC_Receiver_Decl
: Node_Id
;
1383 Possibly_Asynchronous
: Boolean;
1386 if not Expander_Active
then
1391 RPC_Receiver
:= Make_Temporary
(Loc
, 'P');
1393 Specific_Build_RPC_Receiver_Body
1394 (RPC_Receiver
=> RPC_Receiver
,
1395 Request
=> RPC_Receiver_Request
,
1396 Subp_Id
=> RPC_Receiver_Subp_Id
,
1397 Subp_Index
=> RPC_Receiver_Subp_Index
,
1398 Stmts
=> RPC_Receiver_Statements
,
1399 Decl
=> RPC_Receiver_Decl
);
1401 if Get_PCS_Name
= Name_PolyORB_DSA
then
1403 -- For the case of PolyORB, we need to map a textual operation
1404 -- name into a primitive index. Currently we do so using a simple
1405 -- sequence of string comparisons.
1407 RPC_Receiver_Elsif_Parts
:= New_List
;
1411 -- Build callers, receivers for every primitive operations and a RPC
1412 -- receiver for this type. Note that we use Direct_Primitive_Operations,
1413 -- not Primitive_Operations, because we really want just the primitives
1414 -- of the tagged type itself, and in the case of a tagged synchronized
1415 -- type we do not want to get the primitives of the corresponding
1418 if Present
(Direct_Primitive_Operations
(Designated_Type
)) then
1419 Overload_Counter_Table
.Reset
;
1421 Current_Primitive_Elmt
:=
1422 First_Elmt
(Direct_Primitive_Operations
(Designated_Type
));
1423 while Current_Primitive_Elmt
/= No_Elmt
loop
1424 Current_Primitive
:= Node
(Current_Primitive_Elmt
);
1426 -- Copy the primitive of all the parents, except predefined ones
1427 -- that are not remotely dispatching. Also omit hidden primitives
1428 -- (occurs in the case of primitives of interface progenitors
1429 -- other than immediate ancestors of the Designated_Type).
1431 if Chars
(Current_Primitive
) /= Name_uSize
1432 and then Chars
(Current_Primitive
) /= Name_uAlignment
1434 (Is_TSS
(Current_Primitive
, TSS_Deep_Finalize
) or else
1435 Is_TSS
(Current_Primitive
, TSS_Stream_Input
) or else
1436 Is_TSS
(Current_Primitive
, TSS_Stream_Output
) or else
1437 Is_TSS
(Current_Primitive
, TSS_Stream_Read
) or else
1438 Is_TSS
(Current_Primitive
, TSS_Stream_Write
)
1440 Is_Predefined_Interface_Primitive
(Current_Primitive
))
1441 and then not Is_Hidden
(Current_Primitive
)
1443 -- The first thing to do is build an up-to-date copy of the
1444 -- spec with all the formals referencing Controlling_Type
1445 -- transformed into formals referencing Stub_Type. Since this
1446 -- primitive may have been inherited, go back the alias chain
1447 -- until the real primitive has been found.
1449 Current_Primitive_Alias
:= Ultimate_Alias
(Current_Primitive
);
1451 -- Copy the spec from the original declaration for the purpose
1452 -- of declaring an overriding subprogram: we need to replace
1453 -- the type of each controlling formal with Stub_Type. The
1454 -- primitive may have been declared for Controlling_Type or
1455 -- inherited from some ancestor type for which we do not have
1456 -- an easily determined Entity_Id. We have no systematic way
1457 -- of knowing which type to substitute Stub_Type for. Instead,
1458 -- Copy_Specification relies on the flag Is_Controlling_Formal
1459 -- to determine which formals to change.
1461 Current_Primitive_Spec
:=
1462 Copy_Specification
(Loc
,
1463 Spec
=> Parent
(Current_Primitive_Alias
),
1464 Ctrl_Type
=> Stub_Elements
.Stub_Type
);
1466 Current_Primitive_Decl
:=
1467 Make_Subprogram_Declaration
(Loc
,
1468 Specification
=> Current_Primitive_Spec
);
1470 Insert_After_And_Analyze
(Current_Insertion_Node
,
1471 Current_Primitive_Decl
);
1472 Current_Insertion_Node
:= Current_Primitive_Decl
;
1474 Possibly_Asynchronous
:=
1475 Nkind
(Current_Primitive_Spec
) = N_Procedure_Specification
1476 and then Could_Be_Asynchronous
(Current_Primitive_Spec
);
1478 Assign_Subprogram_Identifier
(
1479 Defining_Unit_Name
(Current_Primitive_Spec
),
1480 Current_Primitive_Number
,
1483 if Build_Bodies
then
1484 Current_Primitive_Body
:=
1485 Build_Subprogram_Calling_Stubs
1486 (Vis_Decl
=> Current_Primitive_Decl
,
1488 Build_Subprogram_Id
(Loc
,
1489 Defining_Unit_Name
(Current_Primitive_Spec
)),
1490 Asynchronous
=> Possibly_Asynchronous
,
1491 Dynamically_Asynchronous
=> Possibly_Asynchronous
,
1492 Stub_Type
=> Stub_Elements
.Stub_Type
,
1493 RACW_Type
=> Stub_Elements
.RACW_Type
);
1494 Append_To
(Body_Decls
, Current_Primitive_Body
);
1496 -- Analyzing the body here would cause the Stub type to
1497 -- be frozen, thus preventing subsequent primitive
1498 -- declarations. For this reason, it will be analyzed
1499 -- later in the regular flow (and in the context of the
1500 -- appropriate unit body, see Append_RACW_Bodies).
1504 -- Build the receiver stubs
1506 if Build_Bodies
and then not Is_RAS
then
1507 Current_Receiver_Body
:=
1508 Specific_Build_Subprogram_Receiving_Stubs
1509 (Vis_Decl
=> Current_Primitive_Decl
,
1510 Asynchronous
=> Possibly_Asynchronous
,
1511 Dynamically_Asynchronous
=> Possibly_Asynchronous
,
1512 Stub_Type
=> Stub_Elements
.Stub_Type
,
1513 RACW_Type
=> Stub_Elements
.RACW_Type
,
1514 Parent_Primitive
=> Current_Primitive
);
1517 Defining_Unit_Name
(Specification
(Current_Receiver_Body
));
1519 Append_To
(Body_Decls
, Current_Receiver_Body
);
1521 -- Add a case alternative to the receiver
1523 if Get_PCS_Name
= Name_PolyORB_DSA
then
1524 Append_To
(RPC_Receiver_Elsif_Parts
,
1525 Make_Elsif_Part
(Loc
,
1527 Make_Function_Call
(Loc
,
1530 RTE
(RE_Caseless_String_Eq
), Loc
),
1531 Parameter_Associations
=> New_List
(
1532 New_Occurrence_Of
(RPC_Receiver_Subp_Id
, Loc
),
1533 Make_String_Literal
(Loc
, Subp_Str
))),
1535 Then_Statements
=> New_List
(
1536 Make_Assignment_Statement
(Loc
,
1537 Name
=> New_Occurrence_Of
(
1538 RPC_Receiver_Subp_Index
, Loc
),
1540 Make_Integer_Literal
(Loc
,
1541 Intval
=> Current_Primitive_Number
)))));
1544 Append_To
(RPC_Receiver_Case_Alternatives
,
1545 Make_Case_Statement_Alternative
(Loc
,
1546 Discrete_Choices
=> New_List
(
1547 Make_Integer_Literal
(Loc
, Current_Primitive_Number
)),
1549 Statements
=> New_List
(
1550 Make_Procedure_Call_Statement
(Loc
,
1552 New_Occurrence_Of
(Current_Receiver
, Loc
),
1553 Parameter_Associations
=> New_List
(
1554 New_Occurrence_Of
(RPC_Receiver_Request
, Loc
))))));
1557 -- Increment the index of current primitive
1559 Current_Primitive_Number
:= Current_Primitive_Number
+ 1;
1562 Next_Elmt
(Current_Primitive_Elmt
);
1566 -- Build the case statement and the heart of the subprogram
1568 if Build_Bodies
and then not Is_RAS
then
1569 if Get_PCS_Name
= Name_PolyORB_DSA
1570 and then Present
(First
(RPC_Receiver_Elsif_Parts
))
1572 Append_To
(RPC_Receiver_Statements
,
1573 Make_Implicit_If_Statement
(Designated_Type
,
1574 Condition
=> New_Occurrence_Of
(Standard_False
, Loc
),
1575 Then_Statements
=> New_List
,
1576 Elsif_Parts
=> RPC_Receiver_Elsif_Parts
));
1579 Append_To
(RPC_Receiver_Case_Alternatives
,
1580 Make_Case_Statement_Alternative
(Loc
,
1581 Discrete_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
1582 Statements
=> New_List
(Make_Null_Statement
(Loc
))));
1584 Append_To
(RPC_Receiver_Statements
,
1585 Make_Case_Statement
(Loc
,
1587 New_Occurrence_Of
(RPC_Receiver_Subp_Index
, Loc
),
1588 Alternatives
=> RPC_Receiver_Case_Alternatives
));
1590 Append_To
(Body_Decls
, RPC_Receiver_Decl
);
1591 Specific_Add_Obj_RPC_Receiver_Completion
(Loc
,
1592 Body_Decls
, RPC_Receiver
, Stub_Elements
);
1594 -- Do not analyze RPC receiver body at this stage since it references
1595 -- subprograms that have not been analyzed yet. It will be analyzed in
1596 -- the regular flow (see Append_RACW_Bodies).
1599 end Add_RACW_Primitive_Declarations_And_Bodies
;
1601 -----------------------------
1602 -- Add_RAS_Dereference_TSS --
1603 -----------------------------
1605 procedure Add_RAS_Dereference_TSS
(N
: Node_Id
) is
1606 Loc
: constant Source_Ptr
:= Sloc
(N
);
1608 Type_Def
: constant Node_Id
:= Type_Definition
(N
);
1609 RAS_Type
: constant Entity_Id
:= Defining_Identifier
(N
);
1610 Fat_Type
: constant Entity_Id
:= Equivalent_Type
(RAS_Type
);
1611 RACW_Type
: constant Entity_Id
:= Underlying_RACW_Type
(RAS_Type
);
1613 RACW_Primitive_Name
: Node_Id
;
1615 Proc
: constant Entity_Id
:=
1616 Make_Defining_Identifier
(Loc
,
1617 Chars
=> Make_TSS_Name
(RAS_Type
, TSS_RAS_Dereference
));
1619 Proc_Spec
: Node_Id
;
1620 Param_Specs
: List_Id
;
1621 Param_Assoc
: constant List_Id
:= New_List
;
1622 Stmts
: constant List_Id
:= New_List
;
1624 RAS_Parameter
: constant Entity_Id
:= Make_Temporary
(Loc
, 'P');
1626 Is_Function
: constant Boolean :=
1627 Nkind
(Type_Def
) = N_Access_Function_Definition
;
1629 Is_Degenerate
: Boolean;
1630 -- Set to True if the subprogram_specification for this RAS has an
1631 -- anonymous access parameter (see Process_Remote_AST_Declaration).
1633 Spec
: constant Node_Id
:= Type_Def
;
1635 Current_Parameter
: Node_Id
;
1637 -- Start of processing for Add_RAS_Dereference_TSS
1640 -- The Dereference TSS for a remote access-to-subprogram type has the
1643 -- [function|procedure] ras_typeRD (RAS_Value, <RAS_Parameters>)
1646 -- This is called whenever a value of a RAS type is dereferenced
1648 -- First construct a list of parameter specifications:
1650 -- The first formal is the RAS values
1652 Param_Specs
:= New_List
(
1653 Make_Parameter_Specification
(Loc
,
1654 Defining_Identifier
=> RAS_Parameter
,
1657 New_Occurrence_Of
(Fat_Type
, Loc
)));
1659 -- The following formals are copied from the type declaration
1661 Is_Degenerate
:= False;
1662 Current_Parameter
:= First
(Parameter_Specifications
(Type_Def
));
1663 Parameters
: while Present
(Current_Parameter
) loop
1664 if Nkind
(Parameter_Type
(Current_Parameter
)) =
1667 Is_Degenerate
:= True;
1670 Append_To
(Param_Specs
,
1671 Make_Parameter_Specification
(Loc
,
1672 Defining_Identifier
=>
1673 Make_Defining_Identifier
(Loc
,
1674 Chars
=> Chars
(Defining_Identifier
(Current_Parameter
))),
1675 In_Present
=> In_Present
(Current_Parameter
),
1676 Out_Present
=> Out_Present
(Current_Parameter
),
1678 New_Copy_Tree
(Parameter_Type
(Current_Parameter
)),
1680 New_Copy_Tree
(Expression
(Current_Parameter
))));
1682 Append_To
(Param_Assoc
,
1683 Make_Identifier
(Loc
,
1684 Chars
=> Chars
(Defining_Identifier
(Current_Parameter
))));
1686 Next
(Current_Parameter
);
1687 end loop Parameters
;
1689 if Is_Degenerate
then
1690 Prepend_To
(Param_Assoc
, New_Occurrence_Of
(RAS_Parameter
, Loc
));
1692 -- Generate a dummy body. This code will never actually be executed,
1693 -- because null is the only legal value for a degenerate RAS type.
1694 -- For legality's sake (in order to avoid generating a function that
1695 -- does not contain a return statement), we include a dummy recursive
1696 -- call on the TSS itself.
1699 Make_Raise_Program_Error
(Loc
, Reason
=> PE_Explicit_Raise
));
1700 RACW_Primitive_Name
:= New_Occurrence_Of
(Proc
, Loc
);
1703 -- For a normal RAS type, we cast the RAS formal to the corresponding
1704 -- tagged type, and perform a dispatching call to its Call primitive
1707 Prepend_To
(Param_Assoc
,
1708 Unchecked_Convert_To
(RACW_Type
,
1709 New_Occurrence_Of
(RAS_Parameter
, Loc
)));
1711 RACW_Primitive_Name
:=
1712 Make_Selected_Component
(Loc
,
1713 Prefix
=> Scope
(RACW_Type
),
1714 Selector_Name
=> Name_uCall
);
1719 Make_Simple_Return_Statement
(Loc
,
1721 Make_Function_Call
(Loc
,
1722 Name
=> RACW_Primitive_Name
,
1723 Parameter_Associations
=> Param_Assoc
)));
1727 Make_Procedure_Call_Statement
(Loc
,
1728 Name
=> RACW_Primitive_Name
,
1729 Parameter_Associations
=> Param_Assoc
));
1732 -- Build the complete subprogram
1736 Make_Function_Specification
(Loc
,
1737 Defining_Unit_Name
=> Proc
,
1738 Parameter_Specifications
=> Param_Specs
,
1739 Result_Definition
=>
1741 Entity
(Result_Definition
(Spec
)), Loc
));
1743 Set_Ekind
(Proc
, E_Function
);
1745 New_Occurrence_Of
(Entity
(Result_Definition
(Spec
)), Loc
));
1749 Make_Procedure_Specification
(Loc
,
1750 Defining_Unit_Name
=> Proc
,
1751 Parameter_Specifications
=> Param_Specs
);
1753 Set_Ekind
(Proc
, E_Procedure
);
1754 Set_Etype
(Proc
, Standard_Void_Type
);
1758 Make_Subprogram_Body
(Loc
,
1759 Specification
=> Proc_Spec
,
1760 Declarations
=> New_List
,
1761 Handled_Statement_Sequence
=>
1762 Make_Handled_Sequence_Of_Statements
(Loc
,
1763 Statements
=> Stmts
)));
1765 Set_TSS
(Fat_Type
, Proc
);
1766 end Add_RAS_Dereference_TSS
;
1768 -------------------------------
1769 -- Add_RAS_Proxy_And_Analyze --
1770 -------------------------------
1772 procedure Add_RAS_Proxy_And_Analyze
1775 All_Calls_Remote_E
: Entity_Id
;
1776 Proxy_Object_Addr
: out Entity_Id
)
1778 Loc
: constant Source_Ptr
:= Sloc
(Vis_Decl
);
1780 Subp_Name
: constant Entity_Id
:=
1781 Defining_Unit_Name
(Specification
(Vis_Decl
));
1783 Pkg_Name
: constant Entity_Id
:=
1784 Make_Defining_Identifier
(Loc
,
1785 Chars
=> New_External_Name
(Chars
(Subp_Name
), 'P', -1));
1787 Proxy_Type
: constant Entity_Id
:=
1788 Make_Defining_Identifier
(Loc
,
1791 (Related_Id
=> Chars
(Subp_Name
),
1794 Proxy_Type_Full_View
: constant Entity_Id
:=
1795 Make_Defining_Identifier
(Loc
,
1796 Chars
(Proxy_Type
));
1798 Subp_Decl_Spec
: constant Node_Id
:=
1799 Build_RAS_Primitive_Specification
1800 (Subp_Spec
=> Specification
(Vis_Decl
),
1801 Remote_Object_Type
=> Proxy_Type
);
1803 Subp_Body_Spec
: constant Node_Id
:=
1804 Build_RAS_Primitive_Specification
1805 (Subp_Spec
=> Specification
(Vis_Decl
),
1806 Remote_Object_Type
=> Proxy_Type
);
1808 Vis_Decls
: constant List_Id
:= New_List
;
1809 Pvt_Decls
: constant List_Id
:= New_List
;
1810 Actuals
: constant List_Id
:= New_List
;
1812 Perform_Call
: Node_Id
;
1815 -- type subpP is tagged limited private;
1817 Append_To
(Vis_Decls
,
1818 Make_Private_Type_Declaration
(Loc
,
1819 Defining_Identifier
=> Proxy_Type
,
1820 Tagged_Present
=> True,
1821 Limited_Present
=> True));
1823 -- [subprogram] Call
1824 -- (Self : access subpP;
1825 -- ...other-formals...)
1828 Append_To
(Vis_Decls
,
1829 Make_Subprogram_Declaration
(Loc
,
1830 Specification
=> Subp_Decl_Spec
));
1832 -- A : constant System.Address;
1834 Proxy_Object_Addr
:= Make_Defining_Identifier
(Loc
, Name_uA
);
1836 Append_To
(Vis_Decls
,
1837 Make_Object_Declaration
(Loc
,
1838 Defining_Identifier
=> Proxy_Object_Addr
,
1839 Constant_Present
=> True,
1840 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Address
), Loc
)));
1844 -- type subpP is tagged limited record
1845 -- All_Calls_Remote : Boolean := [All_Calls_Remote?];
1849 Append_To
(Pvt_Decls
,
1850 Make_Full_Type_Declaration
(Loc
,
1851 Defining_Identifier
=> Proxy_Type_Full_View
,
1853 Build_Remote_Subprogram_Proxy_Type
(Loc
,
1854 New_Occurrence_Of
(All_Calls_Remote_E
, Loc
))));
1856 -- Trick semantic analysis into swapping the public and full view when
1857 -- freezing the public view.
1859 Set_Comes_From_Source
(Proxy_Type_Full_View
, True);
1862 -- (Self : access O;
1863 -- ...other-formals...) is
1865 -- P (...other-formals...);
1869 -- (Self : access O;
1870 -- ...other-formals...)
1873 -- return F (...other-formals...);
1876 if Nkind
(Subp_Decl_Spec
) = N_Procedure_Specification
then
1878 Make_Procedure_Call_Statement
(Loc
,
1879 Name
=> New_Occurrence_Of
(Subp_Name
, Loc
),
1880 Parameter_Associations
=> Actuals
);
1883 Make_Simple_Return_Statement
(Loc
,
1885 Make_Function_Call
(Loc
,
1886 Name
=> New_Occurrence_Of
(Subp_Name
, Loc
),
1887 Parameter_Associations
=> Actuals
));
1890 Formal
:= First
(Parameter_Specifications
(Subp_Decl_Spec
));
1891 pragma Assert
(Present
(Formal
));
1894 exit when No
(Formal
);
1896 New_Occurrence_Of
(Defining_Identifier
(Formal
), Loc
));
1899 -- O : aliased subpP;
1901 Append_To
(Pvt_Decls
,
1902 Make_Object_Declaration
(Loc
,
1903 Defining_Identifier
=> Make_Defining_Identifier
(Loc
, Name_uO
),
1904 Aliased_Present
=> True,
1905 Object_Definition
=> New_Occurrence_Of
(Proxy_Type
, Loc
)));
1907 -- A : constant System.Address := O'Address;
1909 Append_To
(Pvt_Decls
,
1910 Make_Object_Declaration
(Loc
,
1911 Defining_Identifier
=>
1912 Make_Defining_Identifier
(Loc
, Chars
(Proxy_Object_Addr
)),
1913 Constant_Present
=> True,
1914 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Address
), Loc
),
1916 Make_Attribute_Reference
(Loc
,
1917 Prefix
=> New_Occurrence_Of
(
1918 Defining_Identifier
(Last
(Pvt_Decls
)), Loc
),
1919 Attribute_Name
=> Name_Address
)));
1922 Make_Package_Declaration
(Loc
,
1923 Specification
=> Make_Package_Specification
(Loc
,
1924 Defining_Unit_Name
=> Pkg_Name
,
1925 Visible_Declarations
=> Vis_Decls
,
1926 Private_Declarations
=> Pvt_Decls
,
1927 End_Label
=> Empty
)));
1928 Analyze
(Last
(Decls
));
1931 Make_Package_Body
(Loc
,
1932 Defining_Unit_Name
=>
1933 Make_Defining_Identifier
(Loc
, Chars
(Pkg_Name
)),
1934 Declarations
=> New_List
(
1935 Make_Subprogram_Body
(Loc
,
1936 Specification
=> Subp_Body_Spec
,
1937 Declarations
=> New_List
,
1938 Handled_Statement_Sequence
=>
1939 Make_Handled_Sequence_Of_Statements
(Loc
,
1940 Statements
=> New_List
(Perform_Call
))))));
1941 Analyze
(Last
(Decls
));
1942 end Add_RAS_Proxy_And_Analyze
;
1944 -----------------------
1945 -- Add_RAST_Features --
1946 -----------------------
1948 procedure Add_RAST_Features
(Vis_Decl
: Node_Id
) is
1949 RAS_Type
: constant Entity_Id
:=
1950 Equivalent_Type
(Defining_Identifier
(Vis_Decl
));
1952 pragma Assert
(No
(TSS
(RAS_Type
, TSS_RAS_Access
)));
1953 Add_RAS_Dereference_TSS
(Vis_Decl
);
1954 Specific_Add_RAST_Features
(Vis_Decl
, RAS_Type
);
1955 end Add_RAST_Features
;
1961 procedure Add_Stub_Type
1962 (Designated_Type
: Entity_Id
;
1963 RACW_Type
: Entity_Id
;
1965 Stub_Type
: out Entity_Id
;
1966 Stub_Type_Access
: out Entity_Id
;
1967 RPC_Receiver_Decl
: out Node_Id
;
1968 Body_Decls
: out List_Id
;
1969 Existing
: out Boolean)
1971 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
1973 Stub_Elements
: constant Stub_Structure
:=
1974 Stubs_Table
.Get
(Designated_Type
);
1975 Stub_Type_Decl
: Node_Id
;
1976 Stub_Type_Access_Decl
: Node_Id
;
1979 if Stub_Elements
/= Empty_Stub_Structure
then
1980 Stub_Type
:= Stub_Elements
.Stub_Type
;
1981 Stub_Type_Access
:= Stub_Elements
.Stub_Type_Access
;
1982 RPC_Receiver_Decl
:= Stub_Elements
.RPC_Receiver_Decl
;
1983 Body_Decls
:= Stub_Elements
.Body_Decls
;
1989 Stub_Type
:= Make_Temporary
(Loc
, 'S');
1990 Set_Ekind
(Stub_Type
, E_Record_Type
);
1991 Set_Is_RACW_Stub_Type
(Stub_Type
);
1993 Make_Defining_Identifier
(Loc
,
1994 Chars
=> New_External_Name
1995 (Related_Id
=> Chars
(Stub_Type
), Suffix
=> 'A'));
1997 RPC_Receiver_Decl
:= Specific_RPC_Receiver_Decl
(RACW_Type
);
1999 -- Create new stub type, copying components from generic RACW_Stub_Type
2002 Make_Full_Type_Declaration
(Loc
,
2003 Defining_Identifier
=> Stub_Type
,
2005 Make_Record_Definition
(Loc
,
2006 Tagged_Present
=> True,
2007 Limited_Present
=> True,
2009 Make_Component_List
(Loc
,
2011 Copy_Component_List
(RTE
(RE_RACW_Stub_Type
), Loc
))));
2013 -- Does the stub type need to explicitly implement interfaces from the
2014 -- designated type???
2016 -- In particular are there issues in the case where the designated type
2017 -- is a synchronized interface???
2019 Stub_Type_Access_Decl
:=
2020 Make_Full_Type_Declaration
(Loc
,
2021 Defining_Identifier
=> Stub_Type_Access
,
2023 Make_Access_To_Object_Definition
(Loc
,
2024 All_Present
=> True,
2025 Subtype_Indication
=> New_Occurrence_Of
(Stub_Type
, Loc
)));
2027 Append_To
(Decls
, Stub_Type_Decl
);
2028 Analyze
(Last
(Decls
));
2029 Append_To
(Decls
, Stub_Type_Access_Decl
);
2030 Analyze
(Last
(Decls
));
2032 -- We can't directly derive the stub type from the designated type,
2033 -- because we don't want any components or discriminants from the real
2034 -- type, so instead we manually fake a derivation to get an appropriate
2037 Derive_Subprograms
(Parent_Type
=> Designated_Type
,
2038 Derived_Type
=> Stub_Type
);
2040 if Present
(RPC_Receiver_Decl
) then
2041 Append_To
(Decls
, RPC_Receiver_Decl
);
2044 -- Case of RACW implementing a RAS with the GARLIC PCS: there is
2045 -- no RPC receiver in that case, this is just an indication of
2046 -- where to insert code in the tree (see comment in declaration of
2047 -- type Stub_Structure).
2049 RPC_Receiver_Decl
:= Last
(Decls
);
2052 Body_Decls
:= New_List
;
2054 Stubs_Table
.Set
(Designated_Type
,
2055 (Stub_Type
=> Stub_Type
,
2056 Stub_Type_Access
=> Stub_Type_Access
,
2057 RPC_Receiver_Decl
=> RPC_Receiver_Decl
,
2058 Body_Decls
=> Body_Decls
,
2059 RACW_Type
=> RACW_Type
));
2062 ------------------------
2063 -- Append_RACW_Bodies --
2064 ------------------------
2066 procedure Append_RACW_Bodies
(Decls
: List_Id
; Spec_Id
: Entity_Id
) is
2070 E
:= First_Entity
(Spec_Id
);
2071 while Present
(E
) loop
2072 if Is_Remote_Access_To_Class_Wide_Type
(E
) then
2073 Append_List_To
(Decls
, Get_And_Reset_RACW_Bodies
(E
));
2078 end Append_RACW_Bodies
;
2080 ----------------------------------
2081 -- Assign_Subprogram_Identifier --
2082 ----------------------------------
2084 procedure Assign_Subprogram_Identifier
2089 N
: constant Name_Id
:= Chars
(Def
);
2091 Overload_Order
: constant Int
:= Overload_Counter_Table
.Get
(N
) + 1;
2094 Overload_Counter_Table
.Set
(N
, Overload_Order
);
2096 Get_Name_String
(N
);
2098 -- Homonym handling: as in Exp_Dbug, but much simpler, because the only
2099 -- entities for which we have to generate names here need only to be
2100 -- disambiguated within their own scope.
2102 if Overload_Order
> 1 then
2103 Name_Buffer
(Name_Len
+ 1 .. Name_Len
+ 2) := "__";
2104 Name_Len
:= Name_Len
+ 2;
2105 Add_Nat_To_Name_Buffer
(Overload_Order
);
2108 Id
:= String_From_Name_Buffer
;
2109 Subprogram_Identifier_Table
.Set
2111 Subprogram_Identifiers
'(Str_Identifier => Id, Int_Identifier => Spn));
2112 end Assign_Subprogram_Identifier;
2114 -------------------------------------
2115 -- Build_Actual_Object_Declaration --
2116 -------------------------------------
2118 procedure Build_Actual_Object_Declaration
2119 (Object : Entity_Id;
2125 Loc : constant Source_Ptr := Sloc (Object);
2128 -- Declare a temporary object for the actual, possibly initialized with
2129 -- a 'Input
/From_Any call
.
2131 -- Complication arises in the case of limited types, for which such a
2132 -- declaration is illegal in Ada 95. In that case, we first generate a
2133 -- renaming declaration of the 'Input call, and then if needed we
2134 -- generate an overlaid non-constant view.
2136 if Ada_Version
<= Ada_95
2137 and then Is_Limited_Type
(Etyp
)
2138 and then Present
(Expr
)
2141 -- Object : Etyp renames <func-call>
2144 Make_Object_Renaming_Declaration
(Loc
,
2145 Defining_Identifier
=> Object
,
2146 Subtype_Mark
=> New_Occurrence_Of
(Etyp
, Loc
),
2151 -- The name defined by the renaming declaration denotes a
2152 -- constant view; create a non-constant object at the same address
2153 -- to be used as the actual.
2156 Constant_Object
: constant Entity_Id
:=
2157 Make_Temporary
(Loc
, 'P');
2160 Set_Defining_Identifier
2161 (Last
(Decls
), Constant_Object
);
2163 -- We have an unconstrained Etyp: build the actual constrained
2164 -- subtype for the value we just read from the stream.
2166 -- subtype S is <actual subtype of Constant_Object>;
2169 Build_Actual_Subtype
(Etyp
,
2170 New_Occurrence_Of
(Constant_Object
, Loc
)));
2175 Make_Object_Declaration
(Loc
,
2176 Defining_Identifier
=> Object
,
2177 Object_Definition
=>
2179 (Defining_Identifier
(Last
(Decls
)), Loc
)));
2180 Set_Ekind
(Object
, E_Variable
);
2182 -- Suppress default initialization:
2183 -- pragma Import (Ada, Object);
2187 Chars
=> Name_Import
,
2188 Pragma_Argument_Associations
=> New_List
(
2189 Make_Pragma_Argument_Association
(Loc
,
2190 Chars
=> Name_Convention
,
2191 Expression
=> Make_Identifier
(Loc
, Name_Ada
)),
2192 Make_Pragma_Argument_Association
(Loc
,
2193 Chars
=> Name_Entity
,
2194 Expression
=> New_Occurrence_Of
(Object
, Loc
)))));
2196 -- for Object'Address use Constant_Object'Address;
2199 Make_Attribute_Definition_Clause
(Loc
,
2200 Name
=> New_Occurrence_Of
(Object
, Loc
),
2201 Chars
=> Name_Address
,
2203 Make_Attribute_Reference
(Loc
,
2204 Prefix
=> New_Occurrence_Of
(Constant_Object
, Loc
),
2205 Attribute_Name
=> Name_Address
)));
2210 -- General case of a regular object declaration. Object is flagged
2211 -- constant unless it has mode out or in out, to allow the backend
2212 -- to optimize where possible.
2214 -- Object : [constant] Etyp [:= <expr>];
2217 Make_Object_Declaration
(Loc
,
2218 Defining_Identifier
=> Object
,
2219 Constant_Present
=> Present
(Expr
) and then not Variable
,
2220 Object_Definition
=> New_Occurrence_Of
(Etyp
, Loc
),
2221 Expression
=> Expr
));
2223 if Constant_Present
(Last
(Decls
)) then
2224 Set_Ekind
(Object
, E_Constant
);
2226 Set_Ekind
(Object
, E_Variable
);
2229 end Build_Actual_Object_Declaration
;
2231 ------------------------------
2232 -- Build_Get_Unique_RP_Call --
2233 ------------------------------
2235 function Build_Get_Unique_RP_Call
2237 Pointer
: Entity_Id
;
2238 Stub_Type
: Entity_Id
) return List_Id
2242 Make_Procedure_Call_Statement
(Loc
,
2244 New_Occurrence_Of
(RTE
(RE_Get_Unique_Remote_Pointer
), Loc
),
2245 Parameter_Associations
=> New_List
(
2246 Unchecked_Convert_To
(RTE
(RE_RACW_Stub_Type_Access
),
2247 New_Occurrence_Of
(Pointer
, Loc
)))),
2249 Make_Assignment_Statement
(Loc
,
2251 Make_Selected_Component
(Loc
,
2252 Prefix
=> New_Occurrence_Of
(Pointer
, Loc
),
2254 New_Occurrence_Of
(First_Tag_Component
2255 (Designated_Type
(Etype
(Pointer
))), Loc
)),
2257 Make_Attribute_Reference
(Loc
,
2258 Prefix
=> New_Occurrence_Of
(Stub_Type
, Loc
),
2259 Attribute_Name
=> Name_Tag
)));
2261 -- Note: The assignment to Pointer._Tag is safe here because
2262 -- we carefully ensured that Stub_Type has exactly the same layout
2263 -- as System.Partition_Interface.RACW_Stub_Type.
2265 end Build_Get_Unique_RP_Call
;
2267 -----------------------------------
2268 -- Build_Ordered_Parameters_List --
2269 -----------------------------------
2271 function Build_Ordered_Parameters_List
(Spec
: Node_Id
) return List_Id
is
2272 Constrained_List
: List_Id
;
2273 Unconstrained_List
: List_Id
;
2274 Current_Parameter
: Node_Id
;
2277 First_Parameter
: Node_Id
;
2278 For_RAS
: Boolean := False;
2281 if No
(Parameter_Specifications
(Spec
)) then
2285 Constrained_List
:= New_List
;
2286 Unconstrained_List
:= New_List
;
2287 First_Parameter
:= First
(Parameter_Specifications
(Spec
));
2289 if Nkind
(Parameter_Type
(First_Parameter
)) = N_Access_Definition
2290 and then Chars
(Defining_Identifier
(First_Parameter
)) = Name_uS
2295 -- Loop through the parameters and add them to the right list. Note that
2296 -- we treat a parameter of a null-excluding access type as unconstrained
2297 -- because we can't declare an object of such a type with default
2300 Current_Parameter
:= First_Parameter
;
2301 while Present
(Current_Parameter
) loop
2302 Ptyp
:= Parameter_Type
(Current_Parameter
);
2304 if (Nkind
(Ptyp
) = N_Access_Definition
2305 or else not Transmit_As_Unconstrained
(Etype
(Ptyp
)))
2306 and then not (For_RAS
and then Current_Parameter
= First_Parameter
)
2308 Append_To
(Constrained_List
, New_Copy
(Current_Parameter
));
2310 Append_To
(Unconstrained_List
, New_Copy
(Current_Parameter
));
2313 Next
(Current_Parameter
);
2316 -- Unconstrained parameters are returned first
2318 Append_List_To
(Unconstrained_List
, Constrained_List
);
2320 return Unconstrained_List
;
2321 end Build_Ordered_Parameters_List
;
2323 ----------------------------------
2324 -- Build_Passive_Partition_Stub --
2325 ----------------------------------
2327 procedure Build_Passive_Partition_Stub
(U
: Node_Id
) is
2329 Pkg_Ent
: Entity_Id
;
2332 Loc
: constant Source_Ptr
:= Sloc
(U
);
2335 -- Verify that the implementation supports distribution, by accessing
2336 -- a type defined in the proper version of system.rpc
2339 Dist_OK
: Entity_Id
;
2340 pragma Warnings
(Off
, Dist_OK
);
2342 Dist_OK
:= RTE
(RE_Params_Stream_Type
);
2345 -- Use body if present, spec otherwise
2347 if Nkind
(U
) = N_Package_Declaration
then
2348 Pkg_Spec
:= Specification
(U
);
2349 L
:= Visible_Declarations
(Pkg_Spec
);
2351 Pkg_Spec
:= Parent
(Corresponding_Spec
(U
));
2352 L
:= Declarations
(U
);
2354 Pkg_Ent
:= Defining_Entity
(Pkg_Spec
);
2357 Make_Procedure_Call_Statement
(Loc
,
2359 New_Occurrence_Of
(RTE
(RE_Register_Passive_Package
), Loc
),
2360 Parameter_Associations
=> New_List
(
2361 Make_String_Literal
(Loc
,
2362 Fully_Qualified_Name_String
(Pkg_Ent
, Append_NUL
=> False)),
2363 Make_Attribute_Reference
(Loc
,
2364 Prefix
=> New_Occurrence_Of
(Pkg_Ent
, Loc
),
2365 Attribute_Name
=> Name_Version
)));
2368 end Build_Passive_Partition_Stub
;
2370 --------------------------------------
2371 -- Build_RPC_Receiver_Specification --
2372 --------------------------------------
2374 function Build_RPC_Receiver_Specification
2375 (RPC_Receiver
: Entity_Id
;
2376 Request_Parameter
: Entity_Id
) return Node_Id
2378 Loc
: constant Source_Ptr
:= Sloc
(RPC_Receiver
);
2381 Make_Procedure_Specification
(Loc
,
2382 Defining_Unit_Name
=> RPC_Receiver
,
2383 Parameter_Specifications
=> New_List
(
2384 Make_Parameter_Specification
(Loc
,
2385 Defining_Identifier
=> Request_Parameter
,
2387 New_Occurrence_Of
(RTE
(RE_Request_Access
), Loc
))));
2388 end Build_RPC_Receiver_Specification
;
2390 ----------------------------------------
2391 -- Build_Remote_Subprogram_Proxy_Type --
2392 ----------------------------------------
2394 function Build_Remote_Subprogram_Proxy_Type
2396 ACR_Expression
: Node_Id
) return Node_Id
2400 Make_Record_Definition
(Loc
,
2401 Tagged_Present
=> True,
2402 Limited_Present
=> True,
2404 Make_Component_List
(Loc
,
2405 Component_Items
=> New_List
(
2406 Make_Component_Declaration
(Loc
,
2407 Defining_Identifier
=>
2408 Make_Defining_Identifier
(Loc
,
2409 Name_All_Calls_Remote
),
2410 Component_Definition
=>
2411 Make_Component_Definition
(Loc
,
2412 Subtype_Indication
=>
2413 New_Occurrence_Of
(Standard_Boolean
, Loc
)),
2417 Make_Component_Declaration
(Loc
,
2418 Defining_Identifier
=>
2419 Make_Defining_Identifier
(Loc
,
2421 Component_Definition
=>
2422 Make_Component_Definition
(Loc
,
2423 Subtype_Indication
=>
2424 New_Occurrence_Of
(RTE
(RE_Address
), Loc
)),
2426 New_Occurrence_Of
(RTE
(RE_Null_Address
), Loc
)),
2428 Make_Component_Declaration
(Loc
,
2429 Defining_Identifier
=>
2430 Make_Defining_Identifier
(Loc
,
2432 Component_Definition
=>
2433 Make_Component_Definition
(Loc
,
2434 Subtype_Indication
=>
2435 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
))))));
2436 end Build_Remote_Subprogram_Proxy_Type
;
2438 --------------------
2439 -- Build_Stub_Tag --
2440 --------------------
2442 function Build_Stub_Tag
2444 RACW_Type
: Entity_Id
) return Node_Id
2446 Stub_Type
: constant Entity_Id
:= Corresponding_Stub_Type
(RACW_Type
);
2449 Make_Attribute_Reference
(Loc
,
2450 Prefix
=> New_Occurrence_Of
(Stub_Type
, Loc
),
2451 Attribute_Name
=> Name_Tag
);
2454 ------------------------------------
2455 -- Build_Subprogram_Calling_Stubs --
2456 ------------------------------------
2458 function Build_Subprogram_Calling_Stubs
2459 (Vis_Decl
: Node_Id
;
2461 Asynchronous
: Boolean;
2462 Dynamically_Asynchronous
: Boolean := False;
2463 Stub_Type
: Entity_Id
:= Empty
;
2464 RACW_Type
: Entity_Id
:= Empty
;
2465 Locator
: Entity_Id
:= Empty
;
2466 New_Name
: Name_Id
:= No_Name
) return Node_Id
2468 Loc
: constant Source_Ptr
:= Sloc
(Vis_Decl
);
2470 Decls
: constant List_Id
:= New_List
;
2471 Statements
: constant List_Id
:= New_List
;
2473 Subp_Spec
: Node_Id
;
2474 -- The specification of the body
2476 Controlling_Parameter
: Entity_Id
:= Empty
;
2478 Asynchronous_Expr
: Node_Id
:= Empty
;
2480 RCI_Locator
: Entity_Id
;
2482 Spec_To_Use
: Node_Id
;
2484 procedure Insert_Partition_Check
(Parameter
: Node_Id
);
2485 -- Check that the parameter has been elaborated on the same partition
2486 -- than the controlling parameter (E.4(19)).
2488 ----------------------------
2489 -- Insert_Partition_Check --
2490 ----------------------------
2492 procedure Insert_Partition_Check
(Parameter
: Node_Id
) is
2493 Parameter_Entity
: constant Entity_Id
:=
2494 Defining_Identifier
(Parameter
);
2496 -- The expression that will be built is of the form:
2498 -- if not Same_Partition (Parameter, Controlling_Parameter) then
2499 -- raise Constraint_Error;
2502 -- We do not check that Parameter is in Stub_Type since such a check
2503 -- has been inserted at the point of call already (a tag check since
2504 -- we have multiple controlling operands).
2507 Make_Raise_Constraint_Error
(Loc
,
2511 Make_Function_Call
(Loc
,
2513 New_Occurrence_Of
(RTE
(RE_Same_Partition
), Loc
),
2514 Parameter_Associations
=>
2516 Unchecked_Convert_To
(RTE
(RE_RACW_Stub_Type_Access
),
2517 New_Occurrence_Of
(Parameter_Entity
, Loc
)),
2518 Unchecked_Convert_To
(RTE
(RE_RACW_Stub_Type_Access
),
2519 New_Occurrence_Of
(Controlling_Parameter
, Loc
))))),
2520 Reason
=> CE_Partition_Check_Failed
));
2521 end Insert_Partition_Check
;
2523 -- Start of processing for Build_Subprogram_Calling_Stubs
2527 Copy_Specification
(Loc
,
2528 Spec
=> Specification
(Vis_Decl
),
2529 New_Name
=> New_Name
);
2531 if Locator
= Empty
then
2532 RCI_Locator
:= RCI_Cache
;
2533 Spec_To_Use
:= Specification
(Vis_Decl
);
2535 RCI_Locator
:= Locator
;
2536 Spec_To_Use
:= Subp_Spec
;
2539 -- Find a controlling argument if we have a stub type. Also check
2540 -- if this subprogram can be made asynchronous.
2542 if Present
(Stub_Type
)
2543 and then Present
(Parameter_Specifications
(Spec_To_Use
))
2546 Current_Parameter
: Node_Id
:=
2547 First
(Parameter_Specifications
2550 while Present
(Current_Parameter
) loop
2552 Is_RACW_Controlling_Formal
(Current_Parameter
, Stub_Type
)
2554 if Controlling_Parameter
= Empty
then
2555 Controlling_Parameter
:=
2556 Defining_Identifier
(Current_Parameter
);
2558 Insert_Partition_Check
(Current_Parameter
);
2562 Next
(Current_Parameter
);
2567 pragma Assert
(No
(Stub_Type
) or else Present
(Controlling_Parameter
));
2569 if Dynamically_Asynchronous
then
2570 Asynchronous_Expr
:= Make_Selected_Component
(Loc
,
2571 Prefix
=> Controlling_Parameter
,
2572 Selector_Name
=> Name_Asynchronous
);
2575 Specific_Build_General_Calling_Stubs
2577 Statements
=> Statements
,
2578 Target
=> Specific_Build_Stub_Target
(Loc
,
2579 Decls
, RCI_Locator
, Controlling_Parameter
),
2580 Subprogram_Id
=> Subp_Id
,
2581 Asynchronous
=> Asynchronous_Expr
,
2582 Is_Known_Asynchronous
=> Asynchronous
2583 and then not Dynamically_Asynchronous
,
2584 Is_Known_Non_Asynchronous
2586 and then not Dynamically_Asynchronous
,
2587 Is_Function
=> Nkind
(Spec_To_Use
) =
2588 N_Function_Specification
,
2589 Spec
=> Spec_To_Use
,
2590 Stub_Type
=> Stub_Type
,
2591 RACW_Type
=> RACW_Type
,
2594 RCI_Calling_Stubs_Table
.Set
2595 (Defining_Unit_Name
(Specification
(Vis_Decl
)),
2596 Defining_Unit_Name
(Spec_To_Use
));
2599 Make_Subprogram_Body
(Loc
,
2600 Specification
=> Subp_Spec
,
2601 Declarations
=> Decls
,
2602 Handled_Statement_Sequence
=>
2603 Make_Handled_Sequence_Of_Statements
(Loc
, Statements
));
2604 end Build_Subprogram_Calling_Stubs
;
2606 -------------------------
2607 -- Build_Subprogram_Id --
2608 -------------------------
2610 function Build_Subprogram_Id
2612 E
: Entity_Id
) return Node_Id
2615 if Get_Subprogram_Ids
(E
).Str_Identifier
= No_String
then
2617 Current_Declaration
: Node_Id
;
2618 Current_Subp
: Entity_Id
;
2619 Current_Subp_Str
: String_Id
;
2620 Current_Subp_Number
: Int
:= First_RCI_Subprogram_Id
;
2622 pragma Warnings
(Off
, Current_Subp_Str
);
2625 -- Build_Subprogram_Id is called outside of the context of
2626 -- generating calling or receiving stubs. Hence we are processing
2627 -- an 'Access attribute_reference for an RCI subprogram, for the
2628 -- purpose of obtaining a RAS value.
2631 (Is_Remote_Call_Interface
(Scope
(E
))
2633 (Nkind
(Parent
(E
)) = N_Procedure_Specification
2635 Nkind
(Parent
(E
)) = N_Function_Specification
));
2637 Current_Declaration
:=
2638 First
(Visible_Declarations
2639 (Package_Specification_Of_Scope
(Scope
(E
))));
2640 while Present
(Current_Declaration
) loop
2641 if Nkind
(Current_Declaration
) = N_Subprogram_Declaration
2642 and then Comes_From_Source
(Current_Declaration
)
2644 Current_Subp
:= Defining_Unit_Name
(Specification
(
2645 Current_Declaration
));
2647 Assign_Subprogram_Identifier
2648 (Current_Subp
, Current_Subp_Number
, Current_Subp_Str
);
2650 Current_Subp_Number
:= Current_Subp_Number
+ 1;
2653 Next
(Current_Declaration
);
2658 case Get_PCS_Name
is
2659 when Name_PolyORB_DSA
=>
2660 return Make_String_Literal
(Loc
, Get_Subprogram_Id
(E
));
2663 return Make_Integer_Literal
(Loc
, Get_Subprogram_Id
(E
));
2665 end Build_Subprogram_Id
;
2667 ------------------------
2668 -- Copy_Specification --
2669 ------------------------
2671 function Copy_Specification
2674 Ctrl_Type
: Entity_Id
:= Empty
;
2675 New_Name
: Name_Id
:= No_Name
) return Node_Id
2677 Parameters
: List_Id
:= No_List
;
2679 Current_Parameter
: Node_Id
;
2680 Current_Identifier
: Entity_Id
;
2681 Current_Type
: Node_Id
;
2683 Name_For_New_Spec
: Name_Id
;
2685 New_Identifier
: Entity_Id
;
2687 -- Comments needed in body below ???
2690 if New_Name
= No_Name
then
2691 pragma Assert
(Nkind
(Spec
) = N_Function_Specification
2692 or else Nkind
(Spec
) = N_Procedure_Specification
);
2694 Name_For_New_Spec
:= Chars
(Defining_Unit_Name
(Spec
));
2696 Name_For_New_Spec
:= New_Name
;
2699 if Present
(Parameter_Specifications
(Spec
)) then
2700 Parameters
:= New_List
;
2701 Current_Parameter
:= First
(Parameter_Specifications
(Spec
));
2702 while Present
(Current_Parameter
) loop
2703 Current_Identifier
:= Defining_Identifier
(Current_Parameter
);
2704 Current_Type
:= Parameter_Type
(Current_Parameter
);
2706 if Nkind
(Current_Type
) = N_Access_Definition
then
2707 if Present
(Ctrl_Type
) then
2708 pragma Assert
(Is_Controlling_Formal
(Current_Identifier
));
2710 Make_Access_Definition
(Loc
,
2711 Subtype_Mark
=> New_Occurrence_Of
(Ctrl_Type
, Loc
),
2712 Null_Exclusion_Present
=>
2713 Null_Exclusion_Present
(Current_Type
));
2717 Make_Access_Definition
(Loc
,
2719 New_Copy_Tree
(Subtype_Mark
(Current_Type
)),
2720 Null_Exclusion_Present
=>
2721 Null_Exclusion_Present
(Current_Type
));
2725 if Present
(Ctrl_Type
)
2726 and then Is_Controlling_Formal
(Current_Identifier
)
2728 Current_Type
:= New_Occurrence_Of
(Ctrl_Type
, Loc
);
2730 Current_Type
:= New_Copy_Tree
(Current_Type
);
2734 New_Identifier
:= Make_Defining_Identifier
(Loc
,
2735 Chars
(Current_Identifier
));
2737 Append_To
(Parameters
,
2738 Make_Parameter_Specification
(Loc
,
2739 Defining_Identifier
=> New_Identifier
,
2740 Parameter_Type
=> Current_Type
,
2741 In_Present
=> In_Present
(Current_Parameter
),
2742 Out_Present
=> Out_Present
(Current_Parameter
),
2744 New_Copy_Tree
(Expression
(Current_Parameter
))));
2746 -- For a regular formal parameter (that needs to be marshalled
2747 -- in the context of remote calls), set the Etype now, because
2748 -- marshalling processing might need it.
2750 if Is_Entity_Name
(Current_Type
) then
2751 Set_Etype
(New_Identifier
, Entity
(Current_Type
));
2753 -- Current_Type is an access definition, special processing
2754 -- (not requiring etype) will occur for marshalling.
2760 Next
(Current_Parameter
);
2764 case Nkind
(Spec
) is
2765 when N_Access_Function_Definition
2766 | N_Function_Specification
2769 Make_Function_Specification
(Loc
,
2770 Defining_Unit_Name
=>
2771 Make_Defining_Identifier
(Loc
,
2772 Chars
=> Name_For_New_Spec
),
2773 Parameter_Specifications
=> Parameters
,
2774 Result_Definition
=>
2775 New_Occurrence_Of
(Entity
(Result_Definition
(Spec
)), Loc
));
2777 when N_Access_Procedure_Definition
2778 | N_Procedure_Specification
2781 Make_Procedure_Specification
(Loc
,
2782 Defining_Unit_Name
=>
2783 Make_Defining_Identifier
(Loc
,
2784 Chars
=> Name_For_New_Spec
),
2785 Parameter_Specifications
=> Parameters
);
2788 raise Program_Error
;
2790 end Copy_Specification
;
2792 -----------------------------
2793 -- Corresponding_Stub_Type --
2794 -----------------------------
2796 function Corresponding_Stub_Type
(RACW_Type
: Entity_Id
) return Entity_Id
is
2797 Desig
: constant Entity_Id
:=
2798 Etype
(Designated_Type
(RACW_Type
));
2799 Stub_Elements
: constant Stub_Structure
:= Stubs_Table
.Get
(Desig
);
2801 return Stub_Elements
.Stub_Type
;
2802 end Corresponding_Stub_Type
;
2804 ---------------------------
2805 -- Could_Be_Asynchronous --
2806 ---------------------------
2808 function Could_Be_Asynchronous
(Spec
: Node_Id
) return Boolean is
2809 Current_Parameter
: Node_Id
;
2812 if Present
(Parameter_Specifications
(Spec
)) then
2813 Current_Parameter
:= First
(Parameter_Specifications
(Spec
));
2814 while Present
(Current_Parameter
) loop
2815 if Out_Present
(Current_Parameter
) then
2819 Next
(Current_Parameter
);
2824 end Could_Be_Asynchronous
;
2826 ---------------------------
2827 -- Declare_Create_NVList --
2828 ---------------------------
2830 procedure Declare_Create_NVList
2838 Make_Object_Declaration
(Loc
,
2839 Defining_Identifier
=> NVList
,
2840 Aliased_Present
=> False,
2841 Object_Definition
=>
2842 New_Occurrence_Of
(RTE
(RE_NVList_Ref
), Loc
)));
2845 Make_Procedure_Call_Statement
(Loc
,
2846 Name
=> New_Occurrence_Of
(RTE
(RE_NVList_Create
), Loc
),
2847 Parameter_Associations
=> New_List
(
2848 New_Occurrence_Of
(NVList
, Loc
))));
2849 end Declare_Create_NVList
;
2851 ---------------------------------------------
2852 -- Expand_All_Calls_Remote_Subprogram_Call --
2853 ---------------------------------------------
2855 procedure Expand_All_Calls_Remote_Subprogram_Call
(N
: Node_Id
) is
2856 Loc
: constant Source_Ptr
:= Sloc
(N
);
2857 Called_Subprogram
: constant Entity_Id
:= Entity
(Name
(N
));
2858 RCI_Package
: constant Entity_Id
:= Scope
(Called_Subprogram
);
2859 RCI_Locator_Decl
: Node_Id
;
2860 RCI_Locator
: Entity_Id
;
2861 Calling_Stubs
: Node_Id
;
2862 E_Calling_Stubs
: Entity_Id
;
2865 E_Calling_Stubs
:= RCI_Calling_Stubs_Table
.Get
(Called_Subprogram
);
2867 if E_Calling_Stubs
= Empty
then
2868 RCI_Locator
:= RCI_Locator_Table
.Get
(RCI_Package
);
2870 -- The RCI_Locator package and calling stub are is inserted at the
2871 -- top level in the current unit, and must appear in the proper scope
2872 -- so that it is not prematurely removed by the GCC back end.
2875 Scop
: constant Entity_Id
:= Cunit_Entity
(Current_Sem_Unit
);
2877 if Ekind
(Scop
) = E_Package_Body
then
2878 Push_Scope
(Spec_Entity
(Scop
));
2879 elsif Ekind
(Scop
) = E_Subprogram_Body
then
2881 (Corresponding_Spec
(Unit_Declaration_Node
(Scop
)));
2887 if RCI_Locator
= Empty
then
2889 RCI_Package_Locator
(Loc
, Package_Specification
(RCI_Package
));
2890 Prepend_To
(Current_Sem_Unit_Declarations
, RCI_Locator_Decl
);
2891 Analyze
(RCI_Locator_Decl
);
2892 RCI_Locator
:= Defining_Unit_Name
(RCI_Locator_Decl
);
2895 RCI_Locator_Decl
:= Parent
(RCI_Locator
);
2898 Calling_Stubs
:= Build_Subprogram_Calling_Stubs
2899 (Vis_Decl
=> Parent
(Parent
(Called_Subprogram
)),
2901 Build_Subprogram_Id
(Loc
, Called_Subprogram
),
2902 Asynchronous
=> Nkind
(N
) = N_Procedure_Call_Statement
2904 Is_Asynchronous
(Called_Subprogram
),
2905 Locator
=> RCI_Locator
,
2906 New_Name
=> New_Internal_Name
('S'));
2907 Insert_After
(RCI_Locator_Decl
, Calling_Stubs
);
2908 Analyze
(Calling_Stubs
);
2911 E_Calling_Stubs
:= Defining_Unit_Name
(Specification
(Calling_Stubs
));
2914 Rewrite
(Name
(N
), New_Occurrence_Of
(E_Calling_Stubs
, Loc
));
2915 end Expand_All_Calls_Remote_Subprogram_Call
;
2917 ---------------------------------
2918 -- Expand_Calling_Stubs_Bodies --
2919 ---------------------------------
2921 procedure Expand_Calling_Stubs_Bodies
(Unit_Node
: Node_Id
) is
2922 Spec
: constant Node_Id
:= Specification
(Unit_Node
);
2924 Add_Calling_Stubs_To_Declarations
(Spec
);
2925 end Expand_Calling_Stubs_Bodies
;
2927 -----------------------------------
2928 -- Expand_Receiving_Stubs_Bodies --
2929 -----------------------------------
2931 procedure Expand_Receiving_Stubs_Bodies
(Unit_Node
: Node_Id
) is
2934 Stubs_Decls
: List_Id
;
2935 Stubs_Stmts
: List_Id
;
2938 if Nkind
(Unit_Node
) = N_Package_Declaration
then
2939 Spec
:= Specification
(Unit_Node
);
2940 Decls
:= Private_Declarations
(Spec
);
2943 Decls
:= Visible_Declarations
(Spec
);
2946 Push_Scope
(Scope_Of_Spec
(Spec
));
2947 Specific_Add_Receiving_Stubs_To_Declarations
(Spec
, Decls
, Decls
);
2951 Package_Specification_Of_Scope
(Corresponding_Spec
(Unit_Node
));
2952 Decls
:= Declarations
(Unit_Node
);
2954 Push_Scope
(Scope_Of_Spec
(Unit_Node
));
2955 Stubs_Decls
:= New_List
;
2956 Stubs_Stmts
:= New_List
;
2957 Specific_Add_Receiving_Stubs_To_Declarations
2958 (Spec
, Stubs_Decls
, Stubs_Stmts
);
2960 Insert_List_Before
(First
(Decls
), Stubs_Decls
);
2963 HSS_Stmts
: constant List_Id
:=
2964 Statements
(Handled_Statement_Sequence
(Unit_Node
));
2966 First_HSS_Stmt
: constant Node_Id
:= First
(HSS_Stmts
);
2969 if No
(First_HSS_Stmt
) then
2970 Append_List_To
(HSS_Stmts
, Stubs_Stmts
);
2972 Insert_List_Before
(First_HSS_Stmt
, Stubs_Stmts
);
2978 end Expand_Receiving_Stubs_Bodies
;
2980 --------------------
2981 -- GARLIC_Support --
2982 --------------------
2984 package body GARLIC_Support
is
2986 -- Local subprograms
2988 procedure Add_RACW_Read_Attribute
2989 (RACW_Type
: Entity_Id
;
2990 Stub_Type
: Entity_Id
;
2991 Stub_Type_Access
: Entity_Id
;
2992 Body_Decls
: List_Id
);
2993 -- Add Read attribute for the RACW type. The declaration and attribute
2994 -- definition clauses are inserted right after the declaration of
2995 -- RACW_Type. If Body_Decls is not No_List, the subprogram body is
2996 -- appended to it (case where the RACW declaration is in the main unit).
2998 procedure Add_RACW_Write_Attribute
2999 (RACW_Type
: Entity_Id
;
3000 Stub_Type
: Entity_Id
;
3001 Stub_Type_Access
: Entity_Id
;
3002 RPC_Receiver
: Node_Id
;
3003 Body_Decls
: List_Id
);
3004 -- Same as above for the Write attribute
3006 function Stream_Parameter
return Node_Id
;
3007 function Result
return Node_Id
;
3008 function Object
return Node_Id
renames Result
;
3009 -- Functions to create occurrences of the formal parameter names of the
3010 -- 'Read and 'Write attributes.
3013 -- Shared source location used by Add_{Read,Write}_Read_Attribute and
3014 -- their ancillary subroutines (set on entry by Add_RACW_Features).
3016 procedure Add_RAS_Access_TSS
(N
: Node_Id
);
3017 -- Add a subprogram body for RAS Access TSS
3019 -------------------------------------
3020 -- Add_Obj_RPC_Receiver_Completion --
3021 -------------------------------------
3023 procedure Add_Obj_RPC_Receiver_Completion
3026 RPC_Receiver
: Entity_Id
;
3027 Stub_Elements
: Stub_Structure
)
3030 -- The RPC receiver body should not be the completion of the
3031 -- declaration recorded in the stub structure, because then the
3032 -- occurrences of the formal parameters within the body should refer
3033 -- to the entities from the declaration, not from the completion, to
3034 -- which we do not have easy access. Instead, the RPC receiver body
3035 -- acts as its own declaration, and the RPC receiver declaration is
3036 -- completed by a renaming-as-body.
3039 Make_Subprogram_Renaming_Declaration
(Loc
,
3041 Copy_Specification
(Loc
,
3042 Specification
(Stub_Elements
.RPC_Receiver_Decl
)),
3043 Name
=> New_Occurrence_Of
(RPC_Receiver
, Loc
)));
3044 end Add_Obj_RPC_Receiver_Completion
;
3046 -----------------------
3047 -- Add_RACW_Features --
3048 -----------------------
3050 procedure Add_RACW_Features
3051 (RACW_Type
: Entity_Id
;
3052 Stub_Type
: Entity_Id
;
3053 Stub_Type_Access
: Entity_Id
;
3054 RPC_Receiver_Decl
: Node_Id
;
3055 Body_Decls
: List_Id
)
3057 RPC_Receiver
: Node_Id
;
3058 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
3061 Loc
:= Sloc
(RACW_Type
);
3065 -- For a RAS, the RPC receiver is that of the RCI unit, not that
3066 -- of the corresponding distributed object type. We retrieve its
3067 -- address from the local proxy object.
3069 RPC_Receiver
:= Make_Selected_Component
(Loc
,
3071 Unchecked_Convert_To
(RTE
(RE_RAS_Proxy_Type_Access
), Object
),
3072 Selector_Name
=> Make_Identifier
(Loc
, Name_Receiver
));
3075 RPC_Receiver
:= Make_Attribute_Reference
(Loc
,
3076 Prefix
=> New_Occurrence_Of
(
3077 Defining_Unit_Name
(Specification
(RPC_Receiver_Decl
)), Loc
),
3078 Attribute_Name
=> Name_Address
);
3081 Add_RACW_Write_Attribute
3088 Add_RACW_Read_Attribute
3093 end Add_RACW_Features
;
3095 -----------------------------
3096 -- Add_RACW_Read_Attribute --
3097 -----------------------------
3099 procedure Add_RACW_Read_Attribute
3100 (RACW_Type
: Entity_Id
;
3101 Stub_Type
: Entity_Id
;
3102 Stub_Type_Access
: Entity_Id
;
3103 Body_Decls
: List_Id
)
3105 Proc_Decl
: Node_Id
;
3106 Attr_Decl
: Node_Id
;
3108 Body_Node
: Node_Id
;
3110 Statements
: constant List_Id
:= New_List
;
3112 Local_Statements
: List_Id
;
3113 Remote_Statements
: List_Id
;
3114 -- Various parts of the procedure
3116 Pnam
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
3117 Asynchronous_Flag
: constant Entity_Id
:=
3118 Asynchronous_Flags_Table
.Get
(RACW_Type
);
3119 pragma Assert
(Present
(Asynchronous_Flag
));
3121 -- Prepare local identifiers
3123 Source_Partition
: Entity_Id
;
3124 Source_Receiver
: Entity_Id
;
3125 Source_Address
: Entity_Id
;
3126 Local_Stub
: Entity_Id
;
3127 Stubbed_Result
: Entity_Id
;
3129 -- Start of processing for Add_RACW_Read_Attribute
3132 Build_Stream_Procedure
(Loc
,
3133 RACW_Type
, Body_Node
, Pnam
, Statements
, Outp
=> True);
3134 Proc_Decl
:= Make_Subprogram_Declaration
(Loc
,
3135 Copy_Specification
(Loc
, Specification
(Body_Node
)));
3138 Make_Attribute_Definition_Clause
(Loc
,
3139 Name
=> New_Occurrence_Of
(RACW_Type
, Loc
),
3143 Defining_Unit_Name
(Specification
(Proc_Decl
)), Loc
));
3145 Insert_After
(Declaration_Node
(RACW_Type
), Proc_Decl
);
3146 Insert_After
(Proc_Decl
, Attr_Decl
);
3148 if No
(Body_Decls
) then
3150 -- Case of processing an RACW type from another unit than the
3151 -- main one: do not generate a body.
3156 -- Prepare local identifiers
3158 Source_Partition
:= Make_Temporary
(Loc
, 'P');
3159 Source_Receiver
:= Make_Temporary
(Loc
, 'S');
3160 Source_Address
:= Make_Temporary
(Loc
, 'P');
3161 Local_Stub
:= Make_Temporary
(Loc
, 'L');
3162 Stubbed_Result
:= Make_Temporary
(Loc
, 'S');
3164 -- Generate object declarations
3167 Make_Object_Declaration
(Loc
,
3168 Defining_Identifier
=> Source_Partition
,
3169 Object_Definition
=>
3170 New_Occurrence_Of
(RTE
(RE_Partition_ID
), Loc
)),
3172 Make_Object_Declaration
(Loc
,
3173 Defining_Identifier
=> Source_Receiver
,
3174 Object_Definition
=>
3175 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
)),
3177 Make_Object_Declaration
(Loc
,
3178 Defining_Identifier
=> Source_Address
,
3179 Object_Definition
=>
3180 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
)),
3182 Make_Object_Declaration
(Loc
,
3183 Defining_Identifier
=> Local_Stub
,
3184 Aliased_Present
=> True,
3185 Object_Definition
=> New_Occurrence_Of
(Stub_Type
, Loc
)),
3187 Make_Object_Declaration
(Loc
,
3188 Defining_Identifier
=> Stubbed_Result
,
3189 Object_Definition
=>
3190 New_Occurrence_Of
(Stub_Type_Access
, Loc
),
3192 Make_Attribute_Reference
(Loc
,
3194 New_Occurrence_Of
(Local_Stub
, Loc
),
3196 Name_Unchecked_Access
)));
3198 -- Read the source Partition_ID and RPC_Receiver from incoming stream
3200 Append_List_To
(Statements
, New_List
(
3201 Make_Attribute_Reference
(Loc
,
3203 New_Occurrence_Of
(RTE
(RE_Partition_ID
), Loc
),
3204 Attribute_Name
=> Name_Read
,
3205 Expressions
=> New_List
(
3207 New_Occurrence_Of
(Source_Partition
, Loc
))),
3209 Make_Attribute_Reference
(Loc
,
3211 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
),
3214 Expressions
=> New_List
(
3216 New_Occurrence_Of
(Source_Receiver
, Loc
))),
3218 Make_Attribute_Reference
(Loc
,
3220 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
),
3223 Expressions
=> New_List
(
3225 New_Occurrence_Of
(Source_Address
, Loc
)))));
3227 -- Build_Get_Unique_RP_Call needs the type of Stubbed_Result
3229 Set_Etype
(Stubbed_Result
, Stub_Type_Access
);
3231 -- If the Address is Null_Address, then return a null object, unless
3232 -- RACW_Type is null-excluding, in which case unconditionally raise
3233 -- CONSTRAINT_ERROR instead.
3236 Zero_Statements
: List_Id
;
3237 -- Statements executed when a zero value is received
3240 if Can_Never_Be_Null
(RACW_Type
) then
3241 Zero_Statements
:= New_List
(
3242 Make_Raise_Constraint_Error
(Loc
,
3243 Reason
=> CE_Null_Not_Allowed
));
3245 Zero_Statements
:= New_List
(
3246 Make_Assignment_Statement
(Loc
,
3248 Expression
=> Make_Null
(Loc
)),
3249 Make_Simple_Return_Statement
(Loc
));
3252 Append_To
(Statements
,
3253 Make_Implicit_If_Statement
(RACW_Type
,
3256 Left_Opnd
=> New_Occurrence_Of
(Source_Address
, Loc
),
3257 Right_Opnd
=> Make_Integer_Literal
(Loc
, Uint_0
)),
3258 Then_Statements
=> Zero_Statements
));
3261 -- If the RACW denotes an object created on the current partition,
3262 -- Local_Statements will be executed. The real object will be used.
3264 Local_Statements
:= New_List
(
3265 Make_Assignment_Statement
(Loc
,
3268 Unchecked_Convert_To
(RACW_Type
,
3269 OK_Convert_To
(RTE
(RE_Address
),
3270 New_Occurrence_Of
(Source_Address
, Loc
)))));
3272 -- If the object is located on another partition, then a stub object
3273 -- will be created with all the information needed to rebuild the
3274 -- real object at the other end.
3276 Remote_Statements
:= New_List
(
3278 Make_Assignment_Statement
(Loc
,
3279 Name
=> Make_Selected_Component
(Loc
,
3280 Prefix
=> Stubbed_Result
,
3281 Selector_Name
=> Name_Origin
),
3283 New_Occurrence_Of
(Source_Partition
, Loc
)),
3285 Make_Assignment_Statement
(Loc
,
3286 Name
=> Make_Selected_Component
(Loc
,
3287 Prefix
=> Stubbed_Result
,
3288 Selector_Name
=> Name_Receiver
),
3290 New_Occurrence_Of
(Source_Receiver
, Loc
)),
3292 Make_Assignment_Statement
(Loc
,
3293 Name
=> Make_Selected_Component
(Loc
,
3294 Prefix
=> Stubbed_Result
,
3295 Selector_Name
=> Name_Addr
),
3297 New_Occurrence_Of
(Source_Address
, Loc
)));
3299 Append_To
(Remote_Statements
,
3300 Make_Assignment_Statement
(Loc
,
3301 Name
=> Make_Selected_Component
(Loc
,
3302 Prefix
=> Stubbed_Result
,
3303 Selector_Name
=> Name_Asynchronous
),
3305 New_Occurrence_Of
(Asynchronous_Flag
, Loc
)));
3307 Append_List_To
(Remote_Statements
,
3308 Build_Get_Unique_RP_Call
(Loc
, Stubbed_Result
, Stub_Type
));
3309 -- ??? Issue with asynchronous calls here: the Asynchronous flag is
3310 -- set on the stub type if, and only if, the RACW type has a pragma
3311 -- Asynchronous. This is incorrect for RACWs that implement RAS
3312 -- types, because in that case the /designated subprogram/ (not the
3313 -- type) might be asynchronous, and that causes the stub to need to
3314 -- be asynchronous too. A solution is to transport a RAS as a struct
3315 -- containing a RACW and an asynchronous flag, and to properly alter
3316 -- the Asynchronous component in the stub type in the RAS's Input
3319 Append_To
(Remote_Statements
,
3320 Make_Assignment_Statement
(Loc
,
3322 Expression
=> Unchecked_Convert_To
(RACW_Type
,
3323 New_Occurrence_Of
(Stubbed_Result
, Loc
))));
3325 -- Distinguish between the local and remote cases, and execute the
3326 -- appropriate piece of code.
3328 Append_To
(Statements
,
3329 Make_Implicit_If_Statement
(RACW_Type
,
3333 Make_Function_Call
(Loc
,
3334 Name
=> New_Occurrence_Of
(
3335 RTE
(RE_Get_Local_Partition_Id
), Loc
)),
3336 Right_Opnd
=> New_Occurrence_Of
(Source_Partition
, Loc
)),
3337 Then_Statements
=> Local_Statements
,
3338 Else_Statements
=> Remote_Statements
));
3340 Set_Declarations
(Body_Node
, Decls
);
3341 Append_To
(Body_Decls
, Body_Node
);
3342 end Add_RACW_Read_Attribute
;
3344 ------------------------------
3345 -- Add_RACW_Write_Attribute --
3346 ------------------------------
3348 procedure Add_RACW_Write_Attribute
3349 (RACW_Type
: Entity_Id
;
3350 Stub_Type
: Entity_Id
;
3351 Stub_Type_Access
: Entity_Id
;
3352 RPC_Receiver
: Node_Id
;
3353 Body_Decls
: List_Id
)
3355 Body_Node
: Node_Id
;
3356 Proc_Decl
: Node_Id
;
3357 Attr_Decl
: Node_Id
;
3359 Statements
: constant List_Id
:= New_List
;
3360 Local_Statements
: List_Id
;
3361 Remote_Statements
: List_Id
;
3362 Null_Statements
: List_Id
;
3364 Pnam
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
3367 Build_Stream_Procedure
3368 (Loc
, RACW_Type
, Body_Node
, Pnam
, Statements
, Outp
=> False);
3370 Proc_Decl
:= Make_Subprogram_Declaration
(Loc
,
3371 Copy_Specification
(Loc
, Specification
(Body_Node
)));
3374 Make_Attribute_Definition_Clause
(Loc
,
3375 Name
=> New_Occurrence_Of
(RACW_Type
, Loc
),
3376 Chars
=> Name_Write
,
3379 Defining_Unit_Name
(Specification
(Proc_Decl
)), Loc
));
3381 Insert_After
(Declaration_Node
(RACW_Type
), Proc_Decl
);
3382 Insert_After
(Proc_Decl
, Attr_Decl
);
3384 if No
(Body_Decls
) then
3388 -- Build the code fragment corresponding to the marshalling of a
3391 Local_Statements
:= New_List
(
3393 Pack_Entity_Into_Stream_Access
(Loc
,
3394 Stream
=> Stream_Parameter
,
3395 Object
=> RTE
(RE_Get_Local_Partition_Id
)),
3397 Pack_Node_Into_Stream_Access
(Loc
,
3398 Stream
=> Stream_Parameter
,
3399 Object
=> OK_Convert_To
(RTE
(RE_Unsigned_64
), RPC_Receiver
),
3400 Etyp
=> RTE
(RE_Unsigned_64
)),
3402 Pack_Node_Into_Stream_Access
(Loc
,
3403 Stream
=> Stream_Parameter
,
3404 Object
=> OK_Convert_To
(RTE
(RE_Unsigned_64
),
3405 Make_Attribute_Reference
(Loc
,
3407 Make_Explicit_Dereference
(Loc
,
3409 Attribute_Name
=> Name_Address
)),
3410 Etyp
=> RTE
(RE_Unsigned_64
)));
3412 -- Build the code fragment corresponding to the marshalling of
3415 Remote_Statements
:= New_List
(
3416 Pack_Node_Into_Stream_Access
(Loc
,
3417 Stream
=> Stream_Parameter
,
3419 Make_Selected_Component
(Loc
,
3421 Unchecked_Convert_To
(Stub_Type_Access
, Object
),
3422 Selector_Name
=> Make_Identifier
(Loc
, Name_Origin
)),
3423 Etyp
=> RTE
(RE_Partition_ID
)),
3425 Pack_Node_Into_Stream_Access
(Loc
,
3426 Stream
=> Stream_Parameter
,
3428 Make_Selected_Component
(Loc
,
3430 Unchecked_Convert_To
(Stub_Type_Access
, Object
),
3431 Selector_Name
=> Make_Identifier
(Loc
, Name_Receiver
)),
3432 Etyp
=> RTE
(RE_Unsigned_64
)),
3434 Pack_Node_Into_Stream_Access
(Loc
,
3435 Stream
=> Stream_Parameter
,
3437 Make_Selected_Component
(Loc
,
3439 Unchecked_Convert_To
(Stub_Type_Access
, Object
),
3440 Selector_Name
=> Make_Identifier
(Loc
, Name_Addr
)),
3441 Etyp
=> RTE
(RE_Unsigned_64
)));
3443 -- Build code fragment corresponding to marshalling of a null object
3445 Null_Statements
:= New_List
(
3447 Pack_Entity_Into_Stream_Access
(Loc
,
3448 Stream
=> Stream_Parameter
,
3449 Object
=> RTE
(RE_Get_Local_Partition_Id
)),
3451 Pack_Node_Into_Stream_Access
(Loc
,
3452 Stream
=> Stream_Parameter
,
3453 Object
=> OK_Convert_To
(RTE
(RE_Unsigned_64
), RPC_Receiver
),
3454 Etyp
=> RTE
(RE_Unsigned_64
)),
3456 Pack_Node_Into_Stream_Access
(Loc
,
3457 Stream
=> Stream_Parameter
,
3458 Object
=> Make_Integer_Literal
(Loc
, Uint_0
),
3459 Etyp
=> RTE
(RE_Unsigned_64
)));
3461 Append_To
(Statements
,
3462 Make_Implicit_If_Statement
(RACW_Type
,
3465 Left_Opnd
=> Object
,
3466 Right_Opnd
=> Make_Null
(Loc
)),
3468 Then_Statements
=> Null_Statements
,
3470 Elsif_Parts
=> New_List
(
3471 Make_Elsif_Part
(Loc
,
3475 Make_Attribute_Reference
(Loc
,
3477 Attribute_Name
=> Name_Tag
),
3480 Make_Attribute_Reference
(Loc
,
3481 Prefix
=> New_Occurrence_Of
(Stub_Type
, Loc
),
3482 Attribute_Name
=> Name_Tag
)),
3483 Then_Statements
=> Remote_Statements
)),
3484 Else_Statements
=> Local_Statements
));
3486 Append_To
(Body_Decls
, Body_Node
);
3487 end Add_RACW_Write_Attribute
;
3489 ------------------------
3490 -- Add_RAS_Access_TSS --
3491 ------------------------
3493 procedure Add_RAS_Access_TSS
(N
: Node_Id
) is
3494 Loc
: constant Source_Ptr
:= Sloc
(N
);
3496 Ras_Type
: constant Entity_Id
:= Defining_Identifier
(N
);
3497 Fat_Type
: constant Entity_Id
:= Equivalent_Type
(Ras_Type
);
3498 -- Ras_Type is the access to subprogram type while Fat_Type is the
3499 -- corresponding record type.
3501 RACW_Type
: constant Entity_Id
:=
3502 Underlying_RACW_Type
(Ras_Type
);
3503 Desig
: constant Entity_Id
:=
3504 Etype
(Designated_Type
(RACW_Type
));
3506 Stub_Elements
: constant Stub_Structure
:=
3507 Stubs_Table
.Get
(Desig
);
3508 pragma Assert
(Stub_Elements
/= Empty_Stub_Structure
);
3510 Proc
: constant Entity_Id
:=
3511 Make_Defining_Identifier
(Loc
,
3512 Chars
=> Make_TSS_Name
(Ras_Type
, TSS_RAS_Access
));
3514 Proc_Spec
: Node_Id
;
3516 -- Formal parameters
3518 Package_Name
: constant Entity_Id
:=
3519 Make_Defining_Identifier
(Loc
,
3523 Subp_Id
: constant Entity_Id
:=
3524 Make_Defining_Identifier
(Loc
,
3526 -- Target subprogram
3528 Asynch_P
: constant Entity_Id
:=
3529 Make_Defining_Identifier
(Loc
,
3530 Chars
=> Name_Asynchronous
);
3531 -- Is the procedure to which the 'Access applies asynchronous?
3533 All_Calls_Remote
: constant Entity_Id
:=
3534 Make_Defining_Identifier
(Loc
,
3535 Chars
=> Name_All_Calls_Remote
);
3536 -- True if an All_Calls_Remote pragma applies to the RCI unit
3537 -- that contains the subprogram.
3539 -- Common local variables
3541 Proc_Decls
: List_Id
;
3542 Proc_Statements
: List_Id
;
3544 Origin
: constant Entity_Id
:= Make_Temporary
(Loc
, 'P');
3546 -- Additional local variables for the local case
3548 Proxy_Addr
: constant Entity_Id
:= Make_Temporary
(Loc
, 'P');
3550 -- Additional local variables for the remote case
3552 Local_Stub
: constant Entity_Id
:= Make_Temporary
(Loc
, 'L');
3553 Stub_Ptr
: constant Entity_Id
:= Make_Temporary
(Loc
, 'S');
3556 (Field_Name
: Name_Id
;
3557 Value
: Node_Id
) return Node_Id
;
3558 -- Construct an assignment that sets the named component in the
3566 (Field_Name
: Name_Id
;
3567 Value
: Node_Id
) return Node_Id
3571 Make_Assignment_Statement
(Loc
,
3573 Make_Selected_Component
(Loc
,
3575 Selector_Name
=> Field_Name
),
3576 Expression
=> Value
);
3579 -- Start of processing for Add_RAS_Access_TSS
3582 Proc_Decls
:= New_List
(
3584 -- Common declarations
3586 Make_Object_Declaration
(Loc
,
3587 Defining_Identifier
=> Origin
,
3588 Constant_Present
=> True,
3589 Object_Definition
=>
3590 New_Occurrence_Of
(RTE
(RE_Partition_ID
), Loc
),
3592 Make_Function_Call
(Loc
,
3594 New_Occurrence_Of
(RTE
(RE_Get_Active_Partition_Id
), Loc
),
3595 Parameter_Associations
=> New_List
(
3596 New_Occurrence_Of
(Package_Name
, Loc
)))),
3598 -- Declaration use only in the local case: proxy address
3600 Make_Object_Declaration
(Loc
,
3601 Defining_Identifier
=> Proxy_Addr
,
3602 Object_Definition
=>
3603 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
)),
3605 -- Declarations used only in the remote case: stub object and
3608 Make_Object_Declaration
(Loc
,
3609 Defining_Identifier
=> Local_Stub
,
3610 Aliased_Present
=> True,
3611 Object_Definition
=>
3612 New_Occurrence_Of
(Stub_Elements
.Stub_Type
, Loc
)),
3614 Make_Object_Declaration
(Loc
,
3615 Defining_Identifier
=>
3617 Object_Definition
=>
3618 New_Occurrence_Of
(Stub_Elements
.Stub_Type_Access
, Loc
),
3620 Make_Attribute_Reference
(Loc
,
3621 Prefix
=> New_Occurrence_Of
(Local_Stub
, Loc
),
3622 Attribute_Name
=> Name_Unchecked_Access
)));
3624 Set_Etype
(Stub_Ptr
, Stub_Elements
.Stub_Type_Access
);
3626 -- Build_Get_Unique_RP_Call needs above information
3628 -- Note: Here we assume that the Fat_Type is a record
3629 -- containing just a pointer to a proxy or stub object.
3631 Proc_Statements
:= New_List
(
3635 -- Get_RAS_Info (Pkg, Subp, PA);
3636 -- if Origin = Local_Partition_Id
3637 -- and then not All_Calls_Remote
3639 -- return Fat_Type!(PA);
3642 Make_Procedure_Call_Statement
(Loc
,
3643 Name
=> New_Occurrence_Of
(RTE
(RE_Get_RAS_Info
), Loc
),
3644 Parameter_Associations
=> New_List
(
3645 New_Occurrence_Of
(Package_Name
, Loc
),
3646 New_Occurrence_Of
(Subp_Id
, Loc
),
3647 New_Occurrence_Of
(Proxy_Addr
, Loc
))),
3649 Make_Implicit_If_Statement
(N
,
3655 New_Occurrence_Of
(Origin
, Loc
),
3657 Make_Function_Call
(Loc
,
3659 RTE
(RE_Get_Local_Partition_Id
), Loc
))),
3663 New_Occurrence_Of
(All_Calls_Remote
, Loc
))),
3665 Then_Statements
=> New_List
(
3666 Make_Simple_Return_Statement
(Loc
,
3667 Unchecked_Convert_To
(Fat_Type
,
3668 OK_Convert_To
(RTE
(RE_Address
),
3669 New_Occurrence_Of
(Proxy_Addr
, Loc
)))))),
3671 Set_Field
(Name_Origin
,
3672 New_Occurrence_Of
(Origin
, Loc
)),
3674 Set_Field
(Name_Receiver
,
3675 Make_Function_Call
(Loc
,
3677 New_Occurrence_Of
(RTE
(RE_Get_RCI_Package_Receiver
), Loc
),
3678 Parameter_Associations
=> New_List
(
3679 New_Occurrence_Of
(Package_Name
, Loc
)))),
3681 Set_Field
(Name_Addr
, New_Occurrence_Of
(Proxy_Addr
, Loc
)),
3683 -- E.4.1(9) A remote call is asynchronous if it is a call to
3684 -- a procedure or a call through a value of an access-to-procedure
3685 -- type to which a pragma Asynchronous applies.
3687 -- Asynch_P is true when the procedure is asynchronous;
3688 -- Asynch_T is true when the type is asynchronous.
3690 Set_Field
(Name_Asynchronous
,
3692 New_Occurrence_Of
(Asynch_P
, Loc
),
3693 New_Occurrence_Of
(Boolean_Literals
(
3694 Is_Asynchronous
(Ras_Type
)), Loc
))));
3696 Append_List_To
(Proc_Statements
,
3697 Build_Get_Unique_RP_Call
3698 (Loc
, Stub_Ptr
, Stub_Elements
.Stub_Type
));
3700 -- Return the newly created value
3702 Append_To
(Proc_Statements
,
3703 Make_Simple_Return_Statement
(Loc
,
3705 Unchecked_Convert_To
(Fat_Type
,
3706 New_Occurrence_Of
(Stub_Ptr
, Loc
))));
3709 Make_Function_Specification
(Loc
,
3710 Defining_Unit_Name
=> Proc
,
3711 Parameter_Specifications
=> New_List
(
3712 Make_Parameter_Specification
(Loc
,
3713 Defining_Identifier
=> Package_Name
,
3715 New_Occurrence_Of
(Standard_String
, Loc
)),
3717 Make_Parameter_Specification
(Loc
,
3718 Defining_Identifier
=> Subp_Id
,
3720 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
)),
3722 Make_Parameter_Specification
(Loc
,
3723 Defining_Identifier
=> Asynch_P
,
3725 New_Occurrence_Of
(Standard_Boolean
, Loc
)),
3727 Make_Parameter_Specification
(Loc
,
3728 Defining_Identifier
=> All_Calls_Remote
,
3730 New_Occurrence_Of
(Standard_Boolean
, Loc
))),
3732 Result_Definition
=>
3733 New_Occurrence_Of
(Fat_Type
, Loc
));
3735 -- Set the kind and return type of the function to prevent
3736 -- ambiguities between Ras_Type and Fat_Type in subsequent analysis.
3738 Set_Ekind
(Proc
, E_Function
);
3739 Set_Etype
(Proc
, Fat_Type
);
3742 Make_Subprogram_Body
(Loc
,
3743 Specification
=> Proc_Spec
,
3744 Declarations
=> Proc_Decls
,
3745 Handled_Statement_Sequence
=>
3746 Make_Handled_Sequence_Of_Statements
(Loc
,
3747 Statements
=> Proc_Statements
)));
3749 Set_TSS
(Fat_Type
, Proc
);
3750 end Add_RAS_Access_TSS
;
3752 -----------------------
3753 -- Add_RAST_Features --
3754 -----------------------
3756 procedure Add_RAST_Features
3757 (Vis_Decl
: Node_Id
;
3758 RAS_Type
: Entity_Id
)
3760 pragma Unreferenced
(RAS_Type
);
3762 Add_RAS_Access_TSS
(Vis_Decl
);
3763 end Add_RAST_Features
;
3765 -----------------------------------------
3766 -- Add_Receiving_Stubs_To_Declarations --
3767 -----------------------------------------
3769 procedure Add_Receiving_Stubs_To_Declarations
3770 (Pkg_Spec
: Node_Id
;
3774 Loc
: constant Source_Ptr
:= Sloc
(Pkg_Spec
);
3776 Request_Parameter
: Node_Id
;
3778 Pkg_RPC_Receiver
: constant Entity_Id
:=
3779 Make_Temporary
(Loc
, 'H');
3780 Pkg_RPC_Receiver_Statements
: List_Id
;
3781 Pkg_RPC_Receiver_Cases
: constant List_Id
:= New_List
;
3782 Pkg_RPC_Receiver_Body
: Node_Id
;
3783 -- A Pkg_RPC_Receiver is built to decode the request
3785 Lookup_RAS
: Node_Id
;
3786 Lookup_RAS_Info
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
3787 -- A remote subprogram is created to allow peers to look up RAS
3788 -- information using subprogram ids.
3790 Subp_Id
: Entity_Id
;
3791 Subp_Index
: Entity_Id
;
3792 -- Subprogram_Id as read from the incoming stream
3794 Current_Subp_Number
: Int
:= First_RCI_Subprogram_Id
;
3795 Current_Stubs
: Node_Id
;
3797 Subp_Info_Array
: constant Entity_Id
:= Make_Temporary
(Loc
, 'I');
3798 Subp_Info_List
: constant List_Id
:= New_List
;
3800 Register_Pkg_Actuals
: constant List_Id
:= New_List
;
3802 All_Calls_Remote_E
: Entity_Id
;
3803 Proxy_Object_Addr
: Entity_Id
;
3805 procedure Append_Stubs_To
3806 (RPC_Receiver_Cases
: List_Id
;
3808 Subprogram_Number
: Int
);
3809 -- Add one case to the specified RPC receiver case list
3810 -- associating Subprogram_Number with the subprogram declared
3811 -- by Declaration, for which we have receiving stubs in Stubs.
3813 procedure Visit_Subprogram
(Decl
: Node_Id
);
3814 -- Generate receiving stub for one remote subprogram
3816 ---------------------
3817 -- Append_Stubs_To --
3818 ---------------------
3820 procedure Append_Stubs_To
3821 (RPC_Receiver_Cases
: List_Id
;
3823 Subprogram_Number
: Int
)
3826 Append_To
(RPC_Receiver_Cases
,
3827 Make_Case_Statement_Alternative
(Loc
,
3829 New_List
(Make_Integer_Literal
(Loc
, Subprogram_Number
)),
3832 Make_Procedure_Call_Statement
(Loc
,
3834 New_Occurrence_Of
(Defining_Entity
(Stubs
), Loc
),
3835 Parameter_Associations
=> New_List
(
3836 New_Occurrence_Of
(Request_Parameter
, Loc
))))));
3837 end Append_Stubs_To
;
3839 ----------------------
3840 -- Visit_Subprogram --
3841 ----------------------
3843 procedure Visit_Subprogram
(Decl
: Node_Id
) is
3844 Loc
: constant Source_Ptr
:= Sloc
(Decl
);
3845 Spec
: constant Node_Id
:= Specification
(Decl
);
3846 Subp_Def
: constant Entity_Id
:= Defining_Unit_Name
(Spec
);
3848 Subp_Val
: String_Id
;
3849 pragma Warnings
(Off
, Subp_Val
);
3852 -- Disable expansion of stubs if serious errors have been
3853 -- diagnosed, because otherwise some illegal remote subprogram
3854 -- declarations could cause cascaded errors in stubs.
3856 if Serious_Errors_Detected
/= 0 then
3860 -- Build receiving stub
3863 Build_Subprogram_Receiving_Stubs
3866 Nkind
(Spec
) = N_Procedure_Specification
3867 and then Is_Asynchronous
(Subp_Def
));
3869 Append_To
(Decls
, Current_Stubs
);
3870 Analyze
(Current_Stubs
);
3874 Add_RAS_Proxy_And_Analyze
(Decls
,
3876 All_Calls_Remote_E
=> All_Calls_Remote_E
,
3877 Proxy_Object_Addr
=> Proxy_Object_Addr
);
3879 -- Compute distribution identifier
3881 Assign_Subprogram_Identifier
3882 (Subp_Def
, Current_Subp_Number
, Subp_Val
);
3884 pragma Assert
(Current_Subp_Number
= Get_Subprogram_Id
(Subp_Def
));
3886 -- Add subprogram descriptor (RCI_Subp_Info) to the subprograms
3887 -- table for this receiver. This aggregate must be kept consistent
3888 -- with the declaration of RCI_Subp_Info in
3889 -- System.Partition_Interface.
3891 Append_To
(Subp_Info_List
,
3892 Make_Component_Association
(Loc
,
3893 Choices
=> New_List
(
3894 Make_Integer_Literal
(Loc
, Current_Subp_Number
)),
3897 Make_Aggregate
(Loc
,
3898 Component_Associations
=> New_List
(
3902 Make_Component_Association
(Loc
,
3904 New_List
(Make_Identifier
(Loc
, Name_Addr
)),
3906 New_Occurrence_Of
(Proxy_Object_Addr
, Loc
))))));
3908 Append_Stubs_To
(Pkg_RPC_Receiver_Cases
,
3909 Stubs
=> Current_Stubs
,
3910 Subprogram_Number
=> Current_Subp_Number
);
3912 Current_Subp_Number
:= Current_Subp_Number
+ 1;
3913 end Visit_Subprogram
;
3915 procedure Visit_Spec
is new Build_Package_Stubs
(Visit_Subprogram
);
3917 -- Start of processing for Add_Receiving_Stubs_To_Declarations
3920 -- Building receiving stubs consist in several operations:
3922 -- - a package RPC receiver must be built. This subprogram
3923 -- will get a Subprogram_Id from the incoming stream
3924 -- and will dispatch the call to the right subprogram;
3926 -- - a receiving stub for each subprogram visible in the package
3927 -- spec. This stub will read all the parameters from the stream,
3928 -- and put the result as well as the exception occurrence in the
3931 -- - a dummy package with an empty spec and a body made of an
3932 -- elaboration part, whose job is to register the receiving
3933 -- part of this RCI package on the name server. This is done
3934 -- by calling System.Partition_Interface.Register_Receiving_Stub.
3936 Build_RPC_Receiver_Body
(
3937 RPC_Receiver
=> Pkg_RPC_Receiver
,
3938 Request
=> Request_Parameter
,
3940 Subp_Index
=> Subp_Index
,
3941 Stmts
=> Pkg_RPC_Receiver_Statements
,
3942 Decl
=> Pkg_RPC_Receiver_Body
);
3943 pragma Assert
(Subp_Id
= Subp_Index
);
3945 -- A null subp_id denotes a call through a RAS, in which case the
3946 -- next Uint_64 element in the stream is the address of the local
3947 -- proxy object, from which we can retrieve the actual subprogram id.
3949 Append_To
(Pkg_RPC_Receiver_Statements
,
3950 Make_Implicit_If_Statement
(Pkg_Spec
,
3953 New_Occurrence_Of
(Subp_Id
, Loc
),
3954 Make_Integer_Literal
(Loc
, 0)),
3956 Then_Statements
=> New_List
(
3957 Make_Assignment_Statement
(Loc
,
3959 New_Occurrence_Of
(Subp_Id
, Loc
),
3962 Make_Selected_Component
(Loc
,
3964 Unchecked_Convert_To
(RTE
(RE_RAS_Proxy_Type_Access
),
3965 OK_Convert_To
(RTE
(RE_Address
),
3966 Make_Attribute_Reference
(Loc
,
3968 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
),
3971 Expressions
=> New_List
(
3972 Make_Selected_Component
(Loc
,
3973 Prefix
=> Request_Parameter
,
3974 Selector_Name
=> Name_Params
))))),
3976 Selector_Name
=> Make_Identifier
(Loc
, Name_Subp_Id
))))));
3978 -- Build a subprogram for RAS information lookups
3981 Make_Subprogram_Declaration
(Loc
,
3983 Make_Function_Specification
(Loc
,
3984 Defining_Unit_Name
=>
3986 Parameter_Specifications
=> New_List
(
3987 Make_Parameter_Specification
(Loc
,
3988 Defining_Identifier
=>
3989 Make_Defining_Identifier
(Loc
, Name_Subp_Id
),
3993 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
))),
3994 Result_Definition
=>
3995 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
)));
3996 Append_To
(Decls
, Lookup_RAS
);
3997 Analyze
(Lookup_RAS
);
3999 Current_Stubs
:= Build_Subprogram_Receiving_Stubs
4000 (Vis_Decl
=> Lookup_RAS
,
4001 Asynchronous
=> False);
4002 Append_To
(Decls
, Current_Stubs
);
4003 Analyze
(Current_Stubs
);
4005 Append_Stubs_To
(Pkg_RPC_Receiver_Cases
,
4006 Stubs
=> Current_Stubs
,
4007 Subprogram_Number
=> 1);
4009 -- For each subprogram, the receiving stub will be built and a
4010 -- case statement will be made on the Subprogram_Id to dispatch
4011 -- to the right subprogram.
4013 All_Calls_Remote_E
:=
4015 (Has_All_Calls_Remote
(Defining_Entity
(Pkg_Spec
)));
4017 Overload_Counter_Table
.Reset
;
4019 Visit_Spec
(Pkg_Spec
);
4021 -- If we receive an invalid Subprogram_Id, it is best to do nothing
4022 -- rather than raising an exception since we do not want someone
4023 -- to crash a remote partition by sending invalid subprogram ids.
4024 -- This is consistent with the other parts of the case statement
4025 -- since even in presence of incorrect parameters in the stream,
4026 -- every exception will be caught and (if the subprogram is not an
4027 -- APC) put into the result stream and sent away.
4029 Append_To
(Pkg_RPC_Receiver_Cases
,
4030 Make_Case_Statement_Alternative
(Loc
,
4031 Discrete_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
4032 Statements
=> New_List
(Make_Null_Statement
(Loc
))));
4034 Append_To
(Pkg_RPC_Receiver_Statements
,
4035 Make_Case_Statement
(Loc
,
4036 Expression
=> New_Occurrence_Of
(Subp_Id
, Loc
),
4037 Alternatives
=> Pkg_RPC_Receiver_Cases
));
4040 Make_Object_Declaration
(Loc
,
4041 Defining_Identifier
=> Subp_Info_Array
,
4042 Constant_Present
=> True,
4043 Aliased_Present
=> True,
4044 Object_Definition
=>
4045 Make_Subtype_Indication
(Loc
,
4047 New_Occurrence_Of
(RTE
(RE_RCI_Subp_Info_Array
), Loc
),
4049 Make_Index_Or_Discriminant_Constraint
(Loc
,
4052 Low_Bound
=> Make_Integer_Literal
(Loc
,
4053 First_RCI_Subprogram_Id
),
4055 Make_Integer_Literal
(Loc
,
4057 First_RCI_Subprogram_Id
4058 + List_Length
(Subp_Info_List
) - 1)))))));
4060 -- For a degenerate RCI with no visible subprograms, Subp_Info_List
4061 -- has zero length, and the declaration is for an empty array, in
4062 -- which case no initialization aggregate must be generated.
4064 if Present
(First
(Subp_Info_List
)) then
4065 Set_Expression
(Last
(Decls
),
4066 Make_Aggregate
(Loc
,
4067 Component_Associations
=> Subp_Info_List
));
4069 -- No initialization provided: remove CONSTANT so that the
4070 -- declaration is not an incomplete deferred constant.
4073 Set_Constant_Present
(Last
(Decls
), False);
4076 Analyze
(Last
(Decls
));
4079 Subp_Info_Addr
: Node_Id
;
4080 -- Return statement for Lookup_RAS_Info: address of the subprogram
4081 -- information record for the requested subprogram id.
4084 if Present
(First
(Subp_Info_List
)) then
4086 Make_Selected_Component
(Loc
,
4088 Make_Indexed_Component
(Loc
,
4089 Prefix
=> New_Occurrence_Of
(Subp_Info_Array
, Loc
),
4090 Expressions
=> New_List
(
4091 Convert_To
(Standard_Integer
,
4092 Make_Identifier
(Loc
, Name_Subp_Id
)))),
4093 Selector_Name
=> Make_Identifier
(Loc
, Name_Addr
));
4095 -- Case of no visible subprogram: just raise Constraint_Error, we
4096 -- know for sure we got junk from a remote partition.
4100 Make_Raise_Constraint_Error
(Loc
,
4101 Reason
=> CE_Range_Check_Failed
);
4102 Set_Etype
(Subp_Info_Addr
, RTE
(RE_Unsigned_64
));
4106 Make_Subprogram_Body
(Loc
,
4108 Copy_Specification
(Loc
, Parent
(Lookup_RAS_Info
)),
4109 Declarations
=> No_List
,
4110 Handled_Statement_Sequence
=>
4111 Make_Handled_Sequence_Of_Statements
(Loc
,
4112 Statements
=> New_List
(
4113 Make_Simple_Return_Statement
(Loc
,
4116 (RTE
(RE_Unsigned_64
), Subp_Info_Addr
))))));
4119 Analyze
(Last
(Decls
));
4121 Append_To
(Decls
, Pkg_RPC_Receiver_Body
);
4122 Analyze
(Last
(Decls
));
4126 Append_To
(Register_Pkg_Actuals
,
4127 Make_String_Literal
(Loc
,
4129 Fully_Qualified_Name_String
4130 (Defining_Entity
(Pkg_Spec
), Append_NUL
=> False)));
4134 Append_To
(Register_Pkg_Actuals
,
4135 Make_Attribute_Reference
(Loc
,
4136 Prefix
=> New_Occurrence_Of
(Pkg_RPC_Receiver
, Loc
),
4137 Attribute_Name
=> Name_Unrestricted_Access
));
4141 Append_To
(Register_Pkg_Actuals
,
4142 Make_Attribute_Reference
(Loc
,
4144 New_Occurrence_Of
(Defining_Entity
(Pkg_Spec
), Loc
),
4145 Attribute_Name
=> Name_Version
));
4149 Append_To
(Register_Pkg_Actuals
,
4150 Make_Attribute_Reference
(Loc
,
4151 Prefix
=> New_Occurrence_Of
(Subp_Info_Array
, Loc
),
4152 Attribute_Name
=> Name_Address
));
4156 Append_To
(Register_Pkg_Actuals
,
4157 Make_Attribute_Reference
(Loc
,
4158 Prefix
=> New_Occurrence_Of
(Subp_Info_Array
, Loc
),
4159 Attribute_Name
=> Name_Length
));
4161 -- Generate the call
4164 Make_Procedure_Call_Statement
(Loc
,
4166 New_Occurrence_Of
(RTE
(RE_Register_Receiving_Stub
), Loc
),
4167 Parameter_Associations
=> Register_Pkg_Actuals
));
4168 Analyze
(Last
(Stmts
));
4169 end Add_Receiving_Stubs_To_Declarations
;
4171 ---------------------------------
4172 -- Build_General_Calling_Stubs --
4173 ---------------------------------
4175 procedure Build_General_Calling_Stubs
4177 Statements
: List_Id
;
4178 Target_Partition
: Entity_Id
;
4179 Target_RPC_Receiver
: Node_Id
;
4180 Subprogram_Id
: Node_Id
;
4181 Asynchronous
: Node_Id
:= Empty
;
4182 Is_Known_Asynchronous
: Boolean := False;
4183 Is_Known_Non_Asynchronous
: Boolean := False;
4184 Is_Function
: Boolean;
4186 Stub_Type
: Entity_Id
:= Empty
;
4187 RACW_Type
: Entity_Id
:= Empty
;
4190 Loc
: constant Source_Ptr
:= Sloc
(Nod
);
4192 Stream_Parameter
: Node_Id
;
4193 -- Name of the stream used to transmit parameters to the remote
4196 Result_Parameter
: Node_Id
;
4197 -- Name of the result parameter (in non-APC cases) which get the
4198 -- result of the remote subprogram.
4200 Exception_Return_Parameter
: Node_Id
;
4201 -- Name of the parameter which will hold the exception sent by the
4202 -- remote subprogram.
4204 Current_Parameter
: Node_Id
;
4205 -- Current parameter being handled
4207 Ordered_Parameters_List
: constant List_Id
:=
4208 Build_Ordered_Parameters_List
(Spec
);
4210 Asynchronous_Statements
: List_Id
:= No_List
;
4211 Non_Asynchronous_Statements
: List_Id
:= No_List
;
4212 -- Statements specifics to the Asynchronous/Non-Asynchronous cases
4214 Extra_Formal_Statements
: constant List_Id
:= New_List
;
4215 -- List of statements for extra formal parameters. It will appear
4216 -- after the regular statements for writing out parameters.
4218 pragma Unreferenced
(RACW_Type
);
4219 -- Used only for the PolyORB case
4222 -- The general form of a calling stub for a given subprogram is:
4224 -- procedure X (...) is P : constant Partition_ID :=
4225 -- RCI_Cache.Get_Active_Partition_ID; Stream, Result : aliased
4226 -- System.RPC.Params_Stream_Type (0); begin
4227 -- Put_Package_RPC_Receiver_In_Stream; (the package RPC receiver
4228 -- comes from RCI_Cache.Get_RCI_Package_Receiver)
4229 -- Put_Subprogram_Id_In_Stream; Put_Parameters_In_Stream; Do_RPC
4230 -- (Stream, Result); Read_Exception_Occurrence_From_Result;
4232 -- Read_Out_Parameters_And_Function_Return_From_Stream; end X;
4234 -- There are some variations: Do_APC is called for an asynchronous
4235 -- procedure and the part after the call is completely ommitted as
4236 -- well as the declaration of Result. For a function call, 'Input is
4237 -- always used to read the result even if it is constrained.
4239 Stream_Parameter
:= Make_Temporary
(Loc
, 'S');
4242 Make_Object_Declaration
(Loc
,
4243 Defining_Identifier
=> Stream_Parameter
,
4244 Aliased_Present
=> True,
4245 Object_Definition
=>
4246 Make_Subtype_Indication
(Loc
,
4248 New_Occurrence_Of
(RTE
(RE_Params_Stream_Type
), Loc
),
4250 Make_Index_Or_Discriminant_Constraint
(Loc
,
4252 New_List
(Make_Integer_Literal
(Loc
, 0))))));
4254 if not Is_Known_Asynchronous
then
4255 Result_Parameter
:= Make_Temporary
(Loc
, 'R');
4258 Make_Object_Declaration
(Loc
,
4259 Defining_Identifier
=> Result_Parameter
,
4260 Aliased_Present
=> True,
4261 Object_Definition
=>
4262 Make_Subtype_Indication
(Loc
,
4264 New_Occurrence_Of
(RTE
(RE_Params_Stream_Type
), Loc
),
4266 Make_Index_Or_Discriminant_Constraint
(Loc
,
4268 New_List
(Make_Integer_Literal
(Loc
, 0))))));
4270 Exception_Return_Parameter
:= Make_Temporary
(Loc
, 'E');
4273 Make_Object_Declaration
(Loc
,
4274 Defining_Identifier
=> Exception_Return_Parameter
,
4275 Object_Definition
=>
4276 New_Occurrence_Of
(RTE
(RE_Exception_Occurrence
), Loc
)));
4279 Result_Parameter
:= Empty
;
4280 Exception_Return_Parameter
:= Empty
;
4283 -- Put first the RPC receiver corresponding to the remote package
4285 Append_To
(Statements
,
4286 Make_Attribute_Reference
(Loc
,
4288 New_Occurrence_Of
(RTE
(RE_Unsigned_64
), Loc
),
4289 Attribute_Name
=> Name_Write
,
4290 Expressions
=> New_List
(
4291 Make_Attribute_Reference
(Loc
,
4292 Prefix
=> New_Occurrence_Of
(Stream_Parameter
, Loc
),
4293 Attribute_Name
=> Name_Access
),
4294 Target_RPC_Receiver
)));
4296 -- Then put the Subprogram_Id of the subprogram we want to call in
4299 Append_To
(Statements
,
4300 Make_Attribute_Reference
(Loc
,
4301 Prefix
=> New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
),
4302 Attribute_Name
=> Name_Write
,
4303 Expressions
=> New_List
(
4304 Make_Attribute_Reference
(Loc
,
4305 Prefix
=> New_Occurrence_Of
(Stream_Parameter
, Loc
),
4306 Attribute_Name
=> Name_Access
),
4309 Current_Parameter
:= First
(Ordered_Parameters_List
);
4310 while Present
(Current_Parameter
) loop
4312 Typ
: constant Node_Id
:=
4313 Parameter_Type
(Current_Parameter
);
4315 Constrained
: Boolean;
4317 Extra_Parameter
: Entity_Id
;
4320 if Is_RACW_Controlling_Formal
4321 (Current_Parameter
, Stub_Type
)
4323 -- In the case of a controlling formal argument, we marshall
4324 -- its addr field rather than the local stub.
4326 Append_To
(Statements
,
4327 Pack_Node_Into_Stream
(Loc
,
4328 Stream
=> Stream_Parameter
,
4330 Make_Selected_Component
(Loc
,
4332 Defining_Identifier
(Current_Parameter
),
4333 Selector_Name
=> Name_Addr
),
4334 Etyp
=> RTE
(RE_Unsigned_64
)));
4339 (Defining_Identifier
(Current_Parameter
), Loc
);
4341 -- Access type parameters are transmitted as in out
4342 -- parameters. However, a dereference is needed so that
4343 -- we marshall the designated object.
4345 if Nkind
(Typ
) = N_Access_Definition
then
4346 Value
:= Make_Explicit_Dereference
(Loc
, Value
);
4347 Etyp
:= Etype
(Subtype_Mark
(Typ
));
4349 Etyp
:= Etype
(Typ
);
4352 Constrained
:= not Transmit_As_Unconstrained
(Etyp
);
4354 -- Any parameter but unconstrained out parameters are
4355 -- transmitted to the peer.
4357 if In_Present
(Current_Parameter
)
4358 or else not Out_Present
(Current_Parameter
)
4359 or else not Constrained
4361 Append_To
(Statements
,
4362 Make_Attribute_Reference
(Loc
,
4363 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
4365 Output_From_Constrained
(Constrained
),
4366 Expressions
=> New_List
(
4367 Make_Attribute_Reference
(Loc
,
4369 New_Occurrence_Of
(Stream_Parameter
, Loc
),
4370 Attribute_Name
=> Name_Access
),
4375 -- If the current parameter has a dynamic constrained status,
4376 -- then this status is transmitted as well.
4377 -- This should be done for accessibility as well ???
4379 if Nkind
(Typ
) /= N_Access_Definition
4380 and then Need_Extra_Constrained
(Current_Parameter
)
4382 -- In this block, we do not use the extra formal that has
4383 -- been created because it does not exist at the time of
4384 -- expansion when building calling stubs for remote access
4385 -- to subprogram types. We create an extra variable of this
4386 -- type and push it in the stream after the regular
4389 Extra_Parameter
:= Make_Temporary
(Loc
, 'P');
4392 Make_Object_Declaration
(Loc
,
4393 Defining_Identifier
=> Extra_Parameter
,
4394 Constant_Present
=> True,
4395 Object_Definition
=>
4396 New_Occurrence_Of
(Standard_Boolean
, Loc
),
4398 Make_Attribute_Reference
(Loc
,
4401 Defining_Identifier
(Current_Parameter
), Loc
),
4402 Attribute_Name
=> Name_Constrained
)));
4404 Append_To
(Extra_Formal_Statements
,
4405 Make_Attribute_Reference
(Loc
,
4407 New_Occurrence_Of
(Standard_Boolean
, Loc
),
4408 Attribute_Name
=> Name_Write
,
4409 Expressions
=> New_List
(
4410 Make_Attribute_Reference
(Loc
,
4413 (Stream_Parameter
, Loc
), Attribute_Name
=>
4415 New_Occurrence_Of
(Extra_Parameter
, Loc
))));
4418 Next
(Current_Parameter
);
4422 -- Append the formal statements list to the statements
4424 Append_List_To
(Statements
, Extra_Formal_Statements
);
4426 if not Is_Known_Non_Asynchronous
then
4428 -- Build the call to System.RPC.Do_APC
4430 Asynchronous_Statements
:= New_List
(
4431 Make_Procedure_Call_Statement
(Loc
,
4433 New_Occurrence_Of
(RTE
(RE_Do_Apc
), Loc
),
4434 Parameter_Associations
=> New_List
(
4435 New_Occurrence_Of
(Target_Partition
, Loc
),
4436 Make_Attribute_Reference
(Loc
,
4438 New_Occurrence_Of
(Stream_Parameter
, Loc
),
4439 Attribute_Name
=> Name_Access
))));
4441 Asynchronous_Statements
:= No_List
;
4444 if not Is_Known_Asynchronous
then
4446 -- Build the call to System.RPC.Do_RPC
4448 Non_Asynchronous_Statements
:= New_List
(
4449 Make_Procedure_Call_Statement
(Loc
,
4451 New_Occurrence_Of
(RTE
(RE_Do_Rpc
), Loc
),
4452 Parameter_Associations
=> New_List
(
4453 New_Occurrence_Of
(Target_Partition
, Loc
),
4455 Make_Attribute_Reference
(Loc
,
4457 New_Occurrence_Of
(Stream_Parameter
, Loc
),
4458 Attribute_Name
=> Name_Access
),
4460 Make_Attribute_Reference
(Loc
,
4462 New_Occurrence_Of
(Result_Parameter
, Loc
),
4463 Attribute_Name
=> Name_Access
))));
4465 -- Read the exception occurrence from the result stream and
4466 -- reraise it. It does no harm if this is a Null_Occurrence since
4467 -- this does nothing.
4469 Append_To
(Non_Asynchronous_Statements
,
4470 Make_Attribute_Reference
(Loc
,
4472 New_Occurrence_Of
(RTE
(RE_Exception_Occurrence
), Loc
),
4474 Attribute_Name
=> Name_Read
,
4476 Expressions
=> New_List
(
4477 Make_Attribute_Reference
(Loc
,
4479 New_Occurrence_Of
(Result_Parameter
, Loc
),
4480 Attribute_Name
=> Name_Access
),
4481 New_Occurrence_Of
(Exception_Return_Parameter
, Loc
))));
4483 Append_To
(Non_Asynchronous_Statements
,
4484 Make_Procedure_Call_Statement
(Loc
,
4486 New_Occurrence_Of
(RTE
(RE_Reraise_Occurrence
), Loc
),
4487 Parameter_Associations
=> New_List
(
4488 New_Occurrence_Of
(Exception_Return_Parameter
, Loc
))));
4492 -- If this is a function call, then read the value and return
4493 -- it. The return value is written/read using 'Output/'Input.
4495 Append_To
(Non_Asynchronous_Statements
,
4496 Make_Tag_Check
(Loc
,
4497 Make_Simple_Return_Statement
(Loc
,
4499 Make_Attribute_Reference
(Loc
,
4502 Etype
(Result_Definition
(Spec
)), Loc
),
4504 Attribute_Name
=> Name_Input
,
4506 Expressions
=> New_List
(
4507 Make_Attribute_Reference
(Loc
,
4509 New_Occurrence_Of
(Result_Parameter
, Loc
),
4510 Attribute_Name
=> Name_Access
))))));
4513 -- Loop around parameters and assign out (or in out)
4514 -- parameters. In the case of RACW, controlling arguments
4515 -- cannot possibly have changed since they are remote, so
4516 -- we do not read them from the stream.
4518 Current_Parameter
:= First
(Ordered_Parameters_List
);
4519 while Present
(Current_Parameter
) loop
4521 Typ
: constant Node_Id
:=
4522 Parameter_Type
(Current_Parameter
);
4529 (Defining_Identifier
(Current_Parameter
), Loc
);
4531 if Nkind
(Typ
) = N_Access_Definition
then
4532 Value
:= Make_Explicit_Dereference
(Loc
, Value
);
4533 Etyp
:= Etype
(Subtype_Mark
(Typ
));
4535 Etyp
:= Etype
(Typ
);
4538 if (Out_Present
(Current_Parameter
)
4539 or else Nkind
(Typ
) = N_Access_Definition
)
4540 and then Etyp
/= Stub_Type
4542 Append_To
(Non_Asynchronous_Statements
,
4543 Make_Attribute_Reference
(Loc
,
4545 New_Occurrence_Of
(Etyp
, Loc
),
4547 Attribute_Name
=> Name_Read
,
4549 Expressions
=> New_List
(
4550 Make_Attribute_Reference
(Loc
,
4552 New_Occurrence_Of
(Result_Parameter
, Loc
),
4553 Attribute_Name
=> Name_Access
),
4558 Next
(Current_Parameter
);
4563 if Is_Known_Asynchronous
then
4564 Append_List_To
(Statements
, Asynchronous_Statements
);
4566 elsif Is_Known_Non_Asynchronous
then
4567 Append_List_To
(Statements
, Non_Asynchronous_Statements
);
4570 pragma Assert
(Present
(Asynchronous
));
4571 Prepend_To
(Asynchronous_Statements
,
4572 Make_Attribute_Reference
(Loc
,
4573 Prefix
=> New_Occurrence_Of
(Standard_Boolean
, Loc
),
4574 Attribute_Name
=> Name_Write
,
4575 Expressions
=> New_List
(
4576 Make_Attribute_Reference
(Loc
,
4578 New_Occurrence_Of
(Stream_Parameter
, Loc
),
4579 Attribute_Name
=> Name_Access
),
4580 New_Occurrence_Of
(Standard_True
, Loc
))));
4582 Prepend_To
(Non_Asynchronous_Statements
,
4583 Make_Attribute_Reference
(Loc
,
4584 Prefix
=> New_Occurrence_Of
(Standard_Boolean
, Loc
),
4585 Attribute_Name
=> Name_Write
,
4586 Expressions
=> New_List
(
4587 Make_Attribute_Reference
(Loc
,
4589 New_Occurrence_Of
(Stream_Parameter
, Loc
),
4590 Attribute_Name
=> Name_Access
),
4591 New_Occurrence_Of
(Standard_False
, Loc
))));
4593 Append_To
(Statements
,
4594 Make_Implicit_If_Statement
(Nod
,
4595 Condition
=> Asynchronous
,
4596 Then_Statements
=> Asynchronous_Statements
,
4597 Else_Statements
=> Non_Asynchronous_Statements
));
4599 end Build_General_Calling_Stubs
;
4601 -----------------------------
4602 -- Build_RPC_Receiver_Body --
4603 -----------------------------
4605 procedure Build_RPC_Receiver_Body
4606 (RPC_Receiver
: Entity_Id
;
4607 Request
: out Entity_Id
;
4608 Subp_Id
: out Entity_Id
;
4609 Subp_Index
: out Entity_Id
;
4610 Stmts
: out List_Id
;
4613 Loc
: constant Source_Ptr
:= Sloc
(RPC_Receiver
);
4615 RPC_Receiver_Spec
: Node_Id
;
4616 RPC_Receiver_Decls
: List_Id
;
4619 Request
:= Make_Defining_Identifier
(Loc
, Name_R
);
4621 RPC_Receiver_Spec
:=
4622 Build_RPC_Receiver_Specification
4623 (RPC_Receiver
=> RPC_Receiver
,
4624 Request_Parameter
=> Request
);
4626 Subp_Id
:= Make_Temporary
(Loc
, 'P');
4627 Subp_Index
:= Subp_Id
;
4629 -- Subp_Id may not be a constant, because in the case of the RPC
4630 -- receiver for an RCI package, when a call is received from a RAS
4631 -- dereference, it will be assigned during subsequent processing.
4633 RPC_Receiver_Decls
:= New_List
(
4634 Make_Object_Declaration
(Loc
,
4635 Defining_Identifier
=> Subp_Id
,
4636 Object_Definition
=>
4637 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
),
4639 Make_Attribute_Reference
(Loc
,
4641 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
),
4642 Attribute_Name
=> Name_Input
,
4643 Expressions
=> New_List
(
4644 Make_Selected_Component
(Loc
,
4646 Selector_Name
=> Name_Params
)))));
4651 Make_Subprogram_Body
(Loc
,
4652 Specification
=> RPC_Receiver_Spec
,
4653 Declarations
=> RPC_Receiver_Decls
,
4654 Handled_Statement_Sequence
=>
4655 Make_Handled_Sequence_Of_Statements
(Loc
,
4656 Statements
=> Stmts
));
4657 end Build_RPC_Receiver_Body
;
4659 -----------------------
4660 -- Build_Stub_Target --
4661 -----------------------
4663 function Build_Stub_Target
4666 RCI_Locator
: Entity_Id
;
4667 Controlling_Parameter
: Entity_Id
) return RPC_Target
4669 Target_Info
: RPC_Target
(PCS_Kind
=> Name_GARLIC_DSA
);
4672 Target_Info
.Partition
:= Make_Temporary
(Loc
, 'P');
4674 if Present
(Controlling_Parameter
) then
4676 Make_Object_Declaration
(Loc
,
4677 Defining_Identifier
=> Target_Info
.Partition
,
4678 Constant_Present
=> True,
4679 Object_Definition
=>
4680 New_Occurrence_Of
(RTE
(RE_Partition_ID
), Loc
),
4683 Make_Selected_Component
(Loc
,
4684 Prefix
=> Controlling_Parameter
,
4685 Selector_Name
=> Name_Origin
)));
4687 Target_Info
.RPC_Receiver
:=
4688 Make_Selected_Component
(Loc
,
4689 Prefix
=> Controlling_Parameter
,
4690 Selector_Name
=> Name_Receiver
);
4694 Make_Object_Declaration
(Loc
,
4695 Defining_Identifier
=> Target_Info
.Partition
,
4696 Constant_Present
=> True,
4697 Object_Definition
=>
4698 New_Occurrence_Of
(RTE
(RE_Partition_ID
), Loc
),
4701 Make_Function_Call
(Loc
,
4702 Name
=> Make_Selected_Component
(Loc
,
4704 Make_Identifier
(Loc
, Chars
(RCI_Locator
)),
4706 Make_Identifier
(Loc
,
4707 Name_Get_Active_Partition_ID
)))));
4709 Target_Info
.RPC_Receiver
:=
4710 Make_Selected_Component
(Loc
,
4712 Make_Identifier
(Loc
, Chars
(RCI_Locator
)),
4714 Make_Identifier
(Loc
, Name_Get_RCI_Package_Receiver
));
4717 end Build_Stub_Target
;
4719 --------------------------------------
4720 -- Build_Subprogram_Receiving_Stubs --
4721 --------------------------------------
4723 function Build_Subprogram_Receiving_Stubs
4724 (Vis_Decl
: Node_Id
;
4725 Asynchronous
: Boolean;
4726 Dynamically_Asynchronous
: Boolean := False;
4727 Stub_Type
: Entity_Id
:= Empty
;
4728 RACW_Type
: Entity_Id
:= Empty
;
4729 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
4731 Loc
: constant Source_Ptr
:= Sloc
(Vis_Decl
);
4733 Request_Parameter
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
4734 -- Formal parameter for receiving stubs: a descriptor for an incoming
4737 Decls
: constant List_Id
:= New_List
;
4738 -- All the parameters will get declared before calling the real
4739 -- subprograms. Also the out parameters will be declared.
4741 Statements
: constant List_Id
:= New_List
;
4743 Extra_Formal_Statements
: constant List_Id
:= New_List
;
4744 -- Statements concerning extra formal parameters
4746 After_Statements
: constant List_Id
:= New_List
;
4747 -- Statements to be executed after the subprogram call
4749 Inner_Decls
: List_Id
:= No_List
;
4750 -- In case of a function, the inner declarations are needed since
4751 -- the result may be unconstrained.
4753 Excep_Handlers
: List_Id
:= No_List
;
4754 Excep_Choice
: Entity_Id
;
4755 Excep_Code
: List_Id
;
4757 Parameter_List
: constant List_Id
:= New_List
;
4758 -- List of parameters to be passed to the subprogram
4760 Current_Parameter
: Node_Id
;
4762 Ordered_Parameters_List
: constant List_Id
:=
4763 Build_Ordered_Parameters_List
4764 (Specification
(Vis_Decl
));
4766 Subp_Spec
: Node_Id
;
4767 -- Subprogram specification
4769 Called_Subprogram
: Node_Id
;
4770 -- The subprogram to call
4772 Null_Raise_Statement
: Node_Id
;
4774 Dynamic_Async
: Entity_Id
;
4777 if Present
(RACW_Type
) then
4778 Called_Subprogram
:= New_Occurrence_Of
(Parent_Primitive
, Loc
);
4780 Called_Subprogram
:=
4782 (Defining_Unit_Name
(Specification
(Vis_Decl
)), Loc
);
4785 if Dynamically_Asynchronous
then
4786 Dynamic_Async
:= Make_Temporary
(Loc
, 'S');
4788 Dynamic_Async
:= Empty
;
4791 if not Asynchronous
or Dynamically_Asynchronous
then
4793 -- The first statement after the subprogram call is a statement to
4794 -- write a Null_Occurrence into the result stream.
4796 Null_Raise_Statement
:=
4797 Make_Attribute_Reference
(Loc
,
4799 New_Occurrence_Of
(RTE
(RE_Exception_Occurrence
), Loc
),
4800 Attribute_Name
=> Name_Write
,
4801 Expressions
=> New_List
(
4802 Make_Selected_Component
(Loc
,
4803 Prefix
=> Request_Parameter
,
4804 Selector_Name
=> Name_Result
),
4805 New_Occurrence_Of
(RTE
(RE_Null_Occurrence
), Loc
)));
4807 if Dynamically_Asynchronous
then
4808 Null_Raise_Statement
:=
4809 Make_Implicit_If_Statement
(Vis_Decl
,
4811 Make_Op_Not
(Loc
, New_Occurrence_Of
(Dynamic_Async
, Loc
)),
4812 Then_Statements
=> New_List
(Null_Raise_Statement
));
4815 Append_To
(After_Statements
, Null_Raise_Statement
);
4818 -- Loop through every parameter and get its value from the stream. If
4819 -- the parameter is unconstrained, then the parameter is read using
4820 -- 'Input at the point of declaration.
4822 Current_Parameter
:= First
(Ordered_Parameters_List
);
4823 while Present
(Current_Parameter
) loop
4826 Constrained
: Boolean;
4828 Need_Extra_Constrained
: Boolean;
4829 -- True when an Extra_Constrained actual is required
4831 Object
: constant Entity_Id
:= Make_Temporary
(Loc
, 'P');
4833 Expr
: Node_Id
:= Empty
;
4835 Is_Controlling_Formal
: constant Boolean :=
4836 Is_RACW_Controlling_Formal
4837 (Current_Parameter
, Stub_Type
);
4840 if Is_Controlling_Formal
then
4842 -- We have a controlling formal parameter. Read its address
4843 -- rather than a real object. The address is in Unsigned_64
4846 Etyp
:= RTE
(RE_Unsigned_64
);
4848 Etyp
:= Etype
(Parameter_Type
(Current_Parameter
));
4851 Constrained
:= not Transmit_As_Unconstrained
(Etyp
);
4853 if In_Present
(Current_Parameter
)
4854 or else not Out_Present
(Current_Parameter
)
4855 or else not Constrained
4856 or else Is_Controlling_Formal
4858 -- If an input parameter is constrained, then the read of
4859 -- the parameter is deferred until the beginning of the
4860 -- subprogram body. If it is unconstrained, then an
4861 -- expression is built for the object declaration and the
4862 -- variable is set using 'Input instead of 'Read. Note that
4863 -- this deferral does not change the order in which the
4864 -- actuals are read because Build_Ordered_Parameter_List
4865 -- puts them unconstrained first.
4868 Append_To
(Statements
,
4869 Make_Attribute_Reference
(Loc
,
4870 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
4871 Attribute_Name
=> Name_Read
,
4872 Expressions
=> New_List
(
4873 Make_Selected_Component
(Loc
,
4874 Prefix
=> Request_Parameter
,
4875 Selector_Name
=> Name_Params
),
4876 New_Occurrence_Of
(Object
, Loc
))));
4880 -- Build and append Input_With_Tag_Check function
4883 Input_With_Tag_Check
(Loc
,
4886 Make_Selected_Component
(Loc
,
4887 Prefix
=> Request_Parameter
,
4888 Selector_Name
=> Name_Params
)));
4890 -- Prepare function call expression
4893 Make_Function_Call
(Loc
,
4897 (Specification
(Last
(Decls
))), Loc
));
4901 Need_Extra_Constrained
:=
4902 Nkind
(Parameter_Type
(Current_Parameter
)) /=
4905 Ekind
(Defining_Identifier
(Current_Parameter
)) /= E_Void
4907 Present
(Extra_Constrained
4908 (Defining_Identifier
(Current_Parameter
)));
4910 -- We may not associate an extra constrained actual to a
4911 -- constant object, so if one is needed, declare the actual
4912 -- as a variable even if it won't be modified.
4914 Build_Actual_Object_Declaration
4917 Variable
=> Need_Extra_Constrained
4918 or else Out_Present
(Current_Parameter
),
4922 -- An out parameter may be written back using a 'Write
4923 -- attribute instead of a 'Output because it has been
4924 -- constrained by the parameter given to the caller. Note that
4925 -- out controlling arguments in the case of a RACW are not put
4926 -- back in the stream because the pointer on them has not
4929 if Out_Present
(Current_Parameter
)
4931 Etype
(Parameter_Type
(Current_Parameter
)) /= Stub_Type
4933 Append_To
(After_Statements
,
4934 Make_Attribute_Reference
(Loc
,
4935 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
4936 Attribute_Name
=> Name_Write
,
4937 Expressions
=> New_List
(
4938 Make_Selected_Component
(Loc
,
4939 Prefix
=> Request_Parameter
,
4940 Selector_Name
=> Name_Result
),
4941 New_Occurrence_Of
(Object
, Loc
))));
4944 -- For RACW controlling formals, the Etyp of Object is always
4945 -- an RACW, even if the parameter is not of an anonymous access
4946 -- type. In such case, we need to dereference it at call time.
4948 if Is_Controlling_Formal
then
4949 if Nkind
(Parameter_Type
(Current_Parameter
)) /=
4952 Append_To
(Parameter_List
,
4953 Make_Parameter_Association
(Loc
,
4956 Defining_Identifier
(Current_Parameter
), Loc
),
4957 Explicit_Actual_Parameter
=>
4958 Make_Explicit_Dereference
(Loc
,
4959 Unchecked_Convert_To
(RACW_Type
,
4960 OK_Convert_To
(RTE
(RE_Address
),
4961 New_Occurrence_Of
(Object
, Loc
))))));
4964 Append_To
(Parameter_List
,
4965 Make_Parameter_Association
(Loc
,
4968 Defining_Identifier
(Current_Parameter
), Loc
),
4969 Explicit_Actual_Parameter
=>
4970 Unchecked_Convert_To
(RACW_Type
,
4971 OK_Convert_To
(RTE
(RE_Address
),
4972 New_Occurrence_Of
(Object
, Loc
)))));
4976 Append_To
(Parameter_List
,
4977 Make_Parameter_Association
(Loc
,
4980 Defining_Identifier
(Current_Parameter
), Loc
),
4981 Explicit_Actual_Parameter
=>
4982 New_Occurrence_Of
(Object
, Loc
)));
4985 -- If the current parameter needs an extra formal, then read it
4986 -- from the stream and set the corresponding semantic field in
4987 -- the variable. If the kind of the parameter identifier is
4988 -- E_Void, then this is a compiler generated parameter that
4989 -- doesn't need an extra constrained status.
4991 -- The case of Extra_Accessibility should also be handled ???
4993 if Need_Extra_Constrained
then
4995 Extra_Parameter
: constant Entity_Id
:=
4997 (Defining_Identifier
4998 (Current_Parameter
));
5000 Formal_Entity
: constant Entity_Id
:=
5001 Make_Defining_Identifier
5002 (Loc
, Chars
(Extra_Parameter
));
5004 Formal_Type
: constant Entity_Id
:=
5005 Etype
(Extra_Parameter
);
5009 Make_Object_Declaration
(Loc
,
5010 Defining_Identifier
=> Formal_Entity
,
5011 Object_Definition
=>
5012 New_Occurrence_Of
(Formal_Type
, Loc
)));
5014 Append_To
(Extra_Formal_Statements
,
5015 Make_Attribute_Reference
(Loc
,
5016 Prefix
=> New_Occurrence_Of
(
5018 Attribute_Name
=> Name_Read
,
5019 Expressions
=> New_List
(
5020 Make_Selected_Component
(Loc
,
5021 Prefix
=> Request_Parameter
,
5022 Selector_Name
=> Name_Params
),
5023 New_Occurrence_Of
(Formal_Entity
, Loc
))));
5025 -- Note: the call to Set_Extra_Constrained below relies
5026 -- on the fact that Object's Ekind has been set by
5027 -- Build_Actual_Object_Declaration.
5029 Set_Extra_Constrained
(Object
, Formal_Entity
);
5034 Next
(Current_Parameter
);
5037 -- Append the formal statements list at the end of regular statements
5039 Append_List_To
(Statements
, Extra_Formal_Statements
);
5041 if Nkind
(Specification
(Vis_Decl
)) = N_Function_Specification
then
5043 -- The remote subprogram is a function. We build an inner block to
5044 -- be able to hold a potentially unconstrained result in a
5048 Etyp
: constant Entity_Id
:=
5049 Etype
(Result_Definition
(Specification
(Vis_Decl
)));
5050 Result
: constant Node_Id
:= Make_Temporary
(Loc
, 'R');
5053 Inner_Decls
:= New_List
(
5054 Make_Object_Declaration
(Loc
,
5055 Defining_Identifier
=> Result
,
5056 Constant_Present
=> True,
5057 Object_Definition
=> New_Occurrence_Of
(Etyp
, Loc
),
5059 Make_Function_Call
(Loc
,
5060 Name
=> Called_Subprogram
,
5061 Parameter_Associations
=> Parameter_List
)));
5063 if Is_Class_Wide_Type
(Etyp
) then
5065 -- For a remote call to a function with a class-wide type,
5066 -- check that the returned value satisfies the requirements
5069 Append_To
(Inner_Decls
,
5070 Make_Transportable_Check
(Loc
,
5071 New_Occurrence_Of
(Result
, Loc
)));
5075 Append_To
(After_Statements
,
5076 Make_Attribute_Reference
(Loc
,
5077 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
5078 Attribute_Name
=> Name_Output
,
5079 Expressions
=> New_List
(
5080 Make_Selected_Component
(Loc
,
5081 Prefix
=> Request_Parameter
,
5082 Selector_Name
=> Name_Result
),
5083 New_Occurrence_Of
(Result
, Loc
))));
5086 Append_To
(Statements
,
5087 Make_Block_Statement
(Loc
,
5088 Declarations
=> Inner_Decls
,
5089 Handled_Statement_Sequence
=>
5090 Make_Handled_Sequence_Of_Statements
(Loc
,
5091 Statements
=> After_Statements
)));
5094 -- The remote subprogram is a procedure. We do not need any inner
5095 -- block in this case.
5097 if Dynamically_Asynchronous
then
5099 Make_Object_Declaration
(Loc
,
5100 Defining_Identifier
=> Dynamic_Async
,
5101 Object_Definition
=>
5102 New_Occurrence_Of
(Standard_Boolean
, Loc
)));
5104 Append_To
(Statements
,
5105 Make_Attribute_Reference
(Loc
,
5106 Prefix
=> New_Occurrence_Of
(Standard_Boolean
, Loc
),
5107 Attribute_Name
=> Name_Read
,
5108 Expressions
=> New_List
(
5109 Make_Selected_Component
(Loc
,
5110 Prefix
=> Request_Parameter
,
5111 Selector_Name
=> Name_Params
),
5112 New_Occurrence_Of
(Dynamic_Async
, Loc
))));
5115 Append_To
(Statements
,
5116 Make_Procedure_Call_Statement
(Loc
,
5117 Name
=> Called_Subprogram
,
5118 Parameter_Associations
=> Parameter_List
));
5120 Append_List_To
(Statements
, After_Statements
);
5123 if Asynchronous
and then not Dynamically_Asynchronous
then
5125 -- For an asynchronous procedure, add a null exception handler
5127 Excep_Handlers
:= New_List
(
5128 Make_Implicit_Exception_Handler
(Loc
,
5129 Exception_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
5130 Statements
=> New_List
(Make_Null_Statement
(Loc
))));
5133 -- In the other cases, if an exception is raised, then the
5134 -- exception occurrence is copied into the output stream and
5135 -- no other output parameter is written.
5137 Excep_Choice
:= Make_Temporary
(Loc
, 'E');
5139 Excep_Code
:= New_List
(
5140 Make_Attribute_Reference
(Loc
,
5142 New_Occurrence_Of
(RTE
(RE_Exception_Occurrence
), Loc
),
5143 Attribute_Name
=> Name_Write
,
5144 Expressions
=> New_List
(
5145 Make_Selected_Component
(Loc
,
5146 Prefix
=> Request_Parameter
,
5147 Selector_Name
=> Name_Result
),
5148 New_Occurrence_Of
(Excep_Choice
, Loc
))));
5150 if Dynamically_Asynchronous
then
5151 Excep_Code
:= New_List
(
5152 Make_Implicit_If_Statement
(Vis_Decl
,
5153 Condition
=> Make_Op_Not
(Loc
,
5154 New_Occurrence_Of
(Dynamic_Async
, Loc
)),
5155 Then_Statements
=> Excep_Code
));
5158 Excep_Handlers
:= New_List
(
5159 Make_Implicit_Exception_Handler
(Loc
,
5160 Choice_Parameter
=> Excep_Choice
,
5161 Exception_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
5162 Statements
=> Excep_Code
));
5167 Make_Procedure_Specification
(Loc
,
5168 Defining_Unit_Name
=> Make_Temporary
(Loc
, 'F'),
5170 Parameter_Specifications
=> New_List
(
5171 Make_Parameter_Specification
(Loc
,
5172 Defining_Identifier
=> Request_Parameter
,
5174 New_Occurrence_Of
(RTE
(RE_Request_Access
), Loc
))));
5177 Make_Subprogram_Body
(Loc
,
5178 Specification
=> Subp_Spec
,
5179 Declarations
=> Decls
,
5180 Handled_Statement_Sequence
=>
5181 Make_Handled_Sequence_Of_Statements
(Loc
,
5182 Statements
=> Statements
,
5183 Exception_Handlers
=> Excep_Handlers
));
5184 end Build_Subprogram_Receiving_Stubs
;
5190 function Result
return Node_Id
is
5192 return Make_Identifier
(Loc
, Name_V
);
5195 -----------------------
5196 -- RPC_Receiver_Decl --
5197 -----------------------
5199 function RPC_Receiver_Decl
(RACW_Type
: Entity_Id
) return Node_Id
is
5200 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
5201 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
5204 -- No RPC receiver for remote access-to-subprogram
5211 Make_Subprogram_Declaration
(Loc
,
5212 Build_RPC_Receiver_Specification
5213 (RPC_Receiver
=> Make_Temporary
(Loc
, 'R'),
5214 Request_Parameter
=> Make_Defining_Identifier
(Loc
, Name_R
)));
5215 end RPC_Receiver_Decl
;
5217 ----------------------
5218 -- Stream_Parameter --
5219 ----------------------
5221 function Stream_Parameter
return Node_Id
is
5223 return Make_Identifier
(Loc
, Name_S
);
5224 end Stream_Parameter
;
5228 -------------------------------
5229 -- Get_And_Reset_RACW_Bodies --
5230 -------------------------------
5232 function Get_And_Reset_RACW_Bodies
(RACW_Type
: Entity_Id
) return List_Id
is
5233 Desig
: constant Entity_Id
:=
5234 Etype
(Designated_Type
(RACW_Type
));
5236 Stub_Elements
: Stub_Structure
:= Stubs_Table
.Get
(Desig
);
5238 Body_Decls
: List_Id
;
5239 -- Returned list of declarations
5242 if Stub_Elements
= Empty_Stub_Structure
then
5244 -- Stub elements may be missing as a consequence of a previously
5250 Body_Decls
:= Stub_Elements
.Body_Decls
;
5251 Stub_Elements
.Body_Decls
:= No_List
;
5252 Stubs_Table
.Set
(Desig
, Stub_Elements
);
5254 end Get_And_Reset_RACW_Bodies
;
5256 -----------------------
5257 -- Get_Stub_Elements --
5258 -----------------------
5260 function Get_Stub_Elements
(RACW_Type
: Entity_Id
) return Stub_Structure
is
5261 Desig
: constant Entity_Id
:=
5262 Etype
(Designated_Type
(RACW_Type
));
5263 Stub_Elements
: constant Stub_Structure
:= Stubs_Table
.Get
(Desig
);
5265 pragma Assert
(Stub_Elements
/= Empty_Stub_Structure
);
5266 return Stub_Elements
;
5267 end Get_Stub_Elements
;
5269 -----------------------
5270 -- Get_Subprogram_Id --
5271 -----------------------
5273 function Get_Subprogram_Id
(Def
: Entity_Id
) return String_Id
is
5274 Result
: constant String_Id
:= Get_Subprogram_Ids
(Def
).Str_Identifier
;
5276 pragma Assert
(Result
/= No_String
);
5278 end Get_Subprogram_Id
;
5280 -----------------------
5281 -- Get_Subprogram_Id --
5282 -----------------------
5284 function Get_Subprogram_Id
(Def
: Entity_Id
) return Int
is
5286 return Get_Subprogram_Ids
(Def
).Int_Identifier
;
5287 end Get_Subprogram_Id
;
5289 ------------------------
5290 -- Get_Subprogram_Ids --
5291 ------------------------
5293 function Get_Subprogram_Ids
5294 (Def
: Entity_Id
) return Subprogram_Identifiers
5297 return Subprogram_Identifier_Table
.Get
(Def
);
5298 end Get_Subprogram_Ids
;
5304 function Hash
(F
: Entity_Id
) return Hash_Index
is
5306 return Hash_Index
(Natural (F
) mod Positive (Hash_Index
'Last + 1));
5309 function Hash
(F
: Name_Id
) return Hash_Index
is
5311 return Hash_Index
(Natural (F
) mod Positive (Hash_Index
'Last + 1));
5314 --------------------------
5315 -- Input_With_Tag_Check --
5316 --------------------------
5318 function Input_With_Tag_Check
5320 Var_Type
: Entity_Id
;
5321 Stream
: Node_Id
) return Node_Id
5325 Make_Subprogram_Body
(Loc
,
5327 Make_Function_Specification
(Loc
,
5328 Defining_Unit_Name
=> Make_Temporary
(Loc
, 'S'),
5329 Result_Definition
=> New_Occurrence_Of
(Var_Type
, Loc
)),
5330 Declarations
=> No_List
,
5331 Handled_Statement_Sequence
=>
5332 Make_Handled_Sequence_Of_Statements
(Loc
, New_List
(
5333 Make_Tag_Check
(Loc
,
5334 Make_Simple_Return_Statement
(Loc
,
5335 Make_Attribute_Reference
(Loc
,
5336 Prefix
=> New_Occurrence_Of
(Var_Type
, Loc
),
5337 Attribute_Name
=> Name_Input
,
5339 New_List
(Stream
)))))));
5340 end Input_With_Tag_Check
;
5342 --------------------------------
5343 -- Is_RACW_Controlling_Formal --
5344 --------------------------------
5346 function Is_RACW_Controlling_Formal
5347 (Parameter
: Node_Id
;
5348 Stub_Type
: Entity_Id
) return Boolean
5353 -- If the kind of the parameter is E_Void, then it is not a controlling
5354 -- formal (this can happen in the context of RAS).
5356 if Ekind
(Defining_Identifier
(Parameter
)) = E_Void
then
5360 -- If the parameter is not a controlling formal, then it cannot be
5361 -- possibly a RACW_Controlling_Formal.
5363 if not Is_Controlling_Formal
(Defining_Identifier
(Parameter
)) then
5367 Typ
:= Parameter_Type
(Parameter
);
5368 return (Nkind
(Typ
) = N_Access_Definition
5369 and then Etype
(Subtype_Mark
(Typ
)) = Stub_Type
)
5370 or else Etype
(Typ
) = Stub_Type
;
5371 end Is_RACW_Controlling_Formal
;
5373 ------------------------------
5374 -- Make_Transportable_Check --
5375 ------------------------------
5377 function Make_Transportable_Check
5379 Expr
: Node_Id
) return Node_Id
is
5382 Make_Raise_Program_Error
(Loc
,
5385 Build_Get_Transportable
(Loc
,
5386 Make_Selected_Component
(Loc
,
5388 Selector_Name
=> Make_Identifier
(Loc
, Name_uTag
)))),
5389 Reason
=> PE_Non_Transportable_Actual
);
5390 end Make_Transportable_Check
;
5392 -----------------------------
5393 -- Make_Selected_Component --
5394 -----------------------------
5396 function Make_Selected_Component
5399 Selector_Name
: Name_Id
) return Node_Id
5402 return Make_Selected_Component
(Loc
,
5403 Prefix
=> New_Occurrence_Of
(Prefix
, Loc
),
5404 Selector_Name
=> Make_Identifier
(Loc
, Selector_Name
));
5405 end Make_Selected_Component
;
5407 --------------------
5408 -- Make_Tag_Check --
5409 --------------------
5411 function Make_Tag_Check
(Loc
: Source_Ptr
; N
: Node_Id
) return Node_Id
is
5412 Occ
: constant Entity_Id
:= Make_Temporary
(Loc
, 'E');
5415 return Make_Block_Statement
(Loc
,
5416 Handled_Statement_Sequence
=>
5417 Make_Handled_Sequence_Of_Statements
(Loc
,
5418 Statements
=> New_List
(N
),
5420 Exception_Handlers
=> New_List
(
5421 Make_Implicit_Exception_Handler
(Loc
,
5422 Choice_Parameter
=> Occ
,
5424 Exception_Choices
=>
5425 New_List
(New_Occurrence_Of
(RTE
(RE_Tag_Error
), Loc
)),
5428 New_List
(Make_Procedure_Call_Statement
(Loc
,
5430 (RTE
(RE_Raise_Program_Error_Unknown_Tag
), Loc
),
5431 New_List
(New_Occurrence_Of
(Occ
, Loc
))))))));
5434 ----------------------------
5435 -- Need_Extra_Constrained --
5436 ----------------------------
5438 function Need_Extra_Constrained
(Parameter
: Node_Id
) return Boolean is
5439 Etyp
: constant Entity_Id
:= Etype
(Parameter_Type
(Parameter
));
5441 return Out_Present
(Parameter
)
5442 and then Has_Discriminants
(Etyp
)
5443 and then not Is_Constrained
(Etyp
)
5444 and then Is_Definite_Subtype
(Etyp
);
5445 end Need_Extra_Constrained
;
5447 ------------------------------------
5448 -- Pack_Entity_Into_Stream_Access --
5449 ------------------------------------
5451 function Pack_Entity_Into_Stream_Access
5455 Etyp
: Entity_Id
:= Empty
) return Node_Id
5460 if Present
(Etyp
) then
5463 Typ
:= Etype
(Object
);
5467 Pack_Node_Into_Stream_Access
(Loc
,
5469 Object
=> New_Occurrence_Of
(Object
, Loc
),
5471 end Pack_Entity_Into_Stream_Access
;
5473 ---------------------------
5474 -- Pack_Node_Into_Stream --
5475 ---------------------------
5477 function Pack_Node_Into_Stream
5481 Etyp
: Entity_Id
) return Node_Id
5483 Write_Attribute
: Name_Id
:= Name_Write
;
5486 if not Is_Constrained
(Etyp
) then
5487 Write_Attribute
:= Name_Output
;
5491 Make_Attribute_Reference
(Loc
,
5492 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
5493 Attribute_Name
=> Write_Attribute
,
5494 Expressions
=> New_List
(
5495 Make_Attribute_Reference
(Loc
,
5496 Prefix
=> New_Occurrence_Of
(Stream
, Loc
),
5497 Attribute_Name
=> Name_Access
),
5499 end Pack_Node_Into_Stream
;
5501 ----------------------------------
5502 -- Pack_Node_Into_Stream_Access --
5503 ----------------------------------
5505 function Pack_Node_Into_Stream_Access
5509 Etyp
: Entity_Id
) return Node_Id
5511 Write_Attribute
: Name_Id
:= Name_Write
;
5514 if not Is_Constrained
(Etyp
) then
5515 Write_Attribute
:= Name_Output
;
5519 Make_Attribute_Reference
(Loc
,
5520 Prefix
=> New_Occurrence_Of
(Etyp
, Loc
),
5521 Attribute_Name
=> Write_Attribute
,
5522 Expressions
=> New_List
(
5525 end Pack_Node_Into_Stream_Access
;
5527 ---------------------
5528 -- PolyORB_Support --
5529 ---------------------
5531 package body PolyORB_Support
is
5533 -- Local subprograms
5535 procedure Add_RACW_Read_Attribute
5536 (RACW_Type
: Entity_Id
;
5537 Stub_Type
: Entity_Id
;
5538 Stub_Type_Access
: Entity_Id
;
5539 Body_Decls
: List_Id
);
5540 -- Add Read attribute for the RACW type. The declaration and attribute
5541 -- definition clauses are inserted right after the declaration of
5542 -- RACW_Type. If Body_Decls is not No_List, the subprogram body is
5543 -- appended to it (case where the RACW declaration is in the main unit).
5545 procedure Add_RACW_Write_Attribute
5546 (RACW_Type
: Entity_Id
;
5547 Stub_Type
: Entity_Id
;
5548 Stub_Type_Access
: Entity_Id
;
5549 Body_Decls
: List_Id
);
5550 -- Same as above for the Write attribute
5552 procedure Add_RACW_From_Any
5553 (RACW_Type
: Entity_Id
;
5554 Body_Decls
: List_Id
);
5555 -- Add the From_Any TSS for this RACW type
5557 procedure Add_RACW_To_Any
5558 (RACW_Type
: Entity_Id
;
5559 Body_Decls
: List_Id
);
5560 -- Add the To_Any TSS for this RACW type
5562 procedure Add_RACW_TypeCode
5563 (Designated_Type
: Entity_Id
;
5564 RACW_Type
: Entity_Id
;
5565 Body_Decls
: List_Id
);
5566 -- Add the TypeCode TSS for this RACW type
5568 procedure Add_RAS_From_Any
(RAS_Type
: Entity_Id
);
5569 -- Add the From_Any TSS for this RAS type
5571 procedure Add_RAS_To_Any
(RAS_Type
: Entity_Id
);
5572 -- Add the To_Any TSS for this RAS type
5574 procedure Add_RAS_TypeCode
(RAS_Type
: Entity_Id
);
5575 -- Add the TypeCode TSS for this RAS type
5577 procedure Add_RAS_Access_TSS
(N
: Node_Id
);
5578 -- Add a subprogram body for RAS Access TSS
5580 -------------------------------------
5581 -- Add_Obj_RPC_Receiver_Completion --
5582 -------------------------------------
5584 procedure Add_Obj_RPC_Receiver_Completion
5587 RPC_Receiver
: Entity_Id
;
5588 Stub_Elements
: Stub_Structure
)
5590 Desig
: constant Entity_Id
:=
5591 Etype
(Designated_Type
(Stub_Elements
.RACW_Type
));
5594 Make_Procedure_Call_Statement
(Loc
,
5597 RTE
(RE_Register_Obj_Receiving_Stub
), Loc
),
5599 Parameter_Associations
=> New_List
(
5603 Make_String_Literal
(Loc
,
5604 Fully_Qualified_Name_String
(Desig
, Append_NUL
=> False)),
5608 Make_Attribute_Reference
(Loc
,
5611 Defining_Unit_Name
(Parent
(RPC_Receiver
)), Loc
),
5617 Make_Attribute_Reference
(Loc
,
5620 Defining_Identifier
(
5621 Stub_Elements
.RPC_Receiver_Decl
), Loc
),
5624 end Add_Obj_RPC_Receiver_Completion
;
5626 -----------------------
5627 -- Add_RACW_Features --
5628 -----------------------
5630 procedure Add_RACW_Features
5631 (RACW_Type
: Entity_Id
;
5633 Stub_Type
: Entity_Id
;
5634 Stub_Type_Access
: Entity_Id
;
5635 RPC_Receiver_Decl
: Node_Id
;
5636 Body_Decls
: List_Id
)
5638 pragma Unreferenced
(RPC_Receiver_Decl
);
5642 (RACW_Type
=> RACW_Type
,
5643 Body_Decls
=> Body_Decls
);
5646 (RACW_Type
=> RACW_Type
,
5647 Body_Decls
=> Body_Decls
);
5649 Add_RACW_Write_Attribute
5650 (RACW_Type
=> RACW_Type
,
5651 Stub_Type
=> Stub_Type
,
5652 Stub_Type_Access
=> Stub_Type_Access
,
5653 Body_Decls
=> Body_Decls
);
5655 Add_RACW_Read_Attribute
5656 (RACW_Type
=> RACW_Type
,
5657 Stub_Type
=> Stub_Type
,
5658 Stub_Type_Access
=> Stub_Type_Access
,
5659 Body_Decls
=> Body_Decls
);
5662 (Designated_Type
=> Desig
,
5663 RACW_Type
=> RACW_Type
,
5664 Body_Decls
=> Body_Decls
);
5665 end Add_RACW_Features
;
5667 -----------------------
5668 -- Add_RACW_From_Any --
5669 -----------------------
5671 procedure Add_RACW_From_Any
5672 (RACW_Type
: Entity_Id
;
5673 Body_Decls
: List_Id
)
5675 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
5676 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
5677 Fnam
: constant Entity_Id
:=
5678 Make_Defining_Identifier
(Loc
,
5679 Chars
=> New_External_Name
(Chars
(RACW_Type
), 'F'));
5681 Func_Spec
: Node_Id
;
5682 Func_Decl
: Node_Id
;
5683 Func_Body
: Node_Id
;
5685 Statements
: List_Id
;
5686 -- Various parts of the subprogram
5688 Any_Parameter
: constant Entity_Id
:=
5689 Make_Defining_Identifier
(Loc
, Name_A
);
5691 Asynchronous_Flag
: constant Entity_Id
:=
5692 Asynchronous_Flags_Table
.Get
(RACW_Type
);
5693 -- The flag object declared in Add_RACW_Asynchronous_Flag
5697 Make_Function_Specification
(Loc
,
5698 Defining_Unit_Name
=>
5700 Parameter_Specifications
=> New_List
(
5701 Make_Parameter_Specification
(Loc
,
5702 Defining_Identifier
=>
5705 New_Occurrence_Of
(RTE
(RE_Any
), Loc
))),
5706 Result_Definition
=> New_Occurrence_Of
(RACW_Type
, Loc
));
5708 -- NOTE: The usage occurrences of RACW_Parameter must refer to the
5709 -- entity in the declaration spec, not those of the body spec.
5711 Func_Decl
:= Make_Subprogram_Declaration
(Loc
, Func_Spec
);
5712 Insert_After
(Declaration_Node
(RACW_Type
), Func_Decl
);
5713 Set_Renaming_TSS
(RACW_Type
, Fnam
, TSS_From_Any
);
5715 if No
(Body_Decls
) then
5719 -- ??? Issue with asynchronous calls here: the Asynchronous flag is
5720 -- set on the stub type if, and only if, the RACW type has a pragma
5721 -- Asynchronous. This is incorrect for RACWs that implement RAS
5722 -- types, because in that case the /designated subprogram/ (not the
5723 -- type) might be asynchronous, and that causes the stub to need to
5724 -- be asynchronous too. A solution is to transport a RAS as a struct
5725 -- containing a RACW and an asynchronous flag, and to properly alter
5726 -- the Asynchronous component in the stub type in the RAS's _From_Any
5729 Statements
:= New_List
(
5730 Make_Simple_Return_Statement
(Loc
,
5731 Expression
=> Unchecked_Convert_To
(RACW_Type
,
5732 Make_Function_Call
(Loc
,
5733 Name
=> New_Occurrence_Of
(RTE
(RE_Get_RACW
), Loc
),
5734 Parameter_Associations
=> New_List
(
5735 Make_Function_Call
(Loc
,
5736 Name
=> New_Occurrence_Of
(RTE
(RE_FA_ObjRef
), Loc
),
5737 Parameter_Associations
=> New_List
(
5738 New_Occurrence_Of
(Any_Parameter
, Loc
))),
5739 Build_Stub_Tag
(Loc
, RACW_Type
),
5740 New_Occurrence_Of
(Boolean_Literals
(Is_RAS
), Loc
),
5741 New_Occurrence_Of
(Asynchronous_Flag
, Loc
))))));
5744 Make_Subprogram_Body
(Loc
,
5745 Specification
=> Copy_Specification
(Loc
, Func_Spec
),
5746 Declarations
=> No_List
,
5747 Handled_Statement_Sequence
=>
5748 Make_Handled_Sequence_Of_Statements
(Loc
,
5749 Statements
=> Statements
));
5751 Append_To
(Body_Decls
, Func_Body
);
5752 end Add_RACW_From_Any
;
5754 -----------------------------
5755 -- Add_RACW_Read_Attribute --
5756 -----------------------------
5758 procedure Add_RACW_Read_Attribute
5759 (RACW_Type
: Entity_Id
;
5760 Stub_Type
: Entity_Id
;
5761 Stub_Type_Access
: Entity_Id
;
5762 Body_Decls
: List_Id
)
5764 pragma Unreferenced
(Stub_Type
, Stub_Type_Access
);
5766 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
5768 Proc_Decl
: Node_Id
;
5769 Attr_Decl
: Node_Id
;
5771 Body_Node
: Node_Id
;
5773 Decls
: constant List_Id
:= New_List
;
5774 Statements
: constant List_Id
:= New_List
;
5775 Reference
: constant Entity_Id
:=
5776 Make_Defining_Identifier
(Loc
, Name_R
);
5777 -- Various parts of the procedure
5779 Pnam
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
5781 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
5783 Asynchronous_Flag
: constant Entity_Id
:=
5784 Asynchronous_Flags_Table
.Get
(RACW_Type
);
5785 pragma Assert
(Present
(Asynchronous_Flag
));
5787 function Stream_Parameter
return Node_Id
;
5788 function Result
return Node_Id
;
5790 -- Functions to create occurrences of the formal parameter names
5796 function Result
return Node_Id
is
5798 return Make_Identifier
(Loc
, Name_V
);
5801 ----------------------
5802 -- Stream_Parameter --
5803 ----------------------
5805 function Stream_Parameter
return Node_Id
is
5807 return Make_Identifier
(Loc
, Name_S
);
5808 end Stream_Parameter
;
5810 -- Start of processing for Add_RACW_Read_Attribute
5813 Build_Stream_Procedure
5814 (Loc
, RACW_Type
, Body_Node
, Pnam
, Statements
, Outp
=> True);
5816 Proc_Decl
:= Make_Subprogram_Declaration
(Loc
,
5817 Copy_Specification
(Loc
, Specification
(Body_Node
)));
5820 Make_Attribute_Definition_Clause
(Loc
,
5821 Name
=> New_Occurrence_Of
(RACW_Type
, Loc
),
5825 Defining_Unit_Name
(Specification
(Proc_Decl
)), Loc
));
5827 Insert_After
(Declaration_Node
(RACW_Type
), Proc_Decl
);
5828 Insert_After
(Proc_Decl
, Attr_Decl
);
5830 if No
(Body_Decls
) then
5835 Make_Object_Declaration
(Loc
,
5836 Defining_Identifier
=>
5838 Object_Definition
=>
5839 New_Occurrence_Of
(RTE
(RE_Object_Ref
), Loc
)));
5841 Append_List_To
(Statements
, New_List
(
5842 Make_Attribute_Reference
(Loc
,
5844 New_Occurrence_Of
(RTE
(RE_Object_Ref
), Loc
),
5845 Attribute_Name
=> Name_Read
,
5846 Expressions
=> New_List
(
5848 New_Occurrence_Of
(Reference
, Loc
))),
5850 Make_Assignment_Statement
(Loc
,
5854 Unchecked_Convert_To
(RACW_Type
,
5855 Make_Function_Call
(Loc
,
5857 New_Occurrence_Of
(RTE
(RE_Get_RACW
), Loc
),
5858 Parameter_Associations
=> New_List
(
5859 New_Occurrence_Of
(Reference
, Loc
),
5860 Build_Stub_Tag
(Loc
, RACW_Type
),
5861 New_Occurrence_Of
(Boolean_Literals
(Is_RAS
), Loc
),
5862 New_Occurrence_Of
(Asynchronous_Flag
, Loc
)))))));
5864 Set_Declarations
(Body_Node
, Decls
);
5865 Append_To
(Body_Decls
, Body_Node
);
5866 end Add_RACW_Read_Attribute
;
5868 ---------------------
5869 -- Add_RACW_To_Any --
5870 ---------------------
5872 procedure Add_RACW_To_Any
5873 (RACW_Type
: Entity_Id
;
5874 Body_Decls
: List_Id
)
5876 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
5878 Fnam
: constant Entity_Id
:=
5879 Make_Defining_Identifier
(Loc
,
5880 Chars
=> New_External_Name
(Chars
(RACW_Type
), 'T'));
5882 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
5884 Stub_Elements
: constant Stub_Structure
:=
5885 Get_Stub_Elements
(RACW_Type
);
5887 Func_Spec
: Node_Id
;
5888 Func_Decl
: Node_Id
;
5889 Func_Body
: Node_Id
;
5892 Statements
: List_Id
;
5893 -- Various parts of the subprogram
5895 RACW_Parameter
: constant Entity_Id
:=
5896 Make_Defining_Identifier
(Loc
, Name_R
);
5898 Reference
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
5899 Any
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
5903 Make_Function_Specification
(Loc
,
5904 Defining_Unit_Name
=>
5906 Parameter_Specifications
=> New_List
(
5907 Make_Parameter_Specification
(Loc
,
5908 Defining_Identifier
=>
5911 New_Occurrence_Of
(RACW_Type
, Loc
))),
5912 Result_Definition
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
));
5914 -- NOTE: The usage occurrences of RACW_Parameter must refer to the
5915 -- entity in the declaration spec, not in the body spec.
5917 Func_Decl
:= Make_Subprogram_Declaration
(Loc
, Func_Spec
);
5919 Insert_After
(Declaration_Node
(RACW_Type
), Func_Decl
);
5920 Set_Renaming_TSS
(RACW_Type
, Fnam
, TSS_To_Any
);
5922 if No
(Body_Decls
) then
5928 -- R : constant Object_Ref :=
5934 -- RPC_Receiver'Access);
5938 Make_Object_Declaration
(Loc
,
5939 Defining_Identifier
=> Reference
,
5940 Constant_Present
=> True,
5941 Object_Definition
=>
5942 New_Occurrence_Of
(RTE
(RE_Object_Ref
), Loc
),
5944 Make_Function_Call
(Loc
,
5945 Name
=> New_Occurrence_Of
(RTE
(RE_Get_Reference
), Loc
),
5946 Parameter_Associations
=> New_List
(
5947 Unchecked_Convert_To
(RTE
(RE_Address
),
5948 New_Occurrence_Of
(RACW_Parameter
, Loc
)),
5949 Make_String_Literal
(Loc
,
5950 Strval
=> Fully_Qualified_Name_String
5951 (Etype
(Designated_Type
(RACW_Type
)),
5952 Append_NUL
=> False)),
5953 Build_Stub_Tag
(Loc
, RACW_Type
),
5954 New_Occurrence_Of
(Boolean_Literals
(Is_RAS
), Loc
),
5955 Make_Attribute_Reference
(Loc
,
5958 (Defining_Identifier
5959 (Stub_Elements
.RPC_Receiver_Decl
), Loc
),
5960 Attribute_Name
=> Name_Access
)))),
5962 Make_Object_Declaration
(Loc
,
5963 Defining_Identifier
=> Any
,
5964 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
)));
5968 -- Any := TA_ObjRef (Reference);
5969 -- Set_TC (Any, RPC_Receiver.Obj_TypeCode);
5972 Statements
:= New_List
(
5973 Make_Assignment_Statement
(Loc
,
5974 Name
=> New_Occurrence_Of
(Any
, Loc
),
5976 Make_Function_Call
(Loc
,
5977 Name
=> New_Occurrence_Of
(RTE
(RE_TA_ObjRef
), Loc
),
5978 Parameter_Associations
=> New_List
(
5979 New_Occurrence_Of
(Reference
, Loc
)))),
5981 Make_Procedure_Call_Statement
(Loc
,
5982 Name
=> New_Occurrence_Of
(RTE
(RE_Set_TC
), Loc
),
5983 Parameter_Associations
=> New_List
(
5984 New_Occurrence_Of
(Any
, Loc
),
5985 Make_Selected_Component
(Loc
,
5987 Defining_Identifier
(
5988 Stub_Elements
.RPC_Receiver_Decl
),
5989 Selector_Name
=> Name_Obj_TypeCode
))),
5991 Make_Simple_Return_Statement
(Loc
,
5992 Expression
=> New_Occurrence_Of
(Any
, Loc
)));
5995 Make_Subprogram_Body
(Loc
,
5996 Specification
=> Copy_Specification
(Loc
, Func_Spec
),
5997 Declarations
=> Decls
,
5998 Handled_Statement_Sequence
=>
5999 Make_Handled_Sequence_Of_Statements
(Loc
,
6000 Statements
=> Statements
));
6001 Append_To
(Body_Decls
, Func_Body
);
6002 end Add_RACW_To_Any
;
6004 -----------------------
6005 -- Add_RACW_TypeCode --
6006 -----------------------
6008 procedure Add_RACW_TypeCode
6009 (Designated_Type
: Entity_Id
;
6010 RACW_Type
: Entity_Id
;
6011 Body_Decls
: List_Id
)
6013 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
6015 Fnam
: constant Entity_Id
:=
6016 Make_Defining_Identifier
(Loc
,
6017 Chars
=> New_External_Name
(Chars
(RACW_Type
), 'Y'));
6019 Stub_Elements
: constant Stub_Structure
:=
6020 Stubs_Table
.Get
(Designated_Type
);
6021 pragma Assert
(Stub_Elements
/= Empty_Stub_Structure
);
6023 Func_Spec
: Node_Id
;
6024 Func_Decl
: Node_Id
;
6025 Func_Body
: Node_Id
;
6028 -- The spec for this subprogram has a dummy 'access RACW' argument,
6029 -- which serves only for overloading purposes.
6032 Make_Function_Specification
(Loc
,
6033 Defining_Unit_Name
=> Fnam
,
6034 Result_Definition
=> New_Occurrence_Of
(RTE
(RE_TypeCode
), Loc
));
6036 -- NOTE: The usage occurrences of RACW_Parameter must refer to the
6037 -- entity in the declaration spec, not those of the body spec.
6039 Func_Decl
:= Make_Subprogram_Declaration
(Loc
, Func_Spec
);
6040 Insert_After
(Declaration_Node
(RACW_Type
), Func_Decl
);
6041 Set_Renaming_TSS
(RACW_Type
, Fnam
, TSS_TypeCode
);
6043 if No
(Body_Decls
) then
6048 Make_Subprogram_Body
(Loc
,
6049 Specification
=> Copy_Specification
(Loc
, Func_Spec
),
6050 Declarations
=> Empty_List
,
6051 Handled_Statement_Sequence
=>
6052 Make_Handled_Sequence_Of_Statements
(Loc
,
6053 Statements
=> New_List
(
6054 Make_Simple_Return_Statement
(Loc
,
6056 Make_Selected_Component
(Loc
,
6059 (Stub_Elements
.RPC_Receiver_Decl
),
6060 Selector_Name
=> Name_Obj_TypeCode
)))));
6062 Append_To
(Body_Decls
, Func_Body
);
6063 end Add_RACW_TypeCode
;
6065 ------------------------------
6066 -- Add_RACW_Write_Attribute --
6067 ------------------------------
6069 procedure Add_RACW_Write_Attribute
6070 (RACW_Type
: Entity_Id
;
6071 Stub_Type
: Entity_Id
;
6072 Stub_Type_Access
: Entity_Id
;
6073 Body_Decls
: List_Id
)
6075 pragma Unreferenced
(Stub_Type
, Stub_Type_Access
);
6077 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
6079 Is_RAS
: constant Boolean := not Comes_From_Source
(RACW_Type
);
6081 Stub_Elements
: constant Stub_Structure
:=
6082 Get_Stub_Elements
(RACW_Type
);
6084 Body_Node
: Node_Id
;
6085 Proc_Decl
: Node_Id
;
6086 Attr_Decl
: Node_Id
;
6088 Statements
: constant List_Id
:= New_List
;
6089 Pnam
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
6091 function Stream_Parameter
return Node_Id
;
6092 function Object
return Node_Id
;
6093 -- Functions to create occurrences of the formal parameter names
6099 function Object
return Node_Id
is
6101 return Make_Identifier
(Loc
, Name_V
);
6104 ----------------------
6105 -- Stream_Parameter --
6106 ----------------------
6108 function Stream_Parameter
return Node_Id
is
6110 return Make_Identifier
(Loc
, Name_S
);
6111 end Stream_Parameter
;
6113 -- Start of processing for Add_RACW_Write_Attribute
6116 Build_Stream_Procedure
6117 (Loc
, RACW_Type
, Body_Node
, Pnam
, Statements
, Outp
=> False);
6120 Make_Subprogram_Declaration
(Loc
,
6121 Copy_Specification
(Loc
, Specification
(Body_Node
)));
6124 Make_Attribute_Definition_Clause
(Loc
,
6125 Name
=> New_Occurrence_Of
(RACW_Type
, Loc
),
6126 Chars
=> Name_Write
,
6129 Defining_Unit_Name
(Specification
(Proc_Decl
)), Loc
));
6131 Insert_After
(Declaration_Node
(RACW_Type
), Proc_Decl
);
6132 Insert_After
(Proc_Decl
, Attr_Decl
);
6134 if No
(Body_Decls
) then
6138 Append_To
(Statements
,
6139 Pack_Node_Into_Stream_Access
(Loc
,
6140 Stream
=> Stream_Parameter
,
6142 Make_Function_Call
(Loc
,
6143 Name
=> New_Occurrence_Of
(RTE
(RE_Get_Reference
), Loc
),
6144 Parameter_Associations
=> New_List
(
6145 Unchecked_Convert_To
(RTE
(RE_Address
), Object
),
6146 Make_String_Literal
(Loc
,
6147 Strval
=> Fully_Qualified_Name_String
6148 (Etype
(Designated_Type
(RACW_Type
)),
6149 Append_NUL
=> False)),
6150 Build_Stub_Tag
(Loc
, RACW_Type
),
6151 New_Occurrence_Of
(Boolean_Literals
(Is_RAS
), Loc
),
6152 Make_Attribute_Reference
(Loc
,
6155 (Defining_Identifier
6156 (Stub_Elements
.RPC_Receiver_Decl
), Loc
),
6157 Attribute_Name
=> Name_Access
))),
6159 Etyp
=> RTE
(RE_Object_Ref
)));
6161 Append_To
(Body_Decls
, Body_Node
);
6162 end Add_RACW_Write_Attribute
;
6164 -----------------------
6165 -- Add_RAST_Features --
6166 -----------------------
6168 procedure Add_RAST_Features
6169 (Vis_Decl
: Node_Id
;
6170 RAS_Type
: Entity_Id
)
6173 Add_RAS_Access_TSS
(Vis_Decl
);
6175 Add_RAS_From_Any
(RAS_Type
);
6176 Add_RAS_TypeCode
(RAS_Type
);
6178 -- To_Any uses TypeCode, and therefore needs to be generated last
6180 Add_RAS_To_Any
(RAS_Type
);
6181 end Add_RAST_Features
;
6183 ------------------------
6184 -- Add_RAS_Access_TSS --
6185 ------------------------
6187 procedure Add_RAS_Access_TSS
(N
: Node_Id
) is
6188 Loc
: constant Source_Ptr
:= Sloc
(N
);
6190 Ras_Type
: constant Entity_Id
:= Defining_Identifier
(N
);
6191 Fat_Type
: constant Entity_Id
:= Equivalent_Type
(Ras_Type
);
6192 -- Ras_Type is the access to subprogram type; Fat_Type is the
6193 -- corresponding record type.
6195 RACW_Type
: constant Entity_Id
:=
6196 Underlying_RACW_Type
(Ras_Type
);
6198 Stub_Elements
: constant Stub_Structure
:=
6199 Get_Stub_Elements
(RACW_Type
);
6201 Proc
: constant Entity_Id
:=
6202 Make_Defining_Identifier
(Loc
,
6203 Chars
=> Make_TSS_Name
(Ras_Type
, TSS_RAS_Access
));
6205 Proc_Spec
: Node_Id
;
6207 -- Formal parameters
6209 Package_Name
: constant Entity_Id
:=
6210 Make_Defining_Identifier
(Loc
,
6215 Subp_Id
: constant Entity_Id
:=
6216 Make_Defining_Identifier
(Loc
,
6219 -- Target subprogram
6221 Asynch_P
: constant Entity_Id
:=
6222 Make_Defining_Identifier
(Loc
,
6223 Chars
=> Name_Asynchronous
);
6224 -- Is the procedure to which the 'Access applies asynchronous?
6226 All_Calls_Remote
: constant Entity_Id
:=
6227 Make_Defining_Identifier
(Loc
,
6228 Chars
=> Name_All_Calls_Remote
);
6229 -- True if an All_Calls_Remote pragma applies to the RCI unit
6230 -- that contains the subprogram.
6232 -- Common local variables
6234 Proc_Decls
: List_Id
;
6235 Proc_Statements
: List_Id
;
6237 Subp_Ref
: constant Entity_Id
:=
6238 Make_Defining_Identifier
(Loc
, Name_R
);
6239 -- Reference that designates the target subprogram (returned
6240 -- by Get_RAS_Info).
6242 Is_Local
: constant Entity_Id
:=
6243 Make_Defining_Identifier
(Loc
, Name_L
);
6244 Local_Addr
: constant Entity_Id
:=
6245 Make_Defining_Identifier
(Loc
, Name_A
);
6246 -- For the call to Get_Local_Address
6248 Local_Stub
: constant Entity_Id
:= Make_Temporary
(Loc
, 'L');
6249 Stub_Ptr
: constant Entity_Id
:= Make_Temporary
(Loc
, 'S');
6250 -- Additional local variables for the remote case
6253 (Field_Name
: Name_Id
;
6254 Value
: Node_Id
) return Node_Id
;
6255 -- Construct an assignment that sets the named component in the
6263 (Field_Name
: Name_Id
;
6264 Value
: Node_Id
) return Node_Id
6268 Make_Assignment_Statement
(Loc
,
6270 Make_Selected_Component
(Loc
,
6272 Selector_Name
=> Field_Name
),
6273 Expression
=> Value
);
6276 -- Start of processing for Add_RAS_Access_TSS
6279 Proc_Decls
:= New_List
(
6281 -- Common declarations
6283 Make_Object_Declaration
(Loc
,
6284 Defining_Identifier
=> Subp_Ref
,
6285 Object_Definition
=>
6286 New_Occurrence_Of
(RTE
(RE_Object_Ref
), Loc
)),
6288 Make_Object_Declaration
(Loc
,
6289 Defining_Identifier
=> Is_Local
,
6290 Object_Definition
=>
6291 New_Occurrence_Of
(Standard_Boolean
, Loc
)),
6293 Make_Object_Declaration
(Loc
,
6294 Defining_Identifier
=> Local_Addr
,
6295 Object_Definition
=>
6296 New_Occurrence_Of
(RTE
(RE_Address
), Loc
)),
6298 Make_Object_Declaration
(Loc
,
6299 Defining_Identifier
=> Local_Stub
,
6300 Aliased_Present
=> True,
6301 Object_Definition
=>
6302 New_Occurrence_Of
(Stub_Elements
.Stub_Type
, Loc
)),
6304 Make_Object_Declaration
(Loc
,
6305 Defining_Identifier
=> Stub_Ptr
,
6306 Object_Definition
=>
6307 New_Occurrence_Of
(Stub_Elements
.Stub_Type_Access
, Loc
),
6309 Make_Attribute_Reference
(Loc
,
6310 Prefix
=> New_Occurrence_Of
(Local_Stub
, Loc
),
6311 Attribute_Name
=> Name_Unchecked_Access
)));
6313 Set_Etype
(Stub_Ptr
, Stub_Elements
.Stub_Type_Access
);
6314 -- Build_Get_Unique_RP_Call needs this information
6316 -- Get_RAS_Info (Pkg, Subp, R);
6317 -- Obtain a reference to the target subprogram
6319 Proc_Statements
:= New_List
(
6320 Make_Procedure_Call_Statement
(Loc
,
6321 Name
=> New_Occurrence_Of
(RTE
(RE_Get_RAS_Info
), Loc
),
6322 Parameter_Associations
=> New_List
(
6323 New_Occurrence_Of
(Package_Name
, Loc
),
6324 New_Occurrence_Of
(Subp_Id
, Loc
),
6325 New_Occurrence_Of
(Subp_Ref
, Loc
))),
6327 -- Get_Local_Address (R, L, A);
6328 -- Determine whether the subprogram is local (L), and if so
6329 -- obtain the local address of its proxy (A).
6331 Make_Procedure_Call_Statement
(Loc
,
6332 Name
=> New_Occurrence_Of
(RTE
(RE_Get_Local_Address
), Loc
),
6333 Parameter_Associations
=> New_List
(
6334 New_Occurrence_Of
(Subp_Ref
, Loc
),
6335 New_Occurrence_Of
(Is_Local
, Loc
),
6336 New_Occurrence_Of
(Local_Addr
, Loc
))));
6338 -- Note: Here we assume that the Fat_Type is a record containing just
6339 -- an access to a proxy or stub object.
6341 Append_To
(Proc_Statements
,
6345 Make_Implicit_If_Statement
(N
,
6346 Condition
=> New_Occurrence_Of
(Is_Local
, Loc
),
6348 Then_Statements
=> New_List
(
6350 -- if A.Target = null then
6352 Make_Implicit_If_Statement
(N
,
6355 Make_Selected_Component
(Loc
,
6357 Unchecked_Convert_To
6358 (RTE
(RE_RAS_Proxy_Type_Access
),
6359 New_Occurrence_Of
(Local_Addr
, Loc
)),
6360 Selector_Name
=> Make_Identifier
(Loc
, Name_Target
)),
6363 Then_Statements
=> New_List
(
6365 -- A.Target := Entity_Of (Ref);
6367 Make_Assignment_Statement
(Loc
,
6369 Make_Selected_Component
(Loc
,
6371 Unchecked_Convert_To
6372 (RTE
(RE_RAS_Proxy_Type_Access
),
6373 New_Occurrence_Of
(Local_Addr
, Loc
)),
6374 Selector_Name
=> Make_Identifier
(Loc
, Name_Target
)),
6376 Make_Function_Call
(Loc
,
6377 Name
=> New_Occurrence_Of
(RTE
(RE_Entity_Of
), Loc
),
6378 Parameter_Associations
=> New_List
(
6379 New_Occurrence_Of
(Subp_Ref
, Loc
)))),
6381 -- Inc_Usage (A.Target);
6384 Make_Procedure_Call_Statement
(Loc
,
6385 Name
=> New_Occurrence_Of
(RTE
(RE_Inc_Usage
), Loc
),
6386 Parameter_Associations
=> New_List
(
6387 Make_Selected_Component
(Loc
,
6389 Unchecked_Convert_To
6390 (RTE
(RE_RAS_Proxy_Type_Access
),
6391 New_Occurrence_Of
(Local_Addr
, Loc
)),
6393 Make_Identifier
(Loc
, Name_Target
)))))),
6395 -- if not All_Calls_Remote then
6396 -- return Fat_Type!(A);
6399 Make_Implicit_If_Statement
(N
,
6403 New_Occurrence_Of
(All_Calls_Remote
, Loc
)),
6405 Then_Statements
=> New_List
(
6406 Make_Simple_Return_Statement
(Loc
,
6408 Unchecked_Convert_To
6409 (Fat_Type
, New_Occurrence_Of
(Local_Addr
, Loc
))))))));
6411 Append_List_To
(Proc_Statements
, New_List
(
6413 -- Stub.Target := Entity_Of (Ref);
6415 Set_Field
(Name_Target
,
6416 Make_Function_Call
(Loc
,
6417 Name
=> New_Occurrence_Of
(RTE
(RE_Entity_Of
), Loc
),
6418 Parameter_Associations
=> New_List
(
6419 New_Occurrence_Of
(Subp_Ref
, Loc
)))),
6421 -- Inc_Usage (Stub.Target);
6423 Make_Procedure_Call_Statement
(Loc
,
6424 Name
=> New_Occurrence_Of
(RTE
(RE_Inc_Usage
), Loc
),
6425 Parameter_Associations
=> New_List
(
6426 Make_Selected_Component
(Loc
,
6428 Selector_Name
=> Name_Target
))),
6430 -- E.4.1(9) A remote call is asynchronous if it is a call to
6431 -- a procedure, or a call through a value of an access-to-procedure
6432 -- type, to which a pragma Asynchronous applies.
6434 -- Parameter Asynch_P is true when the procedure is asynchronous;
6435 -- Expression Asynch_T is true when the type is asynchronous.
6437 Set_Field
(Name_Asynchronous
,
6439 Left_Opnd
=> New_Occurrence_Of
(Asynch_P
, Loc
),
6442 (Boolean_Literals
(Is_Asynchronous
(Ras_Type
)), Loc
)))));
6444 Append_List_To
(Proc_Statements
,
6445 Build_Get_Unique_RP_Call
(Loc
, Stub_Ptr
, Stub_Elements
.Stub_Type
));
6447 Append_To
(Proc_Statements
,
6448 Make_Simple_Return_Statement
(Loc
,
6450 Unchecked_Convert_To
(Fat_Type
,
6451 New_Occurrence_Of
(Stub_Ptr
, Loc
))));
6454 Make_Function_Specification
(Loc
,
6455 Defining_Unit_Name
=> Proc
,
6456 Parameter_Specifications
=> New_List
(
6457 Make_Parameter_Specification
(Loc
,
6458 Defining_Identifier
=> Package_Name
,
6460 New_Occurrence_Of
(Standard_String
, Loc
)),
6462 Make_Parameter_Specification
(Loc
,
6463 Defining_Identifier
=> Subp_Id
,
6465 New_Occurrence_Of
(Standard_String
, Loc
)),
6467 Make_Parameter_Specification
(Loc
,
6468 Defining_Identifier
=> Asynch_P
,
6470 New_Occurrence_Of
(Standard_Boolean
, Loc
)),
6472 Make_Parameter_Specification
(Loc
,
6473 Defining_Identifier
=> All_Calls_Remote
,
6475 New_Occurrence_Of
(Standard_Boolean
, Loc
))),
6477 Result_Definition
=>
6478 New_Occurrence_Of
(Fat_Type
, Loc
));
6480 -- Set the kind and return type of the function to prevent
6481 -- ambiguities between Ras_Type and Fat_Type in subsequent analysis.
6483 Set_Ekind
(Proc
, E_Function
);
6484 Set_Etype
(Proc
, Fat_Type
);
6487 Make_Subprogram_Body
(Loc
,
6488 Specification
=> Proc_Spec
,
6489 Declarations
=> Proc_Decls
,
6490 Handled_Statement_Sequence
=>
6491 Make_Handled_Sequence_Of_Statements
(Loc
,
6492 Statements
=> Proc_Statements
)));
6494 Set_TSS
(Fat_Type
, Proc
);
6495 end Add_RAS_Access_TSS
;
6497 ----------------------
6498 -- Add_RAS_From_Any --
6499 ----------------------
6501 procedure Add_RAS_From_Any
(RAS_Type
: Entity_Id
) is
6502 Loc
: constant Source_Ptr
:= Sloc
(RAS_Type
);
6504 Fnam
: constant Entity_Id
:= Make_Defining_Identifier
(Loc
,
6505 Make_TSS_Name
(RAS_Type
, TSS_From_Any
));
6507 Func_Spec
: Node_Id
;
6509 Statements
: List_Id
;
6511 Any_Parameter
: constant Entity_Id
:=
6512 Make_Defining_Identifier
(Loc
, Name_A
);
6515 Statements
:= New_List
(
6516 Make_Simple_Return_Statement
(Loc
,
6518 Make_Aggregate
(Loc
,
6519 Component_Associations
=> New_List
(
6520 Make_Component_Association
(Loc
,
6521 Choices
=> New_List
(Make_Identifier
(Loc
, Name_Ras
)),
6523 PolyORB_Support
.Helpers
.Build_From_Any_Call
6524 (Underlying_RACW_Type
(RAS_Type
),
6525 New_Occurrence_Of
(Any_Parameter
, Loc
),
6529 Make_Function_Specification
(Loc
,
6530 Defining_Unit_Name
=> Fnam
,
6531 Parameter_Specifications
=> New_List
(
6532 Make_Parameter_Specification
(Loc
,
6533 Defining_Identifier
=> Any_Parameter
,
6534 Parameter_Type
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
))),
6535 Result_Definition
=> New_Occurrence_Of
(RAS_Type
, Loc
));
6538 Make_Subprogram_Body
(Loc
,
6539 Specification
=> Func_Spec
,
6540 Declarations
=> No_List
,
6541 Handled_Statement_Sequence
=>
6542 Make_Handled_Sequence_Of_Statements
(Loc
,
6543 Statements
=> Statements
)));
6544 Set_TSS
(RAS_Type
, Fnam
);
6545 end Add_RAS_From_Any
;
6547 --------------------
6548 -- Add_RAS_To_Any --
6549 --------------------
6551 procedure Add_RAS_To_Any
(RAS_Type
: Entity_Id
) is
6552 Loc
: constant Source_Ptr
:= Sloc
(RAS_Type
);
6554 Fnam
: constant Entity_Id
:= Make_Defining_Identifier
(Loc
,
6555 Make_TSS_Name
(RAS_Type
, TSS_To_Any
));
6558 Statements
: List_Id
;
6560 Func_Spec
: Node_Id
;
6562 Any
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
6563 RAS_Parameter
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
6564 RACW_Parameter
: constant Node_Id
:=
6565 Make_Selected_Component
(Loc
,
6566 Prefix
=> RAS_Parameter
,
6567 Selector_Name
=> Name_Ras
);
6570 -- Object declarations
6572 Set_Etype
(RACW_Parameter
, Underlying_RACW_Type
(RAS_Type
));
6574 Make_Object_Declaration
(Loc
,
6575 Defining_Identifier
=> Any
,
6576 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
6578 PolyORB_Support
.Helpers
.Build_To_Any_Call
6579 (Loc
, RACW_Parameter
, No_List
)));
6581 Statements
:= New_List
(
6582 Make_Procedure_Call_Statement
(Loc
,
6583 Name
=> New_Occurrence_Of
(RTE
(RE_Set_TC
), Loc
),
6584 Parameter_Associations
=> New_List
(
6585 New_Occurrence_Of
(Any
, Loc
),
6586 PolyORB_Support
.Helpers
.Build_TypeCode_Call
(Loc
,
6589 Make_Simple_Return_Statement
(Loc
,
6590 Expression
=> New_Occurrence_Of
(Any
, Loc
)));
6593 Make_Function_Specification
(Loc
,
6594 Defining_Unit_Name
=> Fnam
,
6595 Parameter_Specifications
=> New_List
(
6596 Make_Parameter_Specification
(Loc
,
6597 Defining_Identifier
=> RAS_Parameter
,
6598 Parameter_Type
=> New_Occurrence_Of
(RAS_Type
, Loc
))),
6599 Result_Definition
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
));
6602 Make_Subprogram_Body
(Loc
,
6603 Specification
=> Func_Spec
,
6604 Declarations
=> Decls
,
6605 Handled_Statement_Sequence
=>
6606 Make_Handled_Sequence_Of_Statements
(Loc
,
6607 Statements
=> Statements
)));
6608 Set_TSS
(RAS_Type
, Fnam
);
6611 ----------------------
6612 -- Add_RAS_TypeCode --
6613 ----------------------
6615 procedure Add_RAS_TypeCode
(RAS_Type
: Entity_Id
) is
6616 Loc
: constant Source_Ptr
:= Sloc
(RAS_Type
);
6618 Fnam
: constant Entity_Id
:= Make_Defining_Identifier
(Loc
,
6619 Make_TSS_Name
(RAS_Type
, TSS_TypeCode
));
6621 Func_Spec
: Node_Id
;
6622 Decls
: constant List_Id
:= New_List
;
6623 Name_String
: String_Id
;
6624 Repo_Id_String
: String_Id
;
6628 Make_Function_Specification
(Loc
,
6629 Defining_Unit_Name
=> Fnam
,
6630 Result_Definition
=> New_Occurrence_Of
(RTE
(RE_TypeCode
), Loc
));
6632 PolyORB_Support
.Helpers
.Build_Name_And_Repository_Id
6633 (RAS_Type
, Name_Str
=> Name_String
, Repo_Id_Str
=> Repo_Id_String
);
6636 Make_Subprogram_Body
(Loc
,
6637 Specification
=> Func_Spec
,
6638 Declarations
=> Decls
,
6639 Handled_Statement_Sequence
=>
6640 Make_Handled_Sequence_Of_Statements
(Loc
,
6641 Statements
=> New_List
(
6642 Make_Simple_Return_Statement
(Loc
,
6644 Make_Function_Call
(Loc
,
6646 New_Occurrence_Of
(RTE
(RE_Build_Complex_TC
), Loc
),
6647 Parameter_Associations
=> New_List
(
6648 New_Occurrence_Of
(RTE
(RE_Tk_Objref
), Loc
),
6649 Make_Aggregate
(Loc
,
6652 Make_Function_Call
(Loc
,
6655 (RTE
(RE_TA_Std_String
), Loc
),
6656 Parameter_Associations
=> New_List
(
6657 Make_String_Literal
(Loc
, Name_String
))),
6658 Make_Function_Call
(Loc
,
6661 (RTE
(RE_TA_Std_String
), Loc
),
6662 Parameter_Associations
=> New_List
(
6663 Make_String_Literal
(Loc
,
6664 Strval
=> Repo_Id_String
))))))))))));
6665 Set_TSS
(RAS_Type
, Fnam
);
6666 end Add_RAS_TypeCode
;
6668 -----------------------------------------
6669 -- Add_Receiving_Stubs_To_Declarations --
6670 -----------------------------------------
6672 procedure Add_Receiving_Stubs_To_Declarations
6673 (Pkg_Spec
: Node_Id
;
6677 Loc
: constant Source_Ptr
:= Sloc
(Pkg_Spec
);
6679 Pkg_RPC_Receiver
: constant Entity_Id
:=
6680 Make_Temporary
(Loc
, 'H');
6681 Pkg_RPC_Receiver_Object
: Node_Id
;
6682 Pkg_RPC_Receiver_Body
: Node_Id
;
6683 Pkg_RPC_Receiver_Decls
: List_Id
;
6684 Pkg_RPC_Receiver_Statements
: List_Id
;
6686 Pkg_RPC_Receiver_Cases
: constant List_Id
:= New_List
;
6687 -- A Pkg_RPC_Receiver is built to decode the request
6690 -- Request object received from neutral layer
6692 Subp_Id
: Entity_Id
;
6693 -- Subprogram identifier as received from the neutral distribution
6696 Subp_Index
: Entity_Id
;
6697 -- Internal index as determined by matching either the method name
6698 -- from the request structure, or the local subprogram address (in
6701 Is_Local
: constant Entity_Id
:= Make_Temporary
(Loc
, 'L');
6703 Local_Address
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
6704 -- Address of a local subprogram designated by a reference
6705 -- corresponding to a RAS.
6707 Dispatch_On_Address
: constant List_Id
:= New_List
;
6708 Dispatch_On_Name
: constant List_Id
:= New_List
;
6710 Current_Subp_Number
: Int
:= First_RCI_Subprogram_Id
;
6712 Subp_Info_Array
: constant Entity_Id
:= Make_Temporary
(Loc
, 'I');
6713 Subp_Info_List
: constant List_Id
:= New_List
;
6715 Register_Pkg_Actuals
: constant List_Id
:= New_List
;
6717 All_Calls_Remote_E
: Entity_Id
;
6719 procedure Append_Stubs_To
6720 (RPC_Receiver_Cases
: List_Id
;
6721 Declaration
: Node_Id
;
6724 Subp_Dist_Name
: Entity_Id
;
6725 Subp_Proxy_Addr
: Entity_Id
);
6726 -- Add one case to the specified RPC receiver case list associating
6727 -- Subprogram_Number with the subprogram declared by Declaration, for
6728 -- which we have receiving stubs in Stubs. Subp_Number is an internal
6729 -- subprogram index. Subp_Dist_Name is the string used to call the
6730 -- subprogram by name, and Subp_Dist_Addr is the address of the proxy
6731 -- object, used in the context of calls through remote
6732 -- access-to-subprogram types.
6734 procedure Visit_Subprogram
(Decl
: Node_Id
);
6735 -- Generate receiving stub for one remote subprogram
6737 ---------------------
6738 -- Append_Stubs_To --
6739 ---------------------
6741 procedure Append_Stubs_To
6742 (RPC_Receiver_Cases
: List_Id
;
6743 Declaration
: Node_Id
;
6746 Subp_Dist_Name
: Entity_Id
;
6747 Subp_Proxy_Addr
: Entity_Id
)
6749 Case_Stmts
: List_Id
;
6751 Case_Stmts
:= New_List
(
6752 Make_Procedure_Call_Statement
(Loc
,
6755 Defining_Entity
(Stubs
), Loc
),
6756 Parameter_Associations
=>
6757 New_List
(New_Occurrence_Of
(Request
, Loc
))));
6759 if Nkind
(Specification
(Declaration
)) = N_Function_Specification
6761 Is_Asynchronous
(Defining_Entity
(Specification
(Declaration
)))
6763 Append_To
(Case_Stmts
, Make_Simple_Return_Statement
(Loc
));
6766 Append_To
(RPC_Receiver_Cases
,
6767 Make_Case_Statement_Alternative
(Loc
,
6769 New_List
(Make_Integer_Literal
(Loc
, Subp_Number
)),
6770 Statements
=> Case_Stmts
));
6772 Append_To
(Dispatch_On_Name
,
6773 Make_Elsif_Part
(Loc
,
6775 Make_Function_Call
(Loc
,
6777 New_Occurrence_Of
(RTE
(RE_Caseless_String_Eq
), Loc
),
6778 Parameter_Associations
=> New_List
(
6779 New_Occurrence_Of
(Subp_Id
, Loc
),
6780 New_Occurrence_Of
(Subp_Dist_Name
, Loc
))),
6782 Then_Statements
=> New_List
(
6783 Make_Assignment_Statement
(Loc
,
6784 New_Occurrence_Of
(Subp_Index
, Loc
),
6785 Make_Integer_Literal
(Loc
, Subp_Number
)))));
6787 Append_To
(Dispatch_On_Address
,
6788 Make_Elsif_Part
(Loc
,
6791 Left_Opnd
=> New_Occurrence_Of
(Local_Address
, Loc
),
6792 Right_Opnd
=> New_Occurrence_Of
(Subp_Proxy_Addr
, Loc
)),
6794 Then_Statements
=> New_List
(
6795 Make_Assignment_Statement
(Loc
,
6796 New_Occurrence_Of
(Subp_Index
, Loc
),
6797 Make_Integer_Literal
(Loc
, Subp_Number
)))));
6798 end Append_Stubs_To
;
6800 ----------------------
6801 -- Visit_Subprogram --
6802 ----------------------
6804 procedure Visit_Subprogram
(Decl
: Node_Id
) is
6805 Loc
: constant Source_Ptr
:= Sloc
(Decl
);
6806 Spec
: constant Node_Id
:= Specification
(Decl
);
6807 Subp_Def
: constant Entity_Id
:= Defining_Unit_Name
(Spec
);
6809 Subp_Val
: String_Id
;
6811 Subp_Dist_Name
: constant Entity_Id
:=
6812 Make_Defining_Identifier
(Loc
,
6815 (Related_Id
=> Chars
(Subp_Def
),
6817 Suffix_Index
=> -1));
6819 Current_Stubs
: Node_Id
;
6820 Proxy_Obj_Addr
: Entity_Id
;
6823 -- Disable expansion of stubs if serious errors have been
6824 -- diagnosed, because otherwise some illegal remote subprogram
6825 -- declarations could cause cascaded errors in stubs.
6827 if Serious_Errors_Detected
/= 0 then
6831 -- Build receiving stub
6834 Build_Subprogram_Receiving_Stubs
6836 Asynchronous
=> Nkind
(Spec
) = N_Procedure_Specification
6837 and then Is_Asynchronous
(Subp_Def
));
6839 Append_To
(Decls
, Current_Stubs
);
6840 Analyze
(Current_Stubs
);
6844 Add_RAS_Proxy_And_Analyze
(Decls
,
6846 All_Calls_Remote_E
=> All_Calls_Remote_E
,
6847 Proxy_Object_Addr
=> Proxy_Obj_Addr
);
6849 -- Compute distribution identifier
6851 Assign_Subprogram_Identifier
6852 (Subp_Def
, Current_Subp_Number
, Subp_Val
);
6855 (Current_Subp_Number
= Get_Subprogram_Id
(Subp_Def
));
6858 Make_Object_Declaration
(Loc
,
6859 Defining_Identifier
=> Subp_Dist_Name
,
6860 Constant_Present
=> True,
6861 Object_Definition
=>
6862 New_Occurrence_Of
(Standard_String
, Loc
),
6864 Make_String_Literal
(Loc
, Subp_Val
)));
6865 Analyze
(Last
(Decls
));
6867 -- Add subprogram descriptor (RCI_Subp_Info) to the subprograms
6868 -- table for this receiver. The aggregate below must be kept
6869 -- consistent with the declaration of RCI_Subp_Info in
6870 -- System.Partition_Interface.
6872 Append_To
(Subp_Info_List
,
6873 Make_Component_Association
(Loc
,
6875 New_List
(Make_Integer_Literal
(Loc
, Current_Subp_Number
)),
6878 Make_Aggregate
(Loc
,
6879 Expressions
=> New_List
(
6883 Make_Attribute_Reference
(Loc
,
6885 New_Occurrence_Of
(Subp_Dist_Name
, Loc
),
6886 Attribute_Name
=> Name_Address
),
6890 Make_Attribute_Reference
(Loc
,
6892 New_Occurrence_Of
(Subp_Dist_Name
, Loc
),
6893 Attribute_Name
=> Name_Length
),
6897 New_Occurrence_Of
(Proxy_Obj_Addr
, Loc
)))));
6899 Append_Stubs_To
(Pkg_RPC_Receiver_Cases
,
6900 Declaration
=> Decl
,
6901 Stubs
=> Current_Stubs
,
6902 Subp_Number
=> Current_Subp_Number
,
6903 Subp_Dist_Name
=> Subp_Dist_Name
,
6904 Subp_Proxy_Addr
=> Proxy_Obj_Addr
);
6906 Current_Subp_Number
:= Current_Subp_Number
+ 1;
6907 end Visit_Subprogram
;
6909 procedure Visit_Spec
is new Build_Package_Stubs
(Visit_Subprogram
);
6911 -- Start of processing for Add_Receiving_Stubs_To_Declarations
6914 -- Building receiving stubs consist in several operations:
6916 -- - a package RPC receiver must be built. This subprogram will get
6917 -- a Subprogram_Id from the incoming stream and will dispatch the
6918 -- call to the right subprogram;
6920 -- - a receiving stub for each subprogram visible in the package
6921 -- spec. This stub will read all the parameters from the stream,
6922 -- and put the result as well as the exception occurrence in the
6925 Build_RPC_Receiver_Body
(
6926 RPC_Receiver
=> Pkg_RPC_Receiver
,
6929 Subp_Index
=> Subp_Index
,
6930 Stmts
=> Pkg_RPC_Receiver_Statements
,
6931 Decl
=> Pkg_RPC_Receiver_Body
);
6932 Pkg_RPC_Receiver_Decls
:= Declarations
(Pkg_RPC_Receiver_Body
);
6934 -- Extract local address information from the target reference:
6935 -- if non-null, that means that this is a reference that denotes
6936 -- one particular operation, and hence that the operation name
6937 -- must not be taken into account for dispatching.
6939 Append_To
(Pkg_RPC_Receiver_Decls
,
6940 Make_Object_Declaration
(Loc
,
6941 Defining_Identifier
=> Is_Local
,
6942 Object_Definition
=>
6943 New_Occurrence_Of
(Standard_Boolean
, Loc
)));
6945 Append_To
(Pkg_RPC_Receiver_Decls
,
6946 Make_Object_Declaration
(Loc
,
6947 Defining_Identifier
=> Local_Address
,
6948 Object_Definition
=>
6949 New_Occurrence_Of
(RTE
(RE_Address
), Loc
)));
6951 Append_To
(Pkg_RPC_Receiver_Statements
,
6952 Make_Procedure_Call_Statement
(Loc
,
6953 Name
=> New_Occurrence_Of
(RTE
(RE_Get_Local_Address
), Loc
),
6954 Parameter_Associations
=> New_List
(
6955 Make_Selected_Component
(Loc
,
6957 Selector_Name
=> Name_Target
),
6958 New_Occurrence_Of
(Is_Local
, Loc
),
6959 New_Occurrence_Of
(Local_Address
, Loc
))));
6961 -- For each subprogram, the receiving stub will be built and a case
6962 -- statement will be made on the Subprogram_Id to dispatch to the
6963 -- right subprogram.
6965 All_Calls_Remote_E
:= Boolean_Literals
(
6966 Has_All_Calls_Remote
(Defining_Entity
(Pkg_Spec
)));
6968 Overload_Counter_Table
.Reset
;
6969 Reserve_NamingContext_Methods
;
6971 Visit_Spec
(Pkg_Spec
);
6974 Make_Object_Declaration
(Loc
,
6975 Defining_Identifier
=> Subp_Info_Array
,
6976 Constant_Present
=> True,
6977 Aliased_Present
=> True,
6978 Object_Definition
=>
6979 Make_Subtype_Indication
(Loc
,
6981 New_Occurrence_Of
(RTE
(RE_RCI_Subp_Info_Array
), Loc
),
6983 Make_Index_Or_Discriminant_Constraint
(Loc
,
6987 Make_Integer_Literal
(Loc
,
6988 Intval
=> First_RCI_Subprogram_Id
),
6990 Make_Integer_Literal
(Loc
,
6992 First_RCI_Subprogram_Id
6993 + List_Length
(Subp_Info_List
) - 1)))))));
6995 if Present
(First
(Subp_Info_List
)) then
6996 Set_Expression
(Last
(Decls
),
6997 Make_Aggregate
(Loc
,
6998 Component_Associations
=> Subp_Info_List
));
7000 -- Generate the dispatch statement to determine the subprogram id
7001 -- of the called subprogram.
7003 -- We first test whether the reference that was used to make the
7004 -- call was the base RCI reference (in which case Local_Address is
7005 -- zero, and the method identifier from the request must be used
7006 -- to determine which subprogram is called) or a reference
7007 -- identifying one particular subprogram (in which case
7008 -- Local_Address is the address of that subprogram, and the
7009 -- method name from the request is ignored). The latter occurs
7010 -- for the case of a call through a remote access-to-subprogram.
7012 -- In each case, cascaded elsifs are used to determine the proper
7013 -- subprogram index. Using hash tables might be more efficient.
7015 Append_To
(Pkg_RPC_Receiver_Statements
,
7016 Make_Implicit_If_Statement
(Pkg_Spec
,
7019 Left_Opnd
=> New_Occurrence_Of
(Local_Address
, Loc
),
7020 Right_Opnd
=> New_Occurrence_Of
7021 (RTE
(RE_Null_Address
), Loc
)),
7023 Then_Statements
=> New_List
(
7024 Make_Implicit_If_Statement
(Pkg_Spec
,
7025 Condition
=> New_Occurrence_Of
(Standard_False
, Loc
),
7026 Then_Statements
=> New_List
(
7027 Make_Null_Statement
(Loc
)),
7028 Elsif_Parts
=> Dispatch_On_Address
)),
7030 Else_Statements
=> New_List
(
7031 Make_Implicit_If_Statement
(Pkg_Spec
,
7032 Condition
=> New_Occurrence_Of
(Standard_False
, Loc
),
7033 Then_Statements
=> New_List
(Make_Null_Statement
(Loc
)),
7034 Elsif_Parts
=> Dispatch_On_Name
))));
7037 -- For a degenerate RCI with no visible subprograms,
7038 -- Subp_Info_List has zero length, and the declaration is for an
7039 -- empty array, in which case no initialization aggregate must be
7040 -- generated. We do not generate a Dispatch_Statement either.
7042 -- No initialization provided: remove CONSTANT so that the
7043 -- declaration is not an incomplete deferred constant.
7045 Set_Constant_Present
(Last
(Decls
), False);
7048 -- Analyze Subp_Info_Array declaration
7050 Analyze
(Last
(Decls
));
7052 -- If we receive an invalid Subprogram_Id, it is best to do nothing
7053 -- rather than raising an exception since we do not want someone
7054 -- to crash a remote partition by sending invalid subprogram ids.
7055 -- This is consistent with the other parts of the case statement
7056 -- since even in presence of incorrect parameters in the stream,
7057 -- every exception will be caught and (if the subprogram is not an
7058 -- APC) put into the result stream and sent away.
7060 Append_To
(Pkg_RPC_Receiver_Cases
,
7061 Make_Case_Statement_Alternative
(Loc
,
7062 Discrete_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
7063 Statements
=> New_List
(Make_Null_Statement
(Loc
))));
7065 Append_To
(Pkg_RPC_Receiver_Statements
,
7066 Make_Case_Statement
(Loc
,
7067 Expression
=> New_Occurrence_Of
(Subp_Index
, Loc
),
7068 Alternatives
=> Pkg_RPC_Receiver_Cases
));
7070 -- Pkg_RPC_Receiver body is now complete: insert it into the tree and
7073 Append_To
(Decls
, Pkg_RPC_Receiver_Body
);
7074 Analyze
(Last
(Decls
));
7076 Pkg_RPC_Receiver_Object
:=
7077 Make_Object_Declaration
(Loc
,
7078 Defining_Identifier
=> Make_Temporary
(Loc
, 'R'),
7079 Aliased_Present
=> True,
7080 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Servant
), Loc
));
7081 Append_To
(Decls
, Pkg_RPC_Receiver_Object
);
7082 Analyze
(Last
(Decls
));
7086 Append_To
(Register_Pkg_Actuals
,
7087 Make_String_Literal
(Loc
,
7089 Fully_Qualified_Name_String
7090 (Defining_Entity
(Pkg_Spec
), Append_NUL
=> False)));
7094 Append_To
(Register_Pkg_Actuals
,
7095 Make_Attribute_Reference
(Loc
,
7098 (Defining_Entity
(Pkg_Spec
), Loc
),
7099 Attribute_Name
=> Name_Version
));
7103 Append_To
(Register_Pkg_Actuals
,
7104 Make_Attribute_Reference
(Loc
,
7106 New_Occurrence_Of
(Pkg_RPC_Receiver
, Loc
),
7107 Attribute_Name
=> Name_Access
));
7111 Append_To
(Register_Pkg_Actuals
,
7112 Make_Attribute_Reference
(Loc
,
7115 Defining_Identifier
(Pkg_RPC_Receiver_Object
), Loc
),
7116 Attribute_Name
=> Name_Access
));
7120 Append_To
(Register_Pkg_Actuals
,
7121 Make_Attribute_Reference
(Loc
,
7122 Prefix
=> New_Occurrence_Of
(Subp_Info_Array
, Loc
),
7123 Attribute_Name
=> Name_Address
));
7127 Append_To
(Register_Pkg_Actuals
,
7128 Make_Attribute_Reference
(Loc
,
7129 Prefix
=> New_Occurrence_Of
(Subp_Info_Array
, Loc
),
7130 Attribute_Name
=> Name_Length
));
7132 -- Is_All_Calls_Remote
7134 Append_To
(Register_Pkg_Actuals
,
7135 New_Occurrence_Of
(All_Calls_Remote_E
, Loc
));
7137 -- Finally call Register_Pkg_Receiving_Stub with the above parameters
7140 Make_Procedure_Call_Statement
(Loc
,
7142 New_Occurrence_Of
(RTE
(RE_Register_Pkg_Receiving_Stub
), Loc
),
7143 Parameter_Associations
=> Register_Pkg_Actuals
));
7144 Analyze
(Last
(Stmts
));
7145 end Add_Receiving_Stubs_To_Declarations
;
7147 ---------------------------------
7148 -- Build_General_Calling_Stubs --
7149 ---------------------------------
7151 procedure Build_General_Calling_Stubs
7153 Statements
: List_Id
;
7154 Target_Object
: Node_Id
;
7155 Subprogram_Id
: Node_Id
;
7156 Asynchronous
: Node_Id
:= Empty
;
7157 Is_Known_Asynchronous
: Boolean := False;
7158 Is_Known_Non_Asynchronous
: Boolean := False;
7159 Is_Function
: Boolean;
7161 Stub_Type
: Entity_Id
:= Empty
;
7162 RACW_Type
: Entity_Id
:= Empty
;
7165 Loc
: constant Source_Ptr
:= Sloc
(Nod
);
7167 Request
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
7168 -- The request object constructed by these stubs
7169 -- Could we use Name_R instead??? (see GLADE client stubs)
7171 function Make_Request_RTE_Call
7173 Actuals
: List_Id
:= New_List
) return Node_Id
;
7174 -- Generate a procedure call statement calling RE with the given
7175 -- actuals. Request'Access is appended to the list.
7177 ---------------------------
7178 -- Make_Request_RTE_Call --
7179 ---------------------------
7181 function Make_Request_RTE_Call
7183 Actuals
: List_Id
:= New_List
) return Node_Id
7187 Make_Attribute_Reference
(Loc
,
7188 Prefix
=> New_Occurrence_Of
(Request
, Loc
),
7189 Attribute_Name
=> Name_Access
));
7190 return Make_Procedure_Call_Statement
(Loc
,
7192 New_Occurrence_Of
(RTE
(RE
), Loc
),
7193 Parameter_Associations
=> Actuals
);
7194 end Make_Request_RTE_Call
;
7196 Arguments
: Node_Id
;
7197 -- Name of the named values list used to transmit parameters
7198 -- to the remote package
7201 -- Name of the result named value (in non-APC cases) which get the
7202 -- result of the remote subprogram.
7204 Result_TC
: Node_Id
;
7205 -- Typecode expression for the result of the request (void
7206 -- typecode for procedures).
7208 Exception_Return_Parameter
: Node_Id
;
7209 -- Name of the parameter which will hold the exception sent by the
7210 -- remote subprogram.
7212 Current_Parameter
: Node_Id
;
7213 -- Current parameter being handled
7215 Ordered_Parameters_List
: constant List_Id
:=
7216 Build_Ordered_Parameters_List
(Spec
);
7218 Asynchronous_P
: Node_Id
;
7219 -- A Boolean expression indicating whether this call is asynchronous
7221 Asynchronous_Statements
: List_Id
:= No_List
;
7222 Non_Asynchronous_Statements
: List_Id
:= No_List
;
7223 -- Statements specifics to the Asynchronous/Non-Asynchronous cases
7225 Extra_Formal_Statements
: constant List_Id
:= New_List
;
7226 -- List of statements for extra formal parameters. It will appear
7227 -- after the regular statements for writing out parameters.
7229 After_Statements
: constant List_Id
:= New_List
;
7230 -- Statements to be executed after call returns (to assign IN OUT or
7231 -- OUT parameter values).
7234 -- The type of the formal parameter being processed
7236 Is_Controlling_Formal
: Boolean;
7237 Is_First_Controlling_Formal
: Boolean;
7238 First_Controlling_Formal_Seen
: Boolean := False;
7239 -- Controlling formal parameters of distributed object primitives
7240 -- require special handling, and the first such parameter needs even
7241 -- more special handling.
7244 -- ??? document general form of stub subprograms for the PolyORB case
7247 Make_Object_Declaration
(Loc
,
7248 Defining_Identifier
=> Request
,
7249 Aliased_Present
=> True,
7250 Object_Definition
=>
7251 New_Occurrence_Of
(RTE
(RE_Request
), Loc
)));
7253 Result
:= Make_Temporary
(Loc
, 'R');
7257 PolyORB_Support
.Helpers
.Build_TypeCode_Call
7258 (Loc
, Etype
(Result_Definition
(Spec
)), Decls
);
7260 Result_TC
:= New_Occurrence_Of
(RTE
(RE_TC_Void
), Loc
);
7264 Make_Object_Declaration
(Loc
,
7265 Defining_Identifier
=> Result
,
7266 Aliased_Present
=> False,
7267 Object_Definition
=>
7268 New_Occurrence_Of
(RTE
(RE_NamedValue
), Loc
),
7270 Make_Aggregate
(Loc
,
7271 Component_Associations
=> New_List
(
7272 Make_Component_Association
(Loc
,
7273 Choices
=> New_List
(Make_Identifier
(Loc
, Name_Name
)),
7275 New_Occurrence_Of
(RTE
(RE_Result_Name
), Loc
)),
7276 Make_Component_Association
(Loc
,
7277 Choices
=> New_List
(
7278 Make_Identifier
(Loc
, Name_Argument
)),
7280 Make_Function_Call
(Loc
,
7281 Name
=> New_Occurrence_Of
(RTE
(RE_Create_Any
), Loc
),
7282 Parameter_Associations
=> New_List
(Result_TC
))),
7283 Make_Component_Association
(Loc
,
7284 Choices
=> New_List
(
7285 Make_Identifier
(Loc
, Name_Arg_Modes
)),
7286 Expression
=> Make_Integer_Literal
(Loc
, 0))))));
7288 if not Is_Known_Asynchronous
then
7289 Exception_Return_Parameter
:= Make_Temporary
(Loc
, 'E');
7292 Make_Object_Declaration
(Loc
,
7293 Defining_Identifier
=> Exception_Return_Parameter
,
7294 Object_Definition
=>
7295 New_Occurrence_Of
(RTE
(RE_Exception_Occurrence
), Loc
)));
7298 Exception_Return_Parameter
:= Empty
;
7301 -- Initialize and fill in arguments list
7303 Arguments
:= Make_Temporary
(Loc
, 'A');
7304 Declare_Create_NVList
(Loc
, Arguments
, Decls
, Statements
);
7306 Current_Parameter
:= First
(Ordered_Parameters_List
);
7307 while Present
(Current_Parameter
) loop
7308 if Is_RACW_Controlling_Formal
(Current_Parameter
, Stub_Type
) then
7309 Is_Controlling_Formal
:= True;
7310 Is_First_Controlling_Formal
:=
7311 not First_Controlling_Formal_Seen
;
7312 First_Controlling_Formal_Seen
:= True;
7315 Is_Controlling_Formal
:= False;
7316 Is_First_Controlling_Formal
:= False;
7319 if Is_Controlling_Formal
then
7321 -- For a controlling formal argument, we send its reference
7326 Etyp
:= Etype
(Parameter_Type
(Current_Parameter
));
7329 -- The first controlling formal parameter is treated specially:
7330 -- it is used to set the target object of the call.
7332 if not Is_First_Controlling_Formal
then
7334 Constrained
: constant Boolean :=
7335 Is_Constrained
(Etyp
)
7336 or else Is_Elementary_Type
(Etyp
);
7338 Any
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
7340 Actual_Parameter
: Node_Id
:=
7342 Defining_Identifier
(
7343 Current_Parameter
), Loc
);
7348 if Is_Controlling_Formal
then
7350 -- For a controlling formal parameter (other than the
7351 -- first one), use the corresponding RACW. If the
7352 -- parameter is not an anonymous access parameter, that
7353 -- involves taking its 'Unrestricted_Access.
7355 if Nkind
(Parameter_Type
(Current_Parameter
))
7356 = N_Access_Definition
7358 Actual_Parameter
:= OK_Convert_To
7359 (Etyp
, Actual_Parameter
);
7361 Actual_Parameter
:= OK_Convert_To
(Etyp
,
7362 Make_Attribute_Reference
(Loc
,
7363 Prefix
=> Actual_Parameter
,
7364 Attribute_Name
=> Name_Unrestricted_Access
));
7369 if In_Present
(Current_Parameter
)
7370 or else not Out_Present
(Current_Parameter
)
7371 or else not Constrained
7372 or else Is_Controlling_Formal
7374 -- The parameter has an input value, is constrained at
7375 -- runtime by an input value, or is a controlling formal
7376 -- parameter (always passed as a reference) other than
7379 Expr
:= PolyORB_Support
.Helpers
.Build_To_Any_Call
7380 (Loc
, Actual_Parameter
, Decls
);
7383 Expr
:= Make_Function_Call
(Loc
,
7384 Name
=> New_Occurrence_Of
(RTE
(RE_Create_Any
), Loc
),
7385 Parameter_Associations
=> New_List
(
7386 PolyORB_Support
.Helpers
.Build_TypeCode_Call
7387 (Loc
, Etyp
, Decls
)));
7391 Make_Object_Declaration
(Loc
,
7392 Defining_Identifier
=> Any
,
7393 Aliased_Present
=> False,
7394 Object_Definition
=>
7395 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
7396 Expression
=> Expr
));
7398 Append_To
(Statements
,
7399 Add_Parameter_To_NVList
(Loc
,
7400 Parameter
=> Current_Parameter
,
7401 NVList
=> Arguments
,
7402 Constrained
=> Constrained
,
7405 if Out_Present
(Current_Parameter
)
7406 and then not Is_Controlling_Formal
7408 if Is_Limited_Type
(Etyp
) then
7409 Helpers
.Assign_Opaque_From_Any
(Loc
,
7410 Stms
=> After_Statements
,
7412 N
=> New_Occurrence_Of
(Any
, Loc
),
7414 Defining_Identifier
(Current_Parameter
),
7415 Constrained
=> True);
7418 Append_To
(After_Statements
,
7419 Make_Assignment_Statement
(Loc
,
7422 Defining_Identifier
(Current_Parameter
), Loc
),
7424 PolyORB_Support
.Helpers
.Build_From_Any_Call
7426 New_Occurrence_Of
(Any
, Loc
),
7433 -- If the current parameter has a dynamic constrained status, then
7434 -- this status is transmitted as well.
7436 -- This should be done for accessibility as well ???
7438 if Nkind
(Parameter_Type
(Current_Parameter
)) /=
7440 and then Need_Extra_Constrained
(Current_Parameter
)
7442 -- In this block, we do not use the extra formal that has been
7443 -- created because it does not exist at the time of expansion
7444 -- when building calling stubs for remote access to subprogram
7445 -- types. We create an extra variable of this type and push it
7446 -- in the stream after the regular parameters.
7449 Extra_Any_Parameter
: constant Entity_Id
:=
7450 Make_Temporary
(Loc
, 'P');
7452 Parameter_Exp
: constant Node_Id
:=
7453 Make_Attribute_Reference
(Loc
,
7454 Prefix
=> New_Occurrence_Of
(
7455 Defining_Identifier
(Current_Parameter
), Loc
),
7456 Attribute_Name
=> Name_Constrained
);
7459 Set_Etype
(Parameter_Exp
, Etype
(Standard_Boolean
));
7462 Make_Object_Declaration
(Loc
,
7463 Defining_Identifier
=> Extra_Any_Parameter
,
7464 Aliased_Present
=> False,
7465 Object_Definition
=>
7466 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
7468 PolyORB_Support
.Helpers
.Build_To_Any_Call
7469 (Loc
, Parameter_Exp
, Decls
)));
7471 Append_To
(Extra_Formal_Statements
,
7472 Add_Parameter_To_NVList
(Loc
,
7473 Parameter
=> Extra_Any_Parameter
,
7474 NVList
=> Arguments
,
7475 Constrained
=> True,
7476 Any
=> Extra_Any_Parameter
));
7480 Next
(Current_Parameter
);
7483 -- Append the formal statements list to the statements
7485 Append_List_To
(Statements
, Extra_Formal_Statements
);
7487 Append_To
(Statements
,
7488 Make_Procedure_Call_Statement
(Loc
,
7490 New_Occurrence_Of
(RTE
(RE_Request_Setup
), Loc
),
7491 Parameter_Associations
=> New_List
(
7492 New_Occurrence_Of
(Request
, Loc
),
7495 New_Occurrence_Of
(Arguments
, Loc
),
7496 New_Occurrence_Of
(Result
, Loc
),
7497 New_Occurrence_Of
(RTE
(RE_Nil_Exc_List
), Loc
))));
7500 (not (Is_Known_Non_Asynchronous
and Is_Known_Asynchronous
));
7502 if Is_Known_Non_Asynchronous
or Is_Known_Asynchronous
then
7505 (Boolean_Literals
(Is_Known_Asynchronous
), Loc
);
7508 pragma Assert
(Present
(Asynchronous
));
7509 Asynchronous_P
:= New_Copy_Tree
(Asynchronous
);
7511 -- The expression node Asynchronous will be used to build an 'if'
7512 -- statement at the end of Build_General_Calling_Stubs: we need to
7513 -- make a copy here.
7516 Append_To
(Parameter_Associations
(Last
(Statements
)),
7517 Make_Indexed_Component
(Loc
,
7520 RTE
(RE_Asynchronous_P_To_Sync_Scope
), Loc
),
7521 Expressions
=> New_List
(Asynchronous_P
)));
7523 Append_To
(Statements
, Make_Request_RTE_Call
(RE_Request_Invoke
));
7525 -- Asynchronous case
7527 if not Is_Known_Non_Asynchronous
then
7528 Asynchronous_Statements
:= New_List
(Make_Null_Statement
(Loc
));
7531 -- Non-asynchronous case
7533 if not Is_Known_Asynchronous
then
7534 -- Reraise an exception occurrence from the completed request.
7535 -- If the exception occurrence is empty, this is a no-op.
7537 Non_Asynchronous_Statements
:= New_List
(
7538 Make_Procedure_Call_Statement
(Loc
,
7540 New_Occurrence_Of
(RTE
(RE_Request_Raise_Occurrence
), Loc
),
7541 Parameter_Associations
=> New_List
(
7542 New_Occurrence_Of
(Request
, Loc
))));
7545 -- If this is a function call, read the value and return it
7547 Append_To
(Non_Asynchronous_Statements
,
7548 Make_Tag_Check
(Loc
,
7549 Make_Simple_Return_Statement
(Loc
,
7550 PolyORB_Support
.Helpers
.Build_From_Any_Call
7551 (Etype
(Result_Definition
(Spec
)),
7552 Make_Selected_Component
(Loc
,
7554 Selector_Name
=> Name_Argument
),
7559 -- Case of a procedure: deal with IN OUT and OUT formals
7561 Append_List_To
(Non_Asynchronous_Statements
, After_Statements
);
7565 if Is_Known_Asynchronous
then
7566 Append_List_To
(Statements
, Asynchronous_Statements
);
7568 elsif Is_Known_Non_Asynchronous
then
7569 Append_List_To
(Statements
, Non_Asynchronous_Statements
);
7572 pragma Assert
(Present
(Asynchronous
));
7573 Append_To
(Statements
,
7574 Make_Implicit_If_Statement
(Nod
,
7575 Condition
=> Asynchronous
,
7576 Then_Statements
=> Asynchronous_Statements
,
7577 Else_Statements
=> Non_Asynchronous_Statements
));
7579 end Build_General_Calling_Stubs
;
7581 -----------------------
7582 -- Build_Stub_Target --
7583 -----------------------
7585 function Build_Stub_Target
7588 RCI_Locator
: Entity_Id
;
7589 Controlling_Parameter
: Entity_Id
) return RPC_Target
7591 Target_Info
: RPC_Target
(PCS_Kind
=> Name_PolyORB_DSA
);
7592 Target_Reference
: constant Entity_Id
:= Make_Temporary
(Loc
, 'T');
7595 if Present
(Controlling_Parameter
) then
7597 Make_Object_Declaration
(Loc
,
7598 Defining_Identifier
=> Target_Reference
,
7600 Object_Definition
=>
7601 New_Occurrence_Of
(RTE
(RE_Object_Ref
), Loc
),
7604 Make_Function_Call
(Loc
,
7606 New_Occurrence_Of
(RTE
(RE_Make_Ref
), Loc
),
7607 Parameter_Associations
=> New_List
(
7608 Make_Selected_Component
(Loc
,
7609 Prefix
=> Controlling_Parameter
,
7610 Selector_Name
=> Name_Target
)))));
7612 -- Note: Controlling_Parameter has the same components as
7613 -- System.Partition_Interface.RACW_Stub_Type.
7615 Target_Info
.Object
:= New_Occurrence_Of
(Target_Reference
, Loc
);
7618 Target_Info
.Object
:=
7619 Make_Selected_Component
(Loc
,
7621 Make_Identifier
(Loc
, Chars
(RCI_Locator
)),
7623 Make_Identifier
(Loc
, Name_Get_RCI_Package_Ref
));
7627 end Build_Stub_Target
;
7629 -----------------------------
7630 -- Build_RPC_Receiver_Body --
7631 -----------------------------
7633 procedure Build_RPC_Receiver_Body
7634 (RPC_Receiver
: Entity_Id
;
7635 Request
: out Entity_Id
;
7636 Subp_Id
: out Entity_Id
;
7637 Subp_Index
: out Entity_Id
;
7638 Stmts
: out List_Id
;
7641 Loc
: constant Source_Ptr
:= Sloc
(RPC_Receiver
);
7643 RPC_Receiver_Spec
: Node_Id
;
7644 RPC_Receiver_Decls
: List_Id
;
7647 Request
:= Make_Defining_Identifier
(Loc
, Name_R
);
7649 RPC_Receiver_Spec
:=
7650 Build_RPC_Receiver_Specification
7651 (RPC_Receiver
=> RPC_Receiver
,
7652 Request_Parameter
=> Request
);
7654 Subp_Id
:= Make_Defining_Identifier
(Loc
, Name_P
);
7655 Subp_Index
:= Make_Defining_Identifier
(Loc
, Name_I
);
7657 RPC_Receiver_Decls
:= New_List
(
7658 Make_Object_Renaming_Declaration
(Loc
,
7659 Defining_Identifier
=> Subp_Id
,
7660 Subtype_Mark
=> New_Occurrence_Of
(Standard_String
, Loc
),
7662 Make_Explicit_Dereference
(Loc
,
7664 Make_Selected_Component
(Loc
,
7666 Selector_Name
=> Name_Operation
))),
7668 Make_Object_Declaration
(Loc
,
7669 Defining_Identifier
=> Subp_Index
,
7670 Object_Definition
=>
7671 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
),
7673 Make_Attribute_Reference
(Loc
,
7675 New_Occurrence_Of
(RTE
(RE_Subprogram_Id
), Loc
),
7676 Attribute_Name
=> Name_Last
)));
7681 Make_Subprogram_Body
(Loc
,
7682 Specification
=> RPC_Receiver_Spec
,
7683 Declarations
=> RPC_Receiver_Decls
,
7684 Handled_Statement_Sequence
=>
7685 Make_Handled_Sequence_Of_Statements
(Loc
,
7686 Statements
=> Stmts
));
7687 end Build_RPC_Receiver_Body
;
7689 --------------------------------------
7690 -- Build_Subprogram_Receiving_Stubs --
7691 --------------------------------------
7693 function Build_Subprogram_Receiving_Stubs
7694 (Vis_Decl
: Node_Id
;
7695 Asynchronous
: Boolean;
7696 Dynamically_Asynchronous
: Boolean := False;
7697 Stub_Type
: Entity_Id
:= Empty
;
7698 RACW_Type
: Entity_Id
:= Empty
;
7699 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
7701 Loc
: constant Source_Ptr
:= Sloc
(Vis_Decl
);
7703 Request_Parameter
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
7704 -- Formal parameter for receiving stubs: a descriptor for an incoming
7707 Outer_Decls
: constant List_Id
:= New_List
;
7708 -- At the outermost level, an NVList and Any's are declared for all
7709 -- parameters. The Dynamic_Async flag also needs to be declared there
7710 -- to be visible from the exception handling code.
7712 Outer_Statements
: constant List_Id
:= New_List
;
7713 -- Statements that occur prior to the declaration of the actual
7714 -- parameter variables.
7716 Outer_Extra_Formal_Statements
: constant List_Id
:= New_List
;
7717 -- Statements concerning extra formal parameters, prior to the
7718 -- declaration of the actual parameter variables.
7720 Decls
: constant List_Id
:= New_List
;
7721 -- All the parameters will get declared before calling the real
7722 -- subprograms. Also the out parameters will be declared. At this
7723 -- level, parameters may be unconstrained.
7725 Statements
: constant List_Id
:= New_List
;
7727 After_Statements
: constant List_Id
:= New_List
;
7728 -- Statements to be executed after the subprogram call
7730 Inner_Decls
: List_Id
:= No_List
;
7731 -- In case of a function, the inner declarations are needed since
7732 -- the result may be unconstrained.
7734 Excep_Handlers
: List_Id
:= No_List
;
7736 Parameter_List
: constant List_Id
:= New_List
;
7737 -- List of parameters to be passed to the subprogram
7739 First_Controlling_Formal_Seen
: Boolean := False;
7741 Current_Parameter
: Node_Id
;
7743 Ordered_Parameters_List
: constant List_Id
:=
7744 Build_Ordered_Parameters_List
7745 (Specification
(Vis_Decl
));
7747 Arguments
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
7748 -- Name of the named values list used to retrieve parameters
7750 Subp_Spec
: Node_Id
;
7751 -- Subprogram specification
7753 Called_Subprogram
: Node_Id
;
7754 -- The subprogram to call
7757 if Present
(RACW_Type
) then
7758 Called_Subprogram
:=
7759 New_Occurrence_Of
(Parent_Primitive
, Loc
);
7761 Called_Subprogram
:=
7763 (Defining_Unit_Name
(Specification
(Vis_Decl
)), Loc
);
7766 Declare_Create_NVList
(Loc
, Arguments
, Outer_Decls
, Outer_Statements
);
7768 -- Loop through every parameter and get its value from the stream. If
7769 -- the parameter is unconstrained, then the parameter is read using
7770 -- 'Input at the point of declaration.
7772 Current_Parameter
:= First
(Ordered_Parameters_List
);
7773 while Present
(Current_Parameter
) loop
7776 Constrained
: Boolean;
7777 Any
: Entity_Id
:= Empty
;
7778 Object
: constant Entity_Id
:= Make_Temporary
(Loc
, 'P');
7779 Expr
: Node_Id
:= Empty
;
7781 Is_Controlling_Formal
: constant Boolean :=
7782 Is_RACW_Controlling_Formal
7783 (Current_Parameter
, Stub_Type
);
7785 Is_First_Controlling_Formal
: Boolean := False;
7787 Need_Extra_Constrained
: Boolean;
7788 -- True when an extra constrained actual is required
7791 if Is_Controlling_Formal
then
7793 -- Controlling formals in distributed object primitive
7794 -- operations are handled specially:
7796 -- - the first controlling formal is used as the
7797 -- target of the call;
7799 -- - the remaining controlling formals are transmitted
7803 Is_First_Controlling_Formal
:=
7804 not First_Controlling_Formal_Seen
;
7805 First_Controlling_Formal_Seen
:= True;
7808 Etyp
:= Etype
(Parameter_Type
(Current_Parameter
));
7812 Is_Constrained
(Etyp
) or else Is_Elementary_Type
(Etyp
);
7814 if not Is_First_Controlling_Formal
then
7815 Any
:= Make_Temporary
(Loc
, 'A');
7817 Append_To
(Outer_Decls
,
7818 Make_Object_Declaration
(Loc
,
7819 Defining_Identifier
=> Any
,
7820 Object_Definition
=>
7821 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
7823 Make_Function_Call
(Loc
,
7824 Name
=> New_Occurrence_Of
(RTE
(RE_Create_Any
), Loc
),
7825 Parameter_Associations
=> New_List
(
7826 PolyORB_Support
.Helpers
.Build_TypeCode_Call
7827 (Loc
, Etyp
, Outer_Decls
)))));
7829 Append_To
(Outer_Statements
,
7830 Add_Parameter_To_NVList
(Loc
,
7831 Parameter
=> Current_Parameter
,
7832 NVList
=> Arguments
,
7833 Constrained
=> Constrained
,
7837 if Is_First_Controlling_Formal
then
7839 Addr
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
7841 Is_Local
: constant Entity_Id
:=
7842 Make_Temporary
(Loc
, 'L');
7845 -- Special case: obtain the first controlling formal
7846 -- from the target of the remote call, instead of the
7849 Append_To
(Outer_Decls
,
7850 Make_Object_Declaration
(Loc
,
7851 Defining_Identifier
=> Addr
,
7852 Object_Definition
=>
7853 New_Occurrence_Of
(RTE
(RE_Address
), Loc
)));
7855 Append_To
(Outer_Decls
,
7856 Make_Object_Declaration
(Loc
,
7857 Defining_Identifier
=> Is_Local
,
7858 Object_Definition
=>
7859 New_Occurrence_Of
(Standard_Boolean
, Loc
)));
7861 Append_To
(Outer_Statements
,
7862 Make_Procedure_Call_Statement
(Loc
,
7864 New_Occurrence_Of
(RTE
(RE_Get_Local_Address
), Loc
),
7865 Parameter_Associations
=> New_List
(
7866 Make_Selected_Component
(Loc
,
7869 Request_Parameter
, Loc
),
7871 Make_Identifier
(Loc
, Name_Target
)),
7872 New_Occurrence_Of
(Is_Local
, Loc
),
7873 New_Occurrence_Of
(Addr
, Loc
))));
7875 Expr
:= Unchecked_Convert_To
(RACW_Type
,
7876 New_Occurrence_Of
(Addr
, Loc
));
7879 elsif In_Present
(Current_Parameter
)
7880 or else not Out_Present
(Current_Parameter
)
7881 or else not Constrained
7883 -- If an input parameter is constrained, then its reading is
7884 -- deferred until the beginning of the subprogram body. If
7885 -- it is unconstrained, then an expression is built for
7886 -- the object declaration and the variable is set using
7887 -- 'Input instead of 'Read.
7889 if Constrained
and then Is_Limited_Type
(Etyp
) then
7890 Helpers
.Assign_Opaque_From_Any
(Loc
,
7893 N
=> New_Occurrence_Of
(Any
, Loc
),
7897 Expr
:= Helpers
.Build_From_Any_Call
7898 (Etyp
, New_Occurrence_Of
(Any
, Loc
), Decls
);
7901 Append_To
(Statements
,
7902 Make_Assignment_Statement
(Loc
,
7903 Name
=> New_Occurrence_Of
(Object
, Loc
),
7904 Expression
=> Expr
));
7908 -- Expr will be used to initialize (and constrain) the
7909 -- parameter when it is declared.
7917 Need_Extra_Constrained
:=
7918 Nkind
(Parameter_Type
(Current_Parameter
)) /=
7921 Ekind
(Defining_Identifier
(Current_Parameter
)) /= E_Void
7923 Present
(Extra_Constrained
7924 (Defining_Identifier
(Current_Parameter
)));
7926 -- We may not associate an extra constrained actual to a
7927 -- constant object, so if one is needed, declare the actual
7928 -- as a variable even if it won't be modified.
7930 Build_Actual_Object_Declaration
7933 Variable
=> Need_Extra_Constrained
7934 or else Out_Present
(Current_Parameter
),
7937 Set_Etype
(Object
, Etyp
);
7939 -- An out parameter may be written back using a 'Write
7940 -- attribute instead of a 'Output because it has been
7941 -- constrained by the parameter given to the caller. Note that
7942 -- OUT controlling arguments in the case of a RACW are not put
7943 -- back in the stream because the pointer on them has not
7946 if Out_Present
(Current_Parameter
)
7947 and then not Is_Controlling_Formal
7949 Append_To
(After_Statements
,
7950 Make_Procedure_Call_Statement
(Loc
,
7951 Name
=> New_Occurrence_Of
(RTE
(RE_Move_Any_Value
), Loc
),
7952 Parameter_Associations
=> New_List
(
7953 New_Occurrence_Of
(Any
, Loc
),
7954 PolyORB_Support
.Helpers
.Build_To_Any_Call
7956 New_Occurrence_Of
(Object
, Loc
),
7958 Constrained
=> True))));
7961 -- For RACW controlling formals, the Etyp of Object is always
7962 -- an RACW, even if the parameter is not of an anonymous access
7963 -- type. In such case, we need to dereference it at call time.
7965 if Is_Controlling_Formal
then
7966 if Nkind
(Parameter_Type
(Current_Parameter
)) /=
7969 Append_To
(Parameter_List
,
7970 Make_Parameter_Association
(Loc
,
7973 (Defining_Identifier
(Current_Parameter
), Loc
),
7974 Explicit_Actual_Parameter
=>
7975 Make_Explicit_Dereference
(Loc
,
7976 Prefix
=> New_Occurrence_Of
(Object
, Loc
))));
7979 Append_To
(Parameter_List
,
7980 Make_Parameter_Association
(Loc
,
7983 (Defining_Identifier
(Current_Parameter
), Loc
),
7985 Explicit_Actual_Parameter
=>
7986 New_Occurrence_Of
(Object
, Loc
)));
7990 Append_To
(Parameter_List
,
7991 Make_Parameter_Association
(Loc
,
7994 Defining_Identifier
(Current_Parameter
), Loc
),
7995 Explicit_Actual_Parameter
=>
7996 New_Occurrence_Of
(Object
, Loc
)));
7999 -- If the current parameter needs an extra formal, then read it
8000 -- from the stream and set the corresponding semantic field in
8001 -- the variable. If the kind of the parameter identifier is
8002 -- E_Void, then this is a compiler generated parameter that
8003 -- doesn't need an extra constrained status.
8005 -- The case of Extra_Accessibility should also be handled ???
8007 if Need_Extra_Constrained
then
8009 Extra_Parameter
: constant Entity_Id
:=
8011 (Defining_Identifier
8012 (Current_Parameter
));
8014 Extra_Any
: constant Entity_Id
:=
8015 Make_Temporary
(Loc
, 'A');
8017 Formal_Entity
: constant Entity_Id
:=
8018 Make_Defining_Identifier
(Loc
,
8019 Chars
=> Chars
(Extra_Parameter
));
8021 Formal_Type
: constant Entity_Id
:=
8022 Etype
(Extra_Parameter
);
8025 Append_To
(Outer_Decls
,
8026 Make_Object_Declaration
(Loc
,
8027 Defining_Identifier
=> Extra_Any
,
8028 Object_Definition
=>
8029 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
8031 Make_Function_Call
(Loc
,
8033 New_Occurrence_Of
(RTE
(RE_Create_Any
), Loc
),
8034 Parameter_Associations
=> New_List
(
8035 PolyORB_Support
.Helpers
.Build_TypeCode_Call
8036 (Loc
, Formal_Type
, Outer_Decls
)))));
8038 Append_To
(Outer_Extra_Formal_Statements
,
8039 Add_Parameter_To_NVList
(Loc
,
8040 Parameter
=> Extra_Parameter
,
8041 NVList
=> Arguments
,
8042 Constrained
=> True,
8046 Make_Object_Declaration
(Loc
,
8047 Defining_Identifier
=> Formal_Entity
,
8048 Object_Definition
=>
8049 New_Occurrence_Of
(Formal_Type
, Loc
)));
8051 Append_To
(Statements
,
8052 Make_Assignment_Statement
(Loc
,
8053 Name
=> New_Occurrence_Of
(Formal_Entity
, Loc
),
8055 PolyORB_Support
.Helpers
.Build_From_Any_Call
8057 New_Occurrence_Of
(Extra_Any
, Loc
),
8059 Set_Extra_Constrained
(Object
, Formal_Entity
);
8064 Next
(Current_Parameter
);
8067 -- Extra Formals should go after all the other parameters
8069 Append_List_To
(Outer_Statements
, Outer_Extra_Formal_Statements
);
8071 Append_To
(Outer_Statements
,
8072 Make_Procedure_Call_Statement
(Loc
,
8073 Name
=> New_Occurrence_Of
(RTE
(RE_Request_Arguments
), Loc
),
8074 Parameter_Associations
=> New_List
(
8075 New_Occurrence_Of
(Request_Parameter
, Loc
),
8076 New_Occurrence_Of
(Arguments
, Loc
))));
8078 if Nkind
(Specification
(Vis_Decl
)) = N_Function_Specification
then
8080 -- The remote subprogram is a function: Build an inner block to be
8081 -- able to hold a potentially unconstrained result in a variable.
8084 Etyp
: constant Entity_Id
:=
8085 Etype
(Result_Definition
(Specification
(Vis_Decl
)));
8086 Result
: constant Node_Id
:= Make_Temporary
(Loc
, 'R');
8089 Inner_Decls
:= New_List
(
8090 Make_Object_Declaration
(Loc
,
8091 Defining_Identifier
=> Result
,
8092 Constant_Present
=> True,
8093 Object_Definition
=> New_Occurrence_Of
(Etyp
, Loc
),
8095 Make_Function_Call
(Loc
,
8096 Name
=> Called_Subprogram
,
8097 Parameter_Associations
=> Parameter_List
)));
8099 if Is_Class_Wide_Type
(Etyp
) then
8101 -- For a remote call to a function with a class-wide type,
8102 -- check that the returned value satisfies the requirements
8105 Append_To
(Inner_Decls
,
8106 Make_Transportable_Check
(Loc
,
8107 New_Occurrence_Of
(Result
, Loc
)));
8111 Set_Etype
(Result
, Etyp
);
8112 Append_To
(After_Statements
,
8113 Make_Procedure_Call_Statement
(Loc
,
8114 Name
=> New_Occurrence_Of
(RTE
(RE_Set_Result
), Loc
),
8115 Parameter_Associations
=> New_List
(
8116 New_Occurrence_Of
(Request_Parameter
, Loc
),
8117 PolyORB_Support
.Helpers
.Build_To_Any_Call
8118 (Loc
, New_Occurrence_Of
(Result
, Loc
), Decls
))));
8120 -- A DSA function does not have out or inout arguments
8123 Append_To
(Statements
,
8124 Make_Block_Statement
(Loc
,
8125 Declarations
=> Inner_Decls
,
8126 Handled_Statement_Sequence
=>
8127 Make_Handled_Sequence_Of_Statements
(Loc
,
8128 Statements
=> After_Statements
)));
8131 -- The remote subprogram is a procedure. We do not need any inner
8132 -- block in this case. No specific processing is required here for
8133 -- the dynamically asynchronous case: the indication of whether
8134 -- call is asynchronous or not is managed by the Sync_Scope
8135 -- attibute of the request, and is handled entirely in the
8138 Append_To
(After_Statements
,
8139 Make_Procedure_Call_Statement
(Loc
,
8140 Name
=> New_Occurrence_Of
(RTE
(RE_Request_Set_Out
), Loc
),
8141 Parameter_Associations
=> New_List
(
8142 New_Occurrence_Of
(Request_Parameter
, Loc
))));
8144 Append_To
(Statements
,
8145 Make_Procedure_Call_Statement
(Loc
,
8146 Name
=> Called_Subprogram
,
8147 Parameter_Associations
=> Parameter_List
));
8149 Append_List_To
(Statements
, After_Statements
);
8153 Make_Procedure_Specification
(Loc
,
8154 Defining_Unit_Name
=> Make_Temporary
(Loc
, 'F'),
8156 Parameter_Specifications
=> New_List
(
8157 Make_Parameter_Specification
(Loc
,
8158 Defining_Identifier
=> Request_Parameter
,
8160 New_Occurrence_Of
(RTE
(RE_Request_Access
), Loc
))));
8162 -- An exception raised during the execution of an incoming remote
8163 -- subprogram call and that needs to be sent back to the caller is
8164 -- propagated by the receiving stubs, and will be handled by the
8165 -- caller (the distribution runtime).
8167 if Asynchronous
and then not Dynamically_Asynchronous
then
8169 -- For an asynchronous procedure, add a null exception handler
8171 Excep_Handlers
:= New_List
(
8172 Make_Implicit_Exception_Handler
(Loc
,
8173 Exception_Choices
=> New_List
(Make_Others_Choice
(Loc
)),
8174 Statements
=> New_List
(Make_Null_Statement
(Loc
))));
8177 -- In the other cases, if an exception is raised, then the
8178 -- exception occurrence is propagated.
8183 Append_To
(Outer_Statements
,
8184 Make_Block_Statement
(Loc
,
8185 Declarations
=> Decls
,
8186 Handled_Statement_Sequence
=>
8187 Make_Handled_Sequence_Of_Statements
(Loc
,
8188 Statements
=> Statements
)));
8191 Make_Subprogram_Body
(Loc
,
8192 Specification
=> Subp_Spec
,
8193 Declarations
=> Outer_Decls
,
8194 Handled_Statement_Sequence
=>
8195 Make_Handled_Sequence_Of_Statements
(Loc
,
8196 Statements
=> Outer_Statements
,
8197 Exception_Handlers
=> Excep_Handlers
));
8198 end Build_Subprogram_Receiving_Stubs
;
8204 package body Helpers
is
8206 -----------------------
8207 -- Local Subprograms --
8208 -----------------------
8210 function Find_Numeric_Representation
8211 (Typ
: Entity_Id
) return Entity_Id
;
8212 -- Given a numeric type Typ, return the smallest integer or modular
8213 -- type from Interfaces, or the smallest floating point type from
8214 -- Standard whose range encompasses that of Typ.
8216 function Make_Helper_Function_Name
8219 Nam
: Name_Id
) return Entity_Id
;
8220 -- Return the name to be assigned for helper subprogram Nam of Typ
8222 ------------------------------------------------------------
8223 -- Common subprograms for building various tree fragments --
8224 ------------------------------------------------------------
8226 function Build_Get_Aggregate_Element
8230 Idx
: Node_Id
) return Node_Id
;
8231 -- Build a call to Get_Aggregate_Element on Any for typecode TC,
8232 -- returning the Idx'th element.
8235 Subprogram
: Entity_Id
;
8236 -- Reference location for constructed nodes
8239 -- For 'Range and Etype
8242 -- For the construction of the innermost element expression
8244 with procedure Add_Process_Element
8247 Counter
: Entity_Id
;
8250 procedure Append_Array_Traversal
8253 Counter
: Entity_Id
:= Empty
;
8255 -- Build nested loop statements that iterate over the elements of an
8256 -- array Arry. The statement(s) built by Add_Process_Element are
8257 -- executed for each element; Indexes is the list of indexes to be
8258 -- used in the construction of the indexed component that denotes the
8259 -- current element. Subprogram is the entity for the subprogram for
8260 -- which this iterator is generated. The generated statements are
8261 -- appended to Stmts.
8265 -- The record entity being dealt with
8267 with procedure Add_Process_Element
8269 Container
: Node_Or_Entity_Id
;
8270 Counter
: in out Int
;
8273 -- Rec is the instance of the record type, or Empty.
8274 -- Field is either the N_Defining_Identifier for a component,
8275 -- or an N_Variant_Part.
8277 procedure Append_Record_Traversal
8280 Container
: Node_Or_Entity_Id
;
8281 Counter
: in out Int
);
8282 -- Process component list Clist. Individual fields are passed
8283 -- to Field_Processing. Each variant part is also processed.
8284 -- Container is the outer Any (for From_Any/To_Any),
8285 -- the outer typecode (for TC) to which the operation applies.
8287 -----------------------------
8288 -- Append_Record_Traversal --
8289 -----------------------------
8291 procedure Append_Record_Traversal
8294 Container
: Node_Or_Entity_Id
;
8295 Counter
: in out Int
)
8299 -- Clist's Component_Items and Variant_Part
8309 CI
:= Component_Items
(Clist
);
8310 VP
:= Variant_Part
(Clist
);
8313 while Present
(Item
) loop
8314 Def
:= Defining_Identifier
(Item
);
8316 if not Is_Internal_Name
(Chars
(Def
)) then
8318 (Stmts
, Container
, Counter
, Rec
, Def
);
8324 if Present
(VP
) then
8325 Add_Process_Element
(Stmts
, Container
, Counter
, Rec
, VP
);
8327 end Append_Record_Traversal
;
8329 -----------------------------
8330 -- Assign_Opaque_From_Any --
8331 -----------------------------
8333 procedure Assign_Opaque_From_Any
8339 Constrained
: Boolean := False)
8341 Strm
: constant Entity_Id
:= Make_Temporary
(Loc
, 'S');
8344 Read_Call_List
: List_Id
;
8345 -- List on which to place the 'Read attribute reference
8348 -- Strm : Buffer_Stream_Type;
8351 Make_Object_Declaration
(Loc
,
8352 Defining_Identifier
=> Strm
,
8353 Aliased_Present
=> True,
8354 Object_Definition
=>
8355 New_Occurrence_Of
(RTE
(RE_Buffer_Stream_Type
), Loc
)));
8357 -- Any_To_BS (Strm, A);
8360 Make_Procedure_Call_Statement
(Loc
,
8361 Name
=> New_Occurrence_Of
(RTE
(RE_Any_To_BS
), Loc
),
8362 Parameter_Associations
=> New_List
(
8364 New_Occurrence_Of
(Strm
, Loc
))));
8366 if Transmit_As_Unconstrained
(Typ
) and then not Constrained
then
8368 Make_Attribute_Reference
(Loc
,
8369 Prefix
=> New_Occurrence_Of
(Typ
, Loc
),
8370 Attribute_Name
=> Name_Input
,
8371 Expressions
=> New_List
(
8372 Make_Attribute_Reference
(Loc
,
8373 Prefix
=> New_Occurrence_Of
(Strm
, Loc
),
8374 Attribute_Name
=> Name_Access
)));
8376 -- Target := Typ'Input (Strm'Access)
8378 if Present
(Target
) then
8380 Make_Assignment_Statement
(Loc
,
8381 Name
=> New_Occurrence_Of
(Target
, Loc
),
8382 Expression
=> Expr
));
8384 -- return Typ'Input (Strm'Access);
8388 Make_Simple_Return_Statement
(Loc
,
8389 Expression
=> Expr
));
8393 if Present
(Target
) then
8394 Read_Call_List
:= Stms
;
8395 Expr
:= New_Occurrence_Of
(Target
, Loc
);
8399 Temp
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
8402 Read_Call_List
:= New_List
;
8403 Expr
:= New_Occurrence_Of
(Temp
, Loc
);
8405 Append_To
(Stms
, Make_Block_Statement
(Loc
,
8406 Declarations
=> New_List
(
8407 Make_Object_Declaration
(Loc
,
8408 Defining_Identifier
=>
8410 Object_Definition
=>
8411 New_Occurrence_Of
(Typ
, Loc
))),
8413 Handled_Statement_Sequence
=>
8414 Make_Handled_Sequence_Of_Statements
(Loc
,
8415 Statements
=> Read_Call_List
)));
8419 -- Typ'Read (Strm'Access, [Target|Temp])
8421 Append_To
(Read_Call_List
,
8422 Make_Attribute_Reference
(Loc
,
8423 Prefix
=> New_Occurrence_Of
(Typ
, Loc
),
8424 Attribute_Name
=> Name_Read
,
8425 Expressions
=> New_List
(
8426 Make_Attribute_Reference
(Loc
,
8427 Prefix
=> New_Occurrence_Of
(Strm
, Loc
),
8428 Attribute_Name
=> Name_Access
),
8435 Append_To
(Read_Call_List
,
8436 Make_Simple_Return_Statement
(Loc
,
8437 Expression
=> New_Copy
(Expr
)));
8440 end Assign_Opaque_From_Any
;
8442 -------------------------
8443 -- Build_From_Any_Call --
8444 -------------------------
8446 function Build_From_Any_Call
8449 Decls
: List_Id
) return Node_Id
8451 Loc
: constant Source_Ptr
:= Sloc
(N
);
8453 U_Type
: Entity_Id
:= Underlying_Type
(Typ
);
8455 Fnam
: Entity_Id
:= Empty
;
8456 Lib_RE
: RE_Id
:= RE_Null
;
8460 -- First simple case where the From_Any function is present
8461 -- in the type's TSS.
8463 Fnam
:= Find_Inherited_TSS
(U_Type
, TSS_From_Any
);
8465 -- For the subtype representing a generic actual type, go to the
8468 if Is_Generic_Actual_Type
(U_Type
) then
8469 U_Type
:= Underlying_Type
(Base_Type
(U_Type
));
8472 -- For a standard subtype, go to the base type
8474 if Sloc
(U_Type
) <= Standard_Location
then
8475 U_Type
:= Base_Type
(U_Type
);
8477 -- For a user subtype, go to first subtype
8479 elsif Comes_From_Source
(U_Type
)
8480 and then Nkind
(Declaration_Node
(U_Type
))
8481 = N_Subtype_Declaration
8483 U_Type
:= First_Subtype
(U_Type
);
8486 -- Check first for Boolean and Character. These are enumeration
8487 -- types, but we treat them specially, since they may require
8488 -- special handling in the transfer protocol. However, this
8489 -- special handling only applies if they have standard
8490 -- representation, otherwise they are treated like any other
8491 -- enumeration type.
8493 if Present
(Fnam
) then
8496 elsif U_Type
= Standard_Boolean
then
8499 elsif U_Type
= Standard_Character
then
8502 elsif U_Type
= Standard_Wide_Character
then
8505 elsif U_Type
= Standard_Wide_Wide_Character
then
8506 Lib_RE
:= RE_FA_WWC
;
8508 -- Floating point types
8510 elsif U_Type
= Standard_Short_Float
then
8513 elsif U_Type
= Standard_Float
then
8516 elsif U_Type
= Standard_Long_Float
then
8519 elsif U_Type
= Standard_Long_Long_Float
then
8520 Lib_RE
:= RE_FA_LLF
;
8524 elsif U_Type
= RTE
(RE_Integer_8
) then
8527 elsif U_Type
= RTE
(RE_Integer_16
) then
8528 Lib_RE
:= RE_FA_I16
;
8530 elsif U_Type
= RTE
(RE_Integer_32
) then
8531 Lib_RE
:= RE_FA_I32
;
8533 elsif U_Type
= RTE
(RE_Integer_64
) then
8534 Lib_RE
:= RE_FA_I64
;
8536 -- Unsigned integer types
8538 elsif U_Type
= RTE
(RE_Unsigned_8
) then
8541 elsif U_Type
= RTE
(RE_Unsigned_16
) then
8542 Lib_RE
:= RE_FA_U16
;
8544 elsif U_Type
= RTE
(RE_Unsigned_32
) then
8545 Lib_RE
:= RE_FA_U32
;
8547 elsif U_Type
= RTE
(RE_Unsigned_64
) then
8548 Lib_RE
:= RE_FA_U64
;
8550 elsif Is_RTE
(U_Type
, RE_Unbounded_String
) then
8551 Lib_RE
:= RE_FA_String
;
8553 -- Special DSA types
8555 elsif Is_RTE
(U_Type
, RE_Any_Container_Ptr
) then
8558 -- Other (non-primitive) types
8565 Build_From_Any_Function
(Loc
, U_Type
, Decl
, Fnam
);
8566 Append_To
(Decls
, Decl
);
8570 -- Call the function
8572 if Lib_RE
/= RE_Null
then
8573 pragma Assert
(No
(Fnam
));
8574 Fnam
:= RTE
(Lib_RE
);
8578 Make_Function_Call
(Loc
,
8579 Name
=> New_Occurrence_Of
(Fnam
, Loc
),
8580 Parameter_Associations
=> New_List
(N
));
8582 -- We must set the type of Result, so the unchecked conversion
8583 -- from the underlying type to the base type is properly done.
8585 Set_Etype
(Result
, U_Type
);
8587 return Unchecked_Convert_To
(Typ
, Result
);
8588 end Build_From_Any_Call
;
8590 -----------------------------
8591 -- Build_From_Any_Function --
8592 -----------------------------
8594 procedure Build_From_Any_Function
8598 Fnam
: out Entity_Id
)
8601 Decls
: constant List_Id
:= New_List
;
8602 Stms
: constant List_Id
:= New_List
;
8604 Any_Parameter
: constant Entity_Id
:= Make_Temporary
(Loc
, 'A');
8606 Use_Opaque_Representation
: Boolean;
8609 -- For a derived type, we can't go past the base type (to the
8610 -- parent type) here, because that would cause the attribute's
8611 -- formal parameter to have the wrong type; hence the Base_Type
8614 if Is_Itype
(Typ
) and then Typ
/= Base_Type
(Typ
) then
8615 Build_From_Any_Function
8623 Fnam
:= Make_Helper_Function_Name
(Loc
, Typ
, Name_From_Any
);
8626 Make_Function_Specification
(Loc
,
8627 Defining_Unit_Name
=> Fnam
,
8628 Parameter_Specifications
=> New_List
(
8629 Make_Parameter_Specification
(Loc
,
8630 Defining_Identifier
=> Any_Parameter
,
8631 Parameter_Type
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
))),
8632 Result_Definition
=> New_Occurrence_Of
(Typ
, Loc
));
8634 -- The RACW case is taken care of by Exp_Dist.Add_RACW_From_Any
8637 (not (Is_Remote_Access_To_Class_Wide_Type
(Typ
)));
8639 Use_Opaque_Representation
:= False;
8641 if Has_Stream_Attribute_Definition
8642 (Typ
, TSS_Stream_Output
, At_Any_Place
=> True)
8644 Has_Stream_Attribute_Definition
8645 (Typ
, TSS_Stream_Write
, At_Any_Place
=> True)
8647 -- If user-defined stream attributes are specified for this
8648 -- type, use them and transmit data as an opaque sequence of
8651 Use_Opaque_Representation
:= True;
8653 elsif Is_Derived_Type
(Typ
) and then not Is_Tagged_Type
(Typ
) then
8655 Make_Simple_Return_Statement
(Loc
,
8660 New_Occurrence_Of
(Any_Parameter
, Loc
),
8663 elsif Is_Record_Type
(Typ
)
8664 and then not Is_Derived_Type
(Typ
)
8665 and then not Is_Tagged_Type
(Typ
)
8667 if Nkind
(Declaration_Node
(Typ
)) = N_Subtype_Declaration
then
8669 Make_Simple_Return_Statement
(Loc
,
8673 New_Occurrence_Of
(Any_Parameter
, Loc
),
8678 Disc
: Entity_Id
:= Empty
;
8679 Discriminant_Associations
: List_Id
;
8680 Rdef
: constant Node_Id
:=
8682 (Declaration_Node
(Typ
));
8683 Component_Counter
: Int
:= 0;
8685 -- The returned object
8687 Res
: constant Entity_Id
:= Make_Temporary
(Loc
, 'R');
8689 Res_Definition
: Node_Id
:= New_Occurrence_Of
(Typ
, Loc
);
8691 procedure FA_Rec_Add_Process_Element
8694 Counter
: in out Int
;
8698 procedure FA_Append_Record_Traversal
is
8699 new Append_Record_Traversal
8701 Add_Process_Element
=> FA_Rec_Add_Process_Element
);
8703 --------------------------------
8704 -- FA_Rec_Add_Process_Element --
8705 --------------------------------
8707 procedure FA_Rec_Add_Process_Element
8710 Counter
: in out Int
;
8716 if Nkind
(Field
) = N_Defining_Identifier
then
8717 -- A regular component
8719 Ctyp
:= Etype
(Field
);
8722 Make_Assignment_Statement
(Loc
,
8723 Name
=> Make_Selected_Component
(Loc
,
8725 New_Occurrence_Of
(Rec
, Loc
),
8727 New_Occurrence_Of
(Field
, Loc
)),
8730 Build_From_Any_Call
(Ctyp
,
8731 Build_Get_Aggregate_Element
(Loc
,
8734 Build_TypeCode_Call
(Loc
, Ctyp
, Decls
),
8736 Make_Integer_Literal
(Loc
, Counter
)),
8744 Struct_Counter
: Int
:= 0;
8746 Block_Decls
: constant List_Id
:= New_List
;
8747 Block_Stmts
: constant List_Id
:= New_List
;
8750 Alt_List
: constant List_Id
:= New_List
;
8751 Choice_List
: List_Id
;
8753 Struct_Any
: constant Entity_Id
:=
8754 Make_Temporary
(Loc
, 'S');
8758 Make_Object_Declaration
(Loc
,
8759 Defining_Identifier
=> Struct_Any
,
8760 Constant_Present
=> True,
8761 Object_Definition
=>
8762 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
8764 Make_Function_Call
(Loc
,
8767 (RTE
(RE_Extract_Union_Value
), Loc
),
8769 Parameter_Associations
=> New_List
(
8770 Build_Get_Aggregate_Element
(Loc
,
8773 Make_Function_Call
(Loc
,
8774 Name
=> New_Occurrence_Of
(
8775 RTE
(RE_Any_Member_Type
), Loc
),
8776 Parameter_Associations
=>
8778 New_Occurrence_Of
(Any
, Loc
),
8779 Make_Integer_Literal
(Loc
,
8780 Intval
=> Counter
))),
8782 Make_Integer_Literal
(Loc
,
8783 Intval
=> Counter
))))));
8786 Make_Block_Statement
(Loc
,
8787 Declarations
=> Block_Decls
,
8788 Handled_Statement_Sequence
=>
8789 Make_Handled_Sequence_Of_Statements
(Loc
,
8790 Statements
=> Block_Stmts
)));
8792 Append_To
(Block_Stmts
,
8793 Make_Case_Statement
(Loc
,
8795 Make_Selected_Component
(Loc
,
8797 Selector_Name
=> Chars
(Name
(Field
))),
8798 Alternatives
=> Alt_List
));
8800 Variant
:= First_Non_Pragma
(Variants
(Field
));
8801 while Present
(Variant
) loop
8804 (Discrete_Choices
(Variant
));
8806 VP_Stmts
:= New_List
;
8808 -- Struct_Counter should be reset before
8809 -- handling a variant part. Indeed only one
8810 -- of the case statement alternatives will be
8811 -- executed at run time, so the counter must
8812 -- start at 0 for every case statement.
8814 Struct_Counter
:= 0;
8816 FA_Append_Record_Traversal
(
8818 Clist
=> Component_List
(Variant
),
8819 Container
=> Struct_Any
,
8820 Counter
=> Struct_Counter
);
8822 Append_To
(Alt_List
,
8823 Make_Case_Statement_Alternative
(Loc
,
8824 Discrete_Choices
=> Choice_List
,
8825 Statements
=> VP_Stmts
));
8826 Next_Non_Pragma
(Variant
);
8831 Counter
:= Counter
+ 1;
8832 end FA_Rec_Add_Process_Element
;
8835 -- First all discriminants
8837 if Has_Discriminants
(Typ
) then
8838 Discriminant_Associations
:= New_List
;
8840 Disc
:= First_Discriminant
(Typ
);
8841 while Present
(Disc
) loop
8843 Disc_Var_Name
: constant Entity_Id
:=
8844 Make_Defining_Identifier
(Loc
,
8845 Chars
=> Chars
(Disc
));
8846 Disc_Type
: constant Entity_Id
:=
8851 Make_Object_Declaration
(Loc
,
8852 Defining_Identifier
=> Disc_Var_Name
,
8853 Constant_Present
=> True,
8854 Object_Definition
=>
8855 New_Occurrence_Of
(Disc_Type
, Loc
),
8858 Build_From_Any_Call
(Disc_Type
,
8859 Build_Get_Aggregate_Element
(Loc
,
8860 Any
=> Any_Parameter
,
8861 TC
=> Build_TypeCode_Call
8862 (Loc
, Disc_Type
, Decls
),
8863 Idx
=> Make_Integer_Literal
(Loc
,
8864 Intval
=> Component_Counter
)),
8867 Component_Counter
:= Component_Counter
+ 1;
8869 Append_To
(Discriminant_Associations
,
8870 Make_Discriminant_Association
(Loc
,
8871 Selector_Names
=> New_List
(
8872 New_Occurrence_Of
(Disc
, Loc
)),
8874 New_Occurrence_Of
(Disc_Var_Name
, Loc
)));
8876 Next_Discriminant
(Disc
);
8880 Make_Subtype_Indication
(Loc
,
8881 Subtype_Mark
=> Res_Definition
,
8883 Make_Index_Or_Discriminant_Constraint
(Loc
,
8884 Discriminant_Associations
));
8887 -- Now we have all the discriminants in variables, we can
8888 -- declared a constrained object. Note that we are not
8889 -- initializing (non-discriminant) components directly in
8890 -- the object declarations, because which fields to
8891 -- initialize depends (at run time) on the discriminant
8895 Make_Object_Declaration
(Loc
,
8896 Defining_Identifier
=> Res
,
8897 Object_Definition
=> Res_Definition
));
8899 -- ... then all components
8901 FA_Append_Record_Traversal
(Stms
,
8902 Clist
=> Component_List
(Rdef
),
8903 Container
=> Any_Parameter
,
8904 Counter
=> Component_Counter
);
8907 Make_Simple_Return_Statement
(Loc
,
8908 Expression
=> New_Occurrence_Of
(Res
, Loc
)));
8912 elsif Is_Array_Type
(Typ
) then
8914 Constrained
: constant Boolean := Is_Constrained
(Typ
);
8916 procedure FA_Ary_Add_Process_Element
8919 Counter
: Entity_Id
;
8921 -- Assign the current element (as identified by Counter) of
8922 -- Any to the variable denoted by name Datum, and advance
8923 -- Counter by 1. If Datum is not an Any, a call to From_Any
8924 -- for its type is inserted.
8926 --------------------------------
8927 -- FA_Ary_Add_Process_Element --
8928 --------------------------------
8930 procedure FA_Ary_Add_Process_Element
8933 Counter
: Entity_Id
;
8936 Assignment
: constant Node_Id
:=
8937 Make_Assignment_Statement
(Loc
,
8939 Expression
=> Empty
);
8941 Element_Any
: Node_Id
;
8945 Element_TC
: Node_Id
;
8948 if Etype
(Datum
) = RTE
(RE_Any
) then
8950 -- When Datum is an Any the Etype field is not
8951 -- sufficient to determine the typecode of Datum
8952 -- (which can be a TC_SEQUENCE or TC_ARRAY
8953 -- depending on the value of Constrained).
8955 -- Therefore we retrieve the typecode which has
8956 -- been constructed in Append_Array_Traversal with
8957 -- a call to Get_Any_Type.
8960 Make_Function_Call
(Loc
,
8961 Name
=> New_Occurrence_Of
(
8962 RTE
(RE_Get_Any_Type
), Loc
),
8963 Parameter_Associations
=> New_List
(
8964 New_Occurrence_Of
(Entity
(Datum
), Loc
)));
8966 -- For non Any Datum we simply construct a typecode
8967 -- matching the Etype of the Datum.
8969 Element_TC
:= Build_TypeCode_Call
8970 (Loc
, Etype
(Datum
), Decls
);
8974 Build_Get_Aggregate_Element
(Loc
,
8977 Idx
=> New_Occurrence_Of
(Counter
, Loc
));
8980 -- Note: here we *prepend* statements to Stmts, so
8981 -- we must do it in reverse order.
8984 Make_Assignment_Statement
(Loc
,
8986 New_Occurrence_Of
(Counter
, Loc
),
8989 Left_Opnd
=> New_Occurrence_Of
(Counter
, Loc
),
8990 Right_Opnd
=> Make_Integer_Literal
(Loc
, 1))));
8992 if Nkind
(Datum
) /= N_Attribute_Reference
then
8994 -- We ignore the value of the length of each
8995 -- dimension, since the target array has already been
8996 -- constrained anyway.
8998 if Etype
(Datum
) /= RTE
(RE_Any
) then
8999 Set_Expression
(Assignment
,
9001 (Component_Type
(Typ
), Element_Any
, Decls
));
9003 Set_Expression
(Assignment
, Element_Any
);
9006 Prepend_To
(Stmts
, Assignment
);
9008 end FA_Ary_Add_Process_Element
;
9010 ------------------------
9011 -- Local Declarations --
9012 ------------------------
9014 Counter
: constant Entity_Id
:=
9015 Make_Defining_Identifier
(Loc
, Name_J
);
9017 Initial_Counter_Value
: Int
:= 0;
9019 Component_TC
: constant Entity_Id
:=
9020 Make_Defining_Identifier
(Loc
, Name_T
);
9022 Res
: constant Entity_Id
:=
9023 Make_Defining_Identifier
(Loc
, Name_R
);
9025 procedure Append_From_Any_Array_Iterator
is
9026 new Append_Array_Traversal
(
9029 Indexes
=> New_List
,
9030 Add_Process_Element
=> FA_Ary_Add_Process_Element
);
9032 Res_Subtype_Indication
: Node_Id
:=
9033 New_Occurrence_Of
(Typ
, Loc
);
9036 if not Constrained
then
9038 Ndim
: constant Int
:= Number_Dimensions
(Typ
);
9041 Indx
: Node_Id
:= First_Index
(Typ
);
9044 Ranges
: constant List_Id
:= New_List
;
9047 for J
in 1 .. Ndim
loop
9048 Lnam
:= New_External_Name
('L', J
);
9049 Hnam
:= New_External_Name
('H', J
);
9051 -- Note, for empty arrays bounds may be out of
9052 -- the range of Etype (Indx).
9054 Indt
:= Base_Type
(Etype
(Indx
));
9057 Make_Object_Declaration
(Loc
,
9058 Defining_Identifier
=>
9059 Make_Defining_Identifier
(Loc
, Lnam
),
9060 Constant_Present
=> True,
9061 Object_Definition
=>
9062 New_Occurrence_Of
(Indt
, Loc
),
9066 Build_Get_Aggregate_Element
(Loc
,
9067 Any
=> Any_Parameter
,
9068 TC
=> Build_TypeCode_Call
9071 Make_Integer_Literal
(Loc
, J
- 1)),
9075 Make_Object_Declaration
(Loc
,
9076 Defining_Identifier
=>
9077 Make_Defining_Identifier
(Loc
, Hnam
),
9079 Constant_Present
=> True,
9081 Object_Definition
=>
9082 New_Occurrence_Of
(Indt
, Loc
),
9084 Expression
=> Make_Attribute_Reference
(Loc
,
9086 New_Occurrence_Of
(Indt
, Loc
),
9088 Attribute_Name
=> Name_Val
,
9090 Expressions
=> New_List
(
9091 Make_Op_Subtract
(Loc
,
9096 (Standard_Long_Integer
,
9097 Make_Identifier
(Loc
, Lnam
)),
9101 (Standard_Long_Integer
,
9102 Make_Function_Call
(Loc
,
9104 New_Occurrence_Of
(RTE
(
9105 RE_Get_Nested_Sequence_Length
9107 Parameter_Associations
=>
9110 Any_Parameter
, Loc
),
9111 Make_Integer_Literal
(Loc
,
9115 Make_Integer_Literal
(Loc
, 1))))));
9119 Low_Bound
=> Make_Identifier
(Loc
, Lnam
),
9120 High_Bound
=> Make_Identifier
(Loc
, Hnam
)));
9125 -- Now we have all the necessary bound information:
9126 -- apply the set of range constraints to the
9127 -- (unconstrained) nominal subtype of Res.
9129 Initial_Counter_Value
:= Ndim
;
9130 Res_Subtype_Indication
:= Make_Subtype_Indication
(Loc
,
9131 Subtype_Mark
=> Res_Subtype_Indication
,
9133 Make_Index_Or_Discriminant_Constraint
(Loc
,
9134 Constraints
=> Ranges
));
9139 Make_Object_Declaration
(Loc
,
9140 Defining_Identifier
=> Res
,
9141 Object_Definition
=> Res_Subtype_Indication
));
9142 Set_Etype
(Res
, Typ
);
9145 Make_Object_Declaration
(Loc
,
9146 Defining_Identifier
=> Counter
,
9147 Object_Definition
=>
9148 New_Occurrence_Of
(RTE
(RE_Unsigned_32
), Loc
),
9150 Make_Integer_Literal
(Loc
, Initial_Counter_Value
)));
9153 Make_Object_Declaration
(Loc
,
9154 Defining_Identifier
=> Component_TC
,
9155 Constant_Present
=> True,
9156 Object_Definition
=>
9157 New_Occurrence_Of
(RTE
(RE_TypeCode
), Loc
),
9159 Build_TypeCode_Call
(Loc
,
9160 Component_Type
(Typ
), Decls
)));
9162 Append_From_Any_Array_Iterator
9163 (Stms
, Any_Parameter
, Counter
);
9166 Make_Simple_Return_Statement
(Loc
,
9167 Expression
=> New_Occurrence_Of
(Res
, Loc
)));
9170 elsif Is_Integer_Type
(Typ
) or else Is_Unsigned_Type
(Typ
) then
9172 Make_Simple_Return_Statement
(Loc
,
9174 Unchecked_Convert_To
(Typ
,
9176 (Find_Numeric_Representation
(Typ
),
9177 New_Occurrence_Of
(Any_Parameter
, Loc
),
9181 Use_Opaque_Representation
:= True;
9184 if Use_Opaque_Representation
then
9185 Assign_Opaque_From_Any
(Loc
,
9188 N
=> New_Occurrence_Of
(Any_Parameter
, Loc
),
9193 Make_Subprogram_Body
(Loc
,
9194 Specification
=> Spec
,
9195 Declarations
=> Decls
,
9196 Handled_Statement_Sequence
=>
9197 Make_Handled_Sequence_Of_Statements
(Loc
,
9198 Statements
=> Stms
));
9199 end Build_From_Any_Function
;
9201 ---------------------------------
9202 -- Build_Get_Aggregate_Element --
9203 ---------------------------------
9205 function Build_Get_Aggregate_Element
9209 Idx
: Node_Id
) return Node_Id
9212 return Make_Function_Call
(Loc
,
9214 New_Occurrence_Of
(RTE
(RE_Get_Aggregate_Element
), Loc
),
9215 Parameter_Associations
=> New_List
(
9216 New_Occurrence_Of
(Any
, Loc
),
9219 end Build_Get_Aggregate_Element
;
9221 ----------------------------------
9222 -- Build_Name_And_Repository_Id --
9223 ----------------------------------
9225 procedure Build_Name_And_Repository_Id
9227 Name_Str
: out String_Id
;
9228 Repo_Id_Str
: out String_Id
)
9231 Name_Str
:= Fully_Qualified_Name_String
(E
, Append_NUL
=> False);
9233 Store_String_Chars
("DSA:");
9234 Store_String_Chars
(Name_Str
);
9235 Store_String_Chars
(":1.0");
9236 Repo_Id_Str
:= End_String
;
9237 end Build_Name_And_Repository_Id
;
9239 -----------------------
9240 -- Build_To_Any_Call --
9241 -----------------------
9243 function Build_To_Any_Call
9247 Constrained
: Boolean := False) return Node_Id
9249 Typ
: Entity_Id
:= Etype
(N
);
9252 Fnam
: Entity_Id
:= Empty
;
9253 Lib_RE
: RE_Id
:= RE_Null
;
9256 -- If N is a selected component, then maybe its Etype has not been
9257 -- set yet: try to use Etype of the selector_name in that case.
9259 if No
(Typ
) and then Nkind
(N
) = N_Selected_Component
then
9260 Typ
:= Etype
(Selector_Name
(N
));
9263 pragma Assert
(Present
(Typ
));
9265 -- Get full view for private type, completion for incomplete type
9267 U_Type
:= Underlying_Type
(Typ
);
9269 -- First simple case where the To_Any function is present in the
9272 Fnam
:= Find_Inherited_TSS
(U_Type
, TSS_To_Any
);
9274 -- For the subtype representing a generic actual type, go to the
9277 if Is_Generic_Actual_Type
(U_Type
) then
9278 U_Type
:= Underlying_Type
(Base_Type
(U_Type
));
9281 -- For a standard subtype, go to the base type
9283 if Sloc
(U_Type
) <= Standard_Location
then
9284 U_Type
:= Base_Type
(U_Type
);
9286 -- For a user subtype, go to first subtype
9288 elsif Comes_From_Source
(U_Type
)
9289 and then Nkind
(Declaration_Node
(U_Type
))
9290 = N_Subtype_Declaration
9292 U_Type
:= First_Subtype
(U_Type
);
9295 if Present
(Fnam
) then
9298 -- Check first for Boolean and Character. These are enumeration
9299 -- types, but we treat them specially, since they may require
9300 -- special handling in the transfer protocol. However, this
9301 -- special handling only applies if they have standard
9302 -- representation, otherwise they are treated like any other
9303 -- enumeration type.
9305 elsif U_Type
= Standard_Boolean
then
9308 elsif U_Type
= Standard_Character
then
9311 elsif U_Type
= Standard_Wide_Character
then
9314 elsif U_Type
= Standard_Wide_Wide_Character
then
9315 Lib_RE
:= RE_TA_WWC
;
9317 -- Floating point types
9319 elsif U_Type
= Standard_Short_Float
then
9322 elsif U_Type
= Standard_Float
then
9325 elsif U_Type
= Standard_Long_Float
then
9328 elsif U_Type
= Standard_Long_Long_Float
then
9329 Lib_RE
:= RE_TA_LLF
;
9333 elsif U_Type
= RTE
(RE_Integer_8
) then
9336 elsif U_Type
= RTE
(RE_Integer_16
) then
9337 Lib_RE
:= RE_TA_I16
;
9339 elsif U_Type
= RTE
(RE_Integer_32
) then
9340 Lib_RE
:= RE_TA_I32
;
9342 elsif U_Type
= RTE
(RE_Integer_64
) then
9343 Lib_RE
:= RE_TA_I64
;
9345 -- Unsigned integer types
9347 elsif U_Type
= RTE
(RE_Unsigned_8
) then
9350 elsif U_Type
= RTE
(RE_Unsigned_16
) then
9351 Lib_RE
:= RE_TA_U16
;
9353 elsif U_Type
= RTE
(RE_Unsigned_32
) then
9354 Lib_RE
:= RE_TA_U32
;
9356 elsif U_Type
= RTE
(RE_Unsigned_64
) then
9357 Lib_RE
:= RE_TA_U64
;
9359 elsif Is_RTE
(U_Type
, RE_Unbounded_String
) then
9360 Lib_RE
:= RE_TA_String
;
9362 -- Special DSA types
9364 elsif Is_RTE
(U_Type
, RE_Any_Container_Ptr
) then
9368 elsif U_Type
= Underlying_Type
(RTE
(RE_TypeCode
)) then
9370 -- No corresponding FA_TC ???
9374 -- Other (non-primitive) types
9380 Build_To_Any_Function
(Loc
, U_Type
, Decl
, Fnam
);
9381 Append_To
(Decls
, Decl
);
9385 -- Call the function
9387 if Lib_RE
/= RE_Null
then
9388 pragma Assert
(No
(Fnam
));
9389 Fnam
:= RTE
(Lib_RE
);
9392 -- If Fnam is already analyzed, find the proper expected type,
9393 -- else we have a newly constructed To_Any function and we know
9394 -- that the expected type of its parameter is U_Type.
9396 if Ekind
(Fnam
) = E_Function
9397 and then Present
(First_Formal
(Fnam
))
9399 C_Type
:= Etype
(First_Formal
(Fnam
));
9405 Params
: constant List_Id
:=
9406 New_List
(OK_Convert_To
(C_Type
, N
));
9408 if Is_Limited_Type
(C_Type
) then
9410 New_Occurrence_Of
(Boolean_Literals
(Constrained
), Loc
));
9414 Make_Function_Call
(Loc
,
9415 Name
=> New_Occurrence_Of
(Fnam
, Loc
),
9416 Parameter_Associations
=> Params
);
9418 end Build_To_Any_Call
;
9420 ---------------------------
9421 -- Build_To_Any_Function --
9422 ---------------------------
9424 procedure Build_To_Any_Function
9428 Fnam
: out Entity_Id
)
9435 Expr_Formal
: Entity_Id
;
9436 Cstr_Formal
: Entity_Id
:= Empty
; -- initialize to prevent warning
9438 Result_TC
: Node_Id
;
9442 Use_Opaque_Representation
: Boolean;
9443 -- When True, use stream attributes and represent type as an
9444 -- opaque sequence of bytes.
9447 -- For a derived type, we can't go past the base type (to the
9448 -- parent type) here, because that would cause the attribute's
9449 -- formal parameter to have the wrong type; hence the Base_Type
9452 if Is_Itype
(Typ
) and then Typ
/= Base_Type
(Typ
) then
9453 Build_To_Any_Function
9464 Any
:= Make_Defining_Identifier
(Loc
, Name_A
);
9465 Result_TC
:= Build_TypeCode_Call
(Loc
, Typ
, Decls
);
9467 Fnam
:= Make_Helper_Function_Name
(Loc
, Typ
, Name_To_Any
);
9469 Expr_Formal
:= Make_Defining_Identifier
(Loc
, Name_E
);
9470 Params
:= New_List
(
9471 Make_Parameter_Specification
(Loc
,
9472 Defining_Identifier
=> Expr_Formal
,
9473 Parameter_Type
=> New_Occurrence_Of
(Typ
, Loc
)));
9474 Set_Etype
(Expr_Formal
, Typ
);
9476 if Is_Limited_Type
(Typ
) then
9477 Cstr_Formal
:= Make_Defining_Identifier
(Loc
, Name_C
);
9479 Make_Parameter_Specification
(Loc
,
9480 Defining_Identifier
=> Cstr_Formal
,
9482 New_Occurrence_Of
(Standard_Boolean
, Loc
)));
9486 Make_Function_Specification
(Loc
,
9487 Defining_Unit_Name
=> Fnam
,
9488 Parameter_Specifications
=> Params
,
9489 Result_Definition
=>
9490 New_Occurrence_Of
(RTE
(RE_Any
), Loc
));
9493 Make_Object_Declaration
(Loc
,
9494 Defining_Identifier
=> Any
,
9495 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Any
), Loc
));
9497 Use_Opaque_Representation
:= False;
9499 if Has_Stream_Attribute_Definition
9500 (Typ
, TSS_Stream_Output
, At_Any_Place
=> True)
9502 Has_Stream_Attribute_Definition
9503 (Typ
, TSS_Stream_Write
, At_Any_Place
=> True)
9505 -- If user-defined stream attributes are specified for this
9506 -- type, use them and transmit data as an opaque sequence of
9509 Use_Opaque_Representation
:= True;
9511 elsif Is_Derived_Type
(Typ
) and then not Is_Tagged_Type
(Typ
) then
9513 -- Untagged derived type: convert to root type
9516 Rt_Type
: constant Entity_Id
:= Root_Type
(Typ
);
9517 Expr
: constant Node_Id
:=
9520 New_Occurrence_Of
(Expr_Formal
, Loc
));
9522 Set_Expression
(Any_Decl
,
9523 Build_To_Any_Call
(Loc
, Expr
, Decls
));
9526 elsif Is_Record_Type
(Typ
) and then not Is_Tagged_Type
(Typ
) then
9528 -- Untagged record type
9530 if Nkind
(Declaration_Node
(Typ
)) = N_Subtype_Declaration
then
9532 Rt_Type
: constant Entity_Id
:= Etype
(Typ
);
9533 Expr
: constant Node_Id
:=
9534 OK_Convert_To
(Rt_Type
,
9535 New_Occurrence_Of
(Expr_Formal
, Loc
));
9539 (Any_Decl
, Build_To_Any_Call
(Loc
, Expr
, Decls
));
9542 -- Comment needed here (and label on declare block ???)
9546 Disc
: Entity_Id
:= Empty
;
9547 Rdef
: constant Node_Id
:=
9548 Type_Definition
(Declaration_Node
(Typ
));
9550 Elements
: constant List_Id
:= New_List
;
9552 procedure TA_Rec_Add_Process_Element
9554 Container
: Node_Or_Entity_Id
;
9555 Counter
: in out Int
;
9558 -- Processing routine for traversal below
9560 procedure TA_Append_Record_Traversal
is
9561 new Append_Record_Traversal
9562 (Rec
=> Expr_Formal
,
9563 Add_Process_Element
=> TA_Rec_Add_Process_Element
);
9565 --------------------------------
9566 -- TA_Rec_Add_Process_Element --
9567 --------------------------------
9569 procedure TA_Rec_Add_Process_Element
9571 Container
: Node_Or_Entity_Id
;
9572 Counter
: in out Int
;
9576 Field_Ref
: Node_Id
;
9579 if Nkind
(Field
) = N_Defining_Identifier
then
9581 -- A regular component
9583 Field_Ref
:= Make_Selected_Component
(Loc
,
9584 Prefix
=> New_Occurrence_Of
(Rec
, Loc
),
9585 Selector_Name
=> New_Occurrence_Of
(Field
, Loc
));
9586 Set_Etype
(Field_Ref
, Etype
(Field
));
9589 Make_Procedure_Call_Statement
(Loc
,
9592 RTE
(RE_Add_Aggregate_Element
), Loc
),
9593 Parameter_Associations
=> New_List
(
9594 New_Occurrence_Of
(Container
, Loc
),
9595 Build_To_Any_Call
(Loc
, Field_Ref
, Decls
))));
9600 Variant_Part
: declare
9602 Struct_Counter
: Int
:= 0;
9604 Block_Decls
: constant List_Id
:= New_List
;
9605 Block_Stmts
: constant List_Id
:= New_List
;
9608 Alt_List
: constant List_Id
:= New_List
;
9609 Choice_List
: List_Id
;
9611 Union_Any
: constant Entity_Id
:=
9612 Make_Temporary
(Loc
, 'V');
9614 Struct_Any
: constant Entity_Id
:=
9615 Make_Temporary
(Loc
, 'S');
9617 function Make_Discriminant_Reference
9619 -- Build reference to the discriminant for this
9622 ---------------------------------
9623 -- Make_Discriminant_Reference --
9624 ---------------------------------
9626 function Make_Discriminant_Reference
9629 Nod
: constant Node_Id
:=
9630 Make_Selected_Component
(Loc
,
9633 Chars
(Name
(Field
)));
9635 Set_Etype
(Nod
, Etype
(Name
(Field
)));
9637 end Make_Discriminant_Reference
;
9639 -- Start of processing for Variant_Part
9643 Make_Block_Statement
(Loc
,
9646 Handled_Statement_Sequence
=>
9647 Make_Handled_Sequence_Of_Statements
(Loc
,
9648 Statements
=> Block_Stmts
)));
9650 -- Declare variant part aggregate (Union_Any).
9651 -- Knowing the position of this VP in the
9652 -- variant record, we can fetch the VP typecode
9655 Append_To
(Block_Decls
,
9656 Make_Object_Declaration
(Loc
,
9657 Defining_Identifier
=> Union_Any
,
9658 Object_Definition
=>
9659 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
9661 Make_Function_Call
(Loc
,
9662 Name
=> New_Occurrence_Of
(
9663 RTE
(RE_Create_Any
), Loc
),
9664 Parameter_Associations
=> New_List
(
9665 Make_Function_Call
(Loc
,
9668 RTE
(RE_Any_Member_Type
), Loc
),
9669 Parameter_Associations
=> New_List
(
9670 New_Occurrence_Of
(Container
, Loc
),
9671 Make_Integer_Literal
(Loc
,
9674 -- Declare inner struct aggregate (which
9675 -- contains the components of this VP).
9677 Append_To
(Block_Decls
,
9678 Make_Object_Declaration
(Loc
,
9679 Defining_Identifier
=> Struct_Any
,
9680 Object_Definition
=>
9681 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
9683 Make_Function_Call
(Loc
,
9684 Name
=> New_Occurrence_Of
(
9685 RTE
(RE_Create_Any
), Loc
),
9686 Parameter_Associations
=> New_List
(
9687 Make_Function_Call
(Loc
,
9690 RTE
(RE_Any_Member_Type
), Loc
),
9691 Parameter_Associations
=> New_List
(
9692 New_Occurrence_Of
(Union_Any
, Loc
),
9693 Make_Integer_Literal
(Loc
,
9696 -- Build case statement
9698 Append_To
(Block_Stmts
,
9699 Make_Case_Statement
(Loc
,
9700 Expression
=> Make_Discriminant_Reference
,
9701 Alternatives
=> Alt_List
));
9703 Variant
:= First_Non_Pragma
(Variants
(Field
));
9704 while Present
(Variant
) loop
9705 Choice_List
:= New_Copy_List_Tree
9706 (Discrete_Choices
(Variant
));
9708 VP_Stmts
:= New_List
;
9710 -- Append discriminant val to union aggregate
9712 Append_To
(VP_Stmts
,
9713 Make_Procedure_Call_Statement
(Loc
,
9716 RTE
(RE_Add_Aggregate_Element
), Loc
),
9717 Parameter_Associations
=> New_List
(
9718 New_Occurrence_Of
(Union_Any
, Loc
),
9721 Make_Discriminant_Reference
,
9724 -- Populate inner struct aggregate
9726 -- Struct_Counter should be reset before
9727 -- handling a variant part. Indeed only one
9728 -- of the case statement alternatives will be
9729 -- executed at run time, so the counter must
9730 -- start at 0 for every case statement.
9732 Struct_Counter
:= 0;
9734 TA_Append_Record_Traversal
9736 Clist
=> Component_List
(Variant
),
9737 Container
=> Struct_Any
,
9738 Counter
=> Struct_Counter
);
9740 -- Append inner struct to union aggregate
9742 Append_To
(VP_Stmts
,
9743 Make_Procedure_Call_Statement
(Loc
,
9746 (RTE
(RE_Add_Aggregate_Element
), Loc
),
9747 Parameter_Associations
=> New_List
(
9748 New_Occurrence_Of
(Union_Any
, Loc
),
9749 New_Occurrence_Of
(Struct_Any
, Loc
))));
9751 -- Append union to outer aggregate
9753 Append_To
(VP_Stmts
,
9754 Make_Procedure_Call_Statement
(Loc
,
9757 (RTE
(RE_Add_Aggregate_Element
), Loc
),
9758 Parameter_Associations
=> New_List
(
9759 New_Occurrence_Of
(Container
, Loc
),
9761 (Union_Any
, Loc
))));
9763 Append_To
(Alt_List
,
9764 Make_Case_Statement_Alternative
(Loc
,
9765 Discrete_Choices
=> Choice_List
,
9766 Statements
=> VP_Stmts
));
9768 Next_Non_Pragma
(Variant
);
9773 Counter
:= Counter
+ 1;
9774 end TA_Rec_Add_Process_Element
;
9777 -- Records are encoded in a TC_STRUCT aggregate:
9779 -- -- Outer aggregate (TC_STRUCT)
9780 -- | [discriminant1]
9781 -- | [discriminant2]
9788 -- A component can be a common component or variant part
9790 -- A variant part is encoded as a TC_UNION aggregate:
9792 -- -- Variant Part Aggregate (TC_UNION)
9793 -- | [discriminant choice for this Variant Part]
9795 -- | -- Inner struct (TC_STRUCT)
9800 -- Let's start by building the outer aggregate. First we
9801 -- construct Elements array containing all discriminants.
9803 if Has_Discriminants
(Typ
) then
9804 Disc
:= First_Discriminant
(Typ
);
9805 while Present
(Disc
) loop
9807 Discriminant
: constant Entity_Id
:=
9808 Make_Selected_Component
(Loc
,
9809 Prefix
=> Expr_Formal
,
9810 Selector_Name
=> Chars
(Disc
));
9812 Set_Etype
(Discriminant
, Etype
(Disc
));
9813 Append_To
(Elements
,
9814 Make_Component_Association
(Loc
,
9815 Choices
=> New_List
(
9816 Make_Integer_Literal
(Loc
, Counter
)),
9818 Build_To_Any_Call
(Loc
,
9819 Discriminant
, Decls
)));
9822 Counter
:= Counter
+ 1;
9823 Next_Discriminant
(Disc
);
9827 -- If there are no discriminants, we declare an empty
9831 Dummy_Any
: constant Entity_Id
:=
9832 Make_Temporary
(Loc
, 'A');
9836 Make_Object_Declaration
(Loc
,
9837 Defining_Identifier
=> Dummy_Any
,
9838 Object_Definition
=>
9839 New_Occurrence_Of
(RTE
(RE_Any
), Loc
)));
9841 Append_To
(Elements
,
9842 Make_Component_Association
(Loc
,
9843 Choices
=> New_List
(
9846 Make_Integer_Literal
(Loc
, 1),
9848 Make_Integer_Literal
(Loc
, 0))),
9850 New_Occurrence_Of
(Dummy_Any
, Loc
)));
9854 -- We build the result aggregate with discriminants
9855 -- as the first elements.
9857 Set_Expression
(Any_Decl
,
9858 Make_Function_Call
(Loc
,
9859 Name
=> New_Occurrence_Of
9860 (RTE
(RE_Any_Aggregate_Build
), Loc
),
9861 Parameter_Associations
=> New_List
(
9863 Make_Aggregate
(Loc
,
9864 Component_Associations
=> Elements
))));
9867 -- Then we append all the components to the result
9870 TA_Append_Record_Traversal
(Stms
,
9871 Clist
=> Component_List
(Rdef
),
9873 Counter
=> Counter
);
9877 elsif Is_Array_Type
(Typ
) then
9879 -- Constrained and unconstrained array types
9882 Constrained
: constant Boolean :=
9883 not Transmit_As_Unconstrained
(Typ
);
9885 procedure TA_Ary_Add_Process_Element
9888 Counter
: Entity_Id
;
9891 --------------------------------
9892 -- TA_Ary_Add_Process_Element --
9893 --------------------------------
9895 procedure TA_Ary_Add_Process_Element
9898 Counter
: Entity_Id
;
9901 pragma Unreferenced
(Counter
);
9903 Element_Any
: Node_Id
;
9906 if Etype
(Datum
) = RTE
(RE_Any
) then
9907 Element_Any
:= Datum
;
9909 Element_Any
:= Build_To_Any_Call
(Loc
, Datum
, Decls
);
9913 Make_Procedure_Call_Statement
(Loc
,
9914 Name
=> New_Occurrence_Of
(
9915 RTE
(RE_Add_Aggregate_Element
), Loc
),
9916 Parameter_Associations
=> New_List
(
9917 New_Occurrence_Of
(Any
, Loc
),
9919 end TA_Ary_Add_Process_Element
;
9921 procedure Append_To_Any_Array_Iterator
is
9922 new Append_Array_Traversal
(
9924 Arry
=> Expr_Formal
,
9925 Indexes
=> New_List
,
9926 Add_Process_Element
=> TA_Ary_Add_Process_Element
);
9931 Set_Expression
(Any_Decl
,
9932 Make_Function_Call
(Loc
,
9934 New_Occurrence_Of
(RTE
(RE_Create_Any
), Loc
),
9935 Parameter_Associations
=> New_List
(Result_TC
)));
9938 if not Constrained
then
9939 Index
:= First_Index
(Typ
);
9940 for J
in 1 .. Number_Dimensions
(Typ
) loop
9942 Make_Procedure_Call_Statement
(Loc
,
9945 (RTE
(RE_Add_Aggregate_Element
), Loc
),
9946 Parameter_Associations
=> New_List
(
9947 New_Occurrence_Of
(Any
, Loc
),
9948 Build_To_Any_Call
(Loc
,
9949 OK_Convert_To
(Etype
(Index
),
9950 Make_Attribute_Reference
(Loc
,
9952 New_Occurrence_Of
(Expr_Formal
, Loc
),
9953 Attribute_Name
=> Name_First
,
9954 Expressions
=> New_List
(
9955 Make_Integer_Literal
(Loc
, J
)))),
9961 Append_To_Any_Array_Iterator
(Stms
, Any
);
9964 elsif Is_Integer_Type
(Typ
) or else Is_Unsigned_Type
(Typ
) then
9968 Set_Expression
(Any_Decl
,
9969 Build_To_Any_Call
(Loc
,
9971 Find_Numeric_Representation
(Typ
),
9972 New_Occurrence_Of
(Expr_Formal
, Loc
)),
9976 -- Default case, including tagged types: opaque representation
9978 Use_Opaque_Representation
:= True;
9981 if Use_Opaque_Representation
then
9983 Strm
: constant Entity_Id
:= Make_Temporary
(Loc
, 'S');
9984 -- Stream used to store data representation produced by
9985 -- stream attribute.
9989 -- Strm : aliased Buffer_Stream_Type;
9992 Make_Object_Declaration
(Loc
,
9993 Defining_Identifier
=> Strm
,
9994 Aliased_Present
=> True,
9995 Object_Definition
=>
9996 New_Occurrence_Of
(RTE
(RE_Buffer_Stream_Type
), Loc
)));
9999 -- T'Output (Strm'Access, E);
10001 -- T'Write (Strm'Access, E);
10002 -- depending on whether to transmit as unconstrained.
10004 -- For limited types, select at run time depending on
10005 -- Constrained parameter.
10008 function Stream_Call
(Attr
: Name_Id
) return Node_Id
;
10009 -- Return a call to the named attribute
10015 function Stream_Call
(Attr
: Name_Id
) return Node_Id
is
10017 return Make_Attribute_Reference
(Loc
,
10019 New_Occurrence_Of
(Typ
, Loc
),
10020 Attribute_Name
=> Attr
,
10021 Expressions
=> New_List
(
10022 Make_Attribute_Reference
(Loc
,
10024 New_Occurrence_Of
(Strm
, Loc
),
10025 Attribute_Name
=> Name_Access
),
10026 New_Occurrence_Of
(Expr_Formal
, Loc
)));
10031 if Is_Limited_Type
(Typ
) then
10033 Make_Implicit_If_Statement
(Typ
,
10035 New_Occurrence_Of
(Cstr_Formal
, Loc
),
10036 Then_Statements
=> New_List
(
10037 Stream_Call
(Name_Write
)),
10038 Else_Statements
=> New_List
(
10039 Stream_Call
(Name_Output
))));
10041 elsif Transmit_As_Unconstrained
(Typ
) then
10042 Append_To
(Stms
, Stream_Call
(Name_Output
));
10045 Append_To
(Stms
, Stream_Call
(Name_Write
));
10050 -- BS_To_Any (Strm, A);
10053 Make_Procedure_Call_Statement
(Loc
,
10055 New_Occurrence_Of
(RTE
(RE_BS_To_Any
), Loc
),
10056 Parameter_Associations
=> New_List
(
10057 New_Occurrence_Of
(Strm
, Loc
),
10058 New_Occurrence_Of
(Any
, Loc
))));
10061 -- Release_Buffer (Strm);
10064 Make_Procedure_Call_Statement
(Loc
,
10066 New_Occurrence_Of
(RTE
(RE_Release_Buffer
), Loc
),
10067 Parameter_Associations
=> New_List
(
10068 New_Occurrence_Of
(Strm
, Loc
))));
10072 Append_To
(Decls
, Any_Decl
);
10074 if Present
(Result_TC
) then
10076 Make_Procedure_Call_Statement
(Loc
,
10078 New_Occurrence_Of
(RTE
(RE_Set_TC
), Loc
),
10079 Parameter_Associations
=> New_List
(
10080 New_Occurrence_Of
(Any
, Loc
),
10085 Make_Simple_Return_Statement
(Loc
,
10086 Expression
=> New_Occurrence_Of
(Any
, Loc
)));
10089 Make_Subprogram_Body
(Loc
,
10090 Specification
=> Spec
,
10091 Declarations
=> Decls
,
10092 Handled_Statement_Sequence
=>
10093 Make_Handled_Sequence_Of_Statements
(Loc
,
10094 Statements
=> Stms
));
10095 end Build_To_Any_Function
;
10097 -------------------------
10098 -- Build_TypeCode_Call --
10099 -------------------------
10101 function Build_TypeCode_Call
10104 Decls
: List_Id
) return Node_Id
10106 U_Type
: Entity_Id
:= Underlying_Type
(Typ
);
10107 -- The full view, if Typ is private; the completion,
10108 -- if Typ is incomplete.
10110 Fnam
: Entity_Id
:= Empty
;
10111 Lib_RE
: RE_Id
:= RE_Null
;
10115 -- Special case System.PolyORB.Interface.Any: its primitives have
10116 -- not been set yet, so can't call Find_Inherited_TSS.
10118 if Typ
= RTE
(RE_Any
) then
10119 Fnam
:= RTE
(RE_TC_A
);
10122 -- First simple case where the TypeCode is present
10123 -- in the type's TSS.
10125 Fnam
:= Find_Inherited_TSS
(U_Type
, TSS_TypeCode
);
10128 -- For the subtype representing a generic actual type, go to the
10131 if Is_Generic_Actual_Type
(U_Type
) then
10132 U_Type
:= Underlying_Type
(Base_Type
(U_Type
));
10135 -- For a standard subtype, go to the base type
10137 if Sloc
(U_Type
) <= Standard_Location
then
10138 U_Type
:= Base_Type
(U_Type
);
10140 -- For a user subtype, go to first subtype
10142 elsif Comes_From_Source
(U_Type
)
10143 and then Nkind
(Declaration_Node
(U_Type
))
10144 = N_Subtype_Declaration
10146 U_Type
:= First_Subtype
(U_Type
);
10150 if U_Type
= Standard_Boolean
then
10153 elsif U_Type
= Standard_Character
then
10156 elsif U_Type
= Standard_Wide_Character
then
10157 Lib_RE
:= RE_TC_WC
;
10159 elsif U_Type
= Standard_Wide_Wide_Character
then
10160 Lib_RE
:= RE_TC_WWC
;
10162 -- Floating point types
10164 elsif U_Type
= Standard_Short_Float
then
10165 Lib_RE
:= RE_TC_SF
;
10167 elsif U_Type
= Standard_Float
then
10170 elsif U_Type
= Standard_Long_Float
then
10171 Lib_RE
:= RE_TC_LF
;
10173 elsif U_Type
= Standard_Long_Long_Float
then
10174 Lib_RE
:= RE_TC_LLF
;
10176 -- Integer types (walk back to the base type)
10178 elsif U_Type
= RTE
(RE_Integer_8
) then
10179 Lib_RE
:= RE_TC_I8
;
10181 elsif U_Type
= RTE
(RE_Integer_16
) then
10182 Lib_RE
:= RE_TC_I16
;
10184 elsif U_Type
= RTE
(RE_Integer_32
) then
10185 Lib_RE
:= RE_TC_I32
;
10187 elsif U_Type
= RTE
(RE_Integer_64
) then
10188 Lib_RE
:= RE_TC_I64
;
10190 -- Unsigned integer types
10192 elsif U_Type
= RTE
(RE_Unsigned_8
) then
10193 Lib_RE
:= RE_TC_U8
;
10195 elsif U_Type
= RTE
(RE_Unsigned_16
) then
10196 Lib_RE
:= RE_TC_U16
;
10198 elsif U_Type
= RTE
(RE_Unsigned_32
) then
10199 Lib_RE
:= RE_TC_U32
;
10201 elsif U_Type
= RTE
(RE_Unsigned_64
) then
10202 Lib_RE
:= RE_TC_U64
;
10204 elsif Is_RTE
(U_Type
, RE_Unbounded_String
) then
10205 Lib_RE
:= RE_TC_String
;
10207 -- Special DSA types
10209 elsif Is_RTE
(U_Type
, RE_Any_Container_Ptr
) then
10212 -- Other (non-primitive) types
10218 Build_TypeCode_Function
(Loc
, U_Type
, Decl
, Fnam
);
10219 Append_To
(Decls
, Decl
);
10223 if Lib_RE
/= RE_Null
then
10224 Fnam
:= RTE
(Lib_RE
);
10228 -- Call the function
10231 Make_Function_Call
(Loc
, Name
=> New_Occurrence_Of
(Fnam
, Loc
));
10233 -- Allow Expr to be used as arg to Build_To_Any_Call immediately
10235 Set_Etype
(Expr
, RTE
(RE_TypeCode
));
10238 end Build_TypeCode_Call
;
10240 -----------------------------
10241 -- Build_TypeCode_Function --
10242 -----------------------------
10244 procedure Build_TypeCode_Function
10247 Decl
: out Node_Id
;
10248 Fnam
: out Entity_Id
)
10251 Decls
: constant List_Id
:= New_List
;
10252 Stms
: constant List_Id
:= New_List
;
10254 TCNam
: constant Entity_Id
:=
10255 Make_Helper_Function_Name
(Loc
, Typ
, Name_TypeCode
);
10257 Parameters
: List_Id
;
10259 procedure Add_String_Parameter
10261 Parameter_List
: List_Id
);
10262 -- Add a literal for S to Parameters
10264 procedure Add_TypeCode_Parameter
10265 (TC_Node
: Node_Id
;
10266 Parameter_List
: List_Id
);
10267 -- Add the typecode for Typ to Parameters
10269 procedure Add_Long_Parameter
10270 (Expr_Node
: Node_Id
;
10271 Parameter_List
: List_Id
);
10272 -- Add a signed long integer expression to Parameters
10274 procedure Initialize_Parameter_List
10275 (Name_String
: String_Id
;
10276 Repo_Id_String
: String_Id
;
10277 Parameter_List
: out List_Id
);
10278 -- Return a list that contains the first two parameters
10279 -- for a parameterized typecode: name and repository id.
10281 function Make_Constructed_TypeCode
10283 Parameters
: List_Id
) return Node_Id
;
10284 -- Call Build_Complex_TC with the given kind and parameters
10286 procedure Return_Constructed_TypeCode
(Kind
: Entity_Id
);
10287 -- Make a return statement that calls Build_Complex_TC with the
10288 -- given typecode kind, and the constructed parameters list.
10290 procedure Return_Alias_TypeCode
(Base_TypeCode
: Node_Id
);
10291 -- Return a typecode that is a TC_Alias for the given typecode
10293 --------------------------
10294 -- Add_String_Parameter --
10295 --------------------------
10297 procedure Add_String_Parameter
10299 Parameter_List
: List_Id
)
10302 Append_To
(Parameter_List
,
10303 Make_Function_Call
(Loc
,
10304 Name
=> New_Occurrence_Of
(RTE
(RE_TA_Std_String
), Loc
),
10305 Parameter_Associations
=> New_List
(
10306 Make_String_Literal
(Loc
, S
))));
10307 end Add_String_Parameter
;
10309 ----------------------------
10310 -- Add_TypeCode_Parameter --
10311 ----------------------------
10313 procedure Add_TypeCode_Parameter
10314 (TC_Node
: Node_Id
;
10315 Parameter_List
: List_Id
)
10318 Append_To
(Parameter_List
,
10319 Make_Function_Call
(Loc
,
10320 Name
=> New_Occurrence_Of
(RTE
(RE_TA_TC
), Loc
),
10321 Parameter_Associations
=> New_List
(TC_Node
)));
10322 end Add_TypeCode_Parameter
;
10324 ------------------------
10325 -- Add_Long_Parameter --
10326 ------------------------
10328 procedure Add_Long_Parameter
10329 (Expr_Node
: Node_Id
;
10330 Parameter_List
: List_Id
)
10333 Append_To
(Parameter_List
,
10334 Make_Function_Call
(Loc
,
10336 New_Occurrence_Of
(RTE
(RE_TA_I32
), Loc
),
10337 Parameter_Associations
=> New_List
(Expr_Node
)));
10338 end Add_Long_Parameter
;
10340 -------------------------------
10341 -- Initialize_Parameter_List --
10342 -------------------------------
10344 procedure Initialize_Parameter_List
10345 (Name_String
: String_Id
;
10346 Repo_Id_String
: String_Id
;
10347 Parameter_List
: out List_Id
)
10350 Parameter_List
:= New_List
;
10351 Add_String_Parameter
(Name_String
, Parameter_List
);
10352 Add_String_Parameter
(Repo_Id_String
, Parameter_List
);
10353 end Initialize_Parameter_List
;
10355 ---------------------------
10356 -- Return_Alias_TypeCode --
10357 ---------------------------
10359 procedure Return_Alias_TypeCode
(Base_TypeCode
: Node_Id
) is
10361 Add_TypeCode_Parameter
(Base_TypeCode
, Parameters
);
10362 Return_Constructed_TypeCode
(RTE
(RE_Tk_Alias
));
10363 end Return_Alias_TypeCode
;
10365 -------------------------------
10366 -- Make_Constructed_TypeCode --
10367 -------------------------------
10369 function Make_Constructed_TypeCode
10371 Parameters
: List_Id
) return Node_Id
10373 Constructed_TC
: constant Node_Id
:=
10374 Make_Function_Call
(Loc
,
10376 New_Occurrence_Of
(RTE
(RE_Build_Complex_TC
), Loc
),
10377 Parameter_Associations
=> New_List
(
10378 New_Occurrence_Of
(Kind
, Loc
),
10379 Make_Aggregate
(Loc
,
10380 Expressions
=> Parameters
)));
10382 Set_Etype
(Constructed_TC
, RTE
(RE_TypeCode
));
10383 return Constructed_TC
;
10384 end Make_Constructed_TypeCode
;
10386 ---------------------------------
10387 -- Return_Constructed_TypeCode --
10388 ---------------------------------
10390 procedure Return_Constructed_TypeCode
(Kind
: Entity_Id
) is
10393 Make_Simple_Return_Statement
(Loc
,
10395 Make_Constructed_TypeCode
(Kind
, Parameters
)));
10396 end Return_Constructed_TypeCode
;
10402 procedure TC_Rec_Add_Process_Element
10405 Counter
: in out Int
;
10409 procedure TC_Append_Record_Traversal
is
10410 new Append_Record_Traversal
(
10412 Add_Process_Element
=> TC_Rec_Add_Process_Element
);
10414 --------------------------------
10415 -- TC_Rec_Add_Process_Element --
10416 --------------------------------
10418 procedure TC_Rec_Add_Process_Element
10421 Counter
: in out Int
;
10425 pragma Unreferenced
(Any
, Counter
, Rec
);
10428 if Nkind
(Field
) = N_Defining_Identifier
then
10430 -- A regular component
10432 Add_TypeCode_Parameter
10433 (Build_TypeCode_Call
(Loc
, Etype
(Field
), Decls
), Params
);
10434 Get_Name_String
(Chars
(Field
));
10435 Add_String_Parameter
(String_From_Name_Buffer
, Params
);
10441 Variant_Part
: declare
10442 Disc_Type
: constant Entity_Id
:= Etype
(Name
(Field
));
10444 Is_Enum
: constant Boolean :=
10445 Is_Enumeration_Type
(Disc_Type
);
10447 Union_TC_Params
: List_Id
;
10449 U_Name
: constant Name_Id
:=
10450 New_External_Name
(Chars
(Typ
), 'V', -1);
10452 Name_Str
: String_Id
;
10453 Struct_TC_Params
: List_Id
;
10457 Default
: constant Node_Id
:=
10458 Make_Integer_Literal
(Loc
, -1);
10460 Dummy_Counter
: Int
:= 0;
10462 Choice_Index
: Int
:= 0;
10463 -- Index of current choice in TypeCode, used to identify
10464 -- it as the default choice if it is a "when others".
10466 procedure Add_Params_For_Variant_Components
;
10467 -- Add a struct TypeCode and a corresponding member name
10468 -- to the union parameter list.
10470 -- Ordering of declarations is a complete mess in this
10471 -- area, it is supposed to be types/variables, then
10472 -- subprogram specs, then subprogram bodies ???
10474 ---------------------------------------
10475 -- Add_Params_For_Variant_Components --
10476 ---------------------------------------
10478 procedure Add_Params_For_Variant_Components
is
10479 S_Name
: constant Name_Id
:=
10480 New_External_Name
(U_Name
, 'S', -1);
10483 Get_Name_String
(S_Name
);
10484 Name_Str
:= String_From_Name_Buffer
;
10485 Initialize_Parameter_List
10486 (Name_Str
, Name_Str
, Struct_TC_Params
);
10488 -- Build struct parameters
10490 TC_Append_Record_Traversal
(Struct_TC_Params
,
10491 Component_List
(Variant
),
10495 Add_TypeCode_Parameter
10496 (Make_Constructed_TypeCode
10497 (RTE
(RE_Tk_Struct
), Struct_TC_Params
),
10500 Add_String_Parameter
(Name_Str
, Union_TC_Params
);
10501 end Add_Params_For_Variant_Components
;
10503 -- Start of processing for Variant_Part
10506 Get_Name_String
(U_Name
);
10507 Name_Str
:= String_From_Name_Buffer
;
10509 Initialize_Parameter_List
10510 (Name_Str
, Name_Str
, Union_TC_Params
);
10512 -- Add union in enclosing parameter list
10514 Add_TypeCode_Parameter
10515 (Make_Constructed_TypeCode
10516 (RTE
(RE_Tk_Union
), Union_TC_Params
),
10519 Add_String_Parameter
(Name_Str
, Params
);
10521 -- Build union parameters
10523 Add_TypeCode_Parameter
10524 (Build_TypeCode_Call
(Loc
, Disc_Type
, Decls
),
10527 Add_Long_Parameter
(Default
, Union_TC_Params
);
10529 Variant
:= First_Non_Pragma
(Variants
(Field
));
10530 while Present
(Variant
) loop
10531 Choice
:= First
(Discrete_Choices
(Variant
));
10532 while Present
(Choice
) loop
10533 case Nkind
(Choice
) is
10536 L
: constant Uint
:=
10537 Expr_Value
(Low_Bound
(Choice
));
10538 H
: constant Uint
:=
10539 Expr_Value
(High_Bound
(Choice
));
10541 -- 3.8.1(8) guarantees that the bounds of
10542 -- this range are static.
10549 Expr
:= Get_Enum_Lit_From_Pos
10550 (Disc_Type
, J
, Loc
);
10553 Make_Integer_Literal
(Loc
, J
);
10556 Set_Etype
(Expr
, Disc_Type
);
10557 Append_To
(Union_TC_Params
,
10558 Build_To_Any_Call
(Loc
, Expr
, Decls
));
10560 Add_Params_For_Variant_Components
;
10565 Choice_Index
+ UI_To_Int
(H
- L
) + 1;
10568 when N_Others_Choice
=>
10570 -- This variant has a default choice. We must
10571 -- therefore set the default parameter to the
10572 -- current choice index. This parameter is by
10573 -- construction the 4th in Union_TC_Params.
10576 (Pick
(Union_TC_Params
, 4),
10577 Make_Function_Call
(Loc
,
10580 (RTE
(RE_TA_I32
), Loc
),
10581 Parameter_Associations
=>
10583 Make_Integer_Literal
(Loc
,
10584 Intval
=> Choice_Index
))));
10586 -- Add a placeholder member label for the
10587 -- default case, which must have the
10588 -- discriminant type.
10591 Exp
: constant Node_Id
:=
10592 Make_Attribute_Reference
(Loc
,
10593 Prefix
=> New_Occurrence_Of
10595 Attribute_Name
=> Name_First
);
10597 Set_Etype
(Exp
, Disc_Type
);
10598 Append_To
(Union_TC_Params
,
10599 Build_To_Any_Call
(Loc
, Exp
, Decls
));
10602 Add_Params_For_Variant_Components
;
10603 Choice_Index
:= Choice_Index
+ 1;
10605 -- Case of an explicit choice
10609 Exp
: constant Node_Id
:=
10610 New_Copy_Tree
(Choice
);
10612 Append_To
(Union_TC_Params
,
10613 Build_To_Any_Call
(Loc
, Exp
, Decls
));
10616 Add_Params_For_Variant_Components
;
10617 Choice_Index
:= Choice_Index
+ 1;
10623 Next_Non_Pragma
(Variant
);
10627 end TC_Rec_Add_Process_Element
;
10629 Type_Name_Str
: String_Id
;
10630 Type_Repo_Id_Str
: String_Id
;
10632 -- Start of processing for Build_TypeCode_Function
10635 -- For a derived type, we can't go past the base type (to the
10636 -- parent type) here, because that would cause the attribute's
10637 -- formal parameter to have the wrong type; hence the Base_Type
10640 if Is_Itype
(Typ
) and then Typ
/= Base_Type
(Typ
) then
10641 Build_TypeCode_Function
10643 Typ
=> Etype
(Typ
),
10652 Make_Function_Specification
(Loc
,
10653 Defining_Unit_Name
=> Fnam
,
10654 Parameter_Specifications
=> Empty_List
,
10655 Result_Definition
=>
10656 New_Occurrence_Of
(RTE
(RE_TypeCode
), Loc
));
10658 Build_Name_And_Repository_Id
(Typ
,
10659 Name_Str
=> Type_Name_Str
, Repo_Id_Str
=> Type_Repo_Id_Str
);
10661 Initialize_Parameter_List
10662 (Type_Name_Str
, Type_Repo_Id_Str
, Parameters
);
10664 if Has_Stream_Attribute_Definition
10665 (Typ
, TSS_Stream_Output
, At_Any_Place
=> True)
10667 Has_Stream_Attribute_Definition
10668 (Typ
, TSS_Stream_Write
, At_Any_Place
=> True)
10670 -- If user-defined stream attributes are specified for this
10671 -- type, use them and transmit data as an opaque sequence of
10672 -- stream elements.
10674 Return_Alias_TypeCode
10675 (New_Occurrence_Of
(RTE
(RE_TC_Opaque
), Loc
));
10677 elsif Is_Derived_Type
(Typ
) and then not Is_Tagged_Type
(Typ
) then
10678 Return_Alias_TypeCode
(
10679 Build_TypeCode_Call
(Loc
, Etype
(Typ
), Decls
));
10681 elsif Is_Integer_Type
(Typ
) or else Is_Unsigned_Type
(Typ
) then
10682 Return_Alias_TypeCode
(
10683 Build_TypeCode_Call
(Loc
,
10684 Find_Numeric_Representation
(Typ
), Decls
));
10686 elsif Is_Record_Type
(Typ
) and then not Is_Tagged_Type
(Typ
) then
10688 -- Record typecodes are encoded as follows:
10692 -- | [Repository Id]
10694 -- Then for each discriminant:
10696 -- | [Discriminant Type Code]
10697 -- | [Discriminant Name]
10700 -- Then for each component:
10702 -- | [Component Type Code]
10703 -- | [Component Name]
10706 -- Variants components type codes are encoded as follows:
10710 -- | [Repository Id]
10711 -- | [Discriminant Type Code]
10712 -- | [Index of Default Variant Part or -1 for no default]
10714 -- Then for each Variant Part :
10719 -- | | [Variant Part Name]
10720 -- | | [Variant Part Repository Id]
10722 -- | Then for each VP component:
10723 -- | | [VP component Typecode]
10724 -- | | [VP component Name]
10730 if Nkind
(Declaration_Node
(Typ
)) = N_Subtype_Declaration
then
10731 Return_Alias_TypeCode
10732 (Build_TypeCode_Call
(Loc
, Etype
(Typ
), Decls
));
10736 Disc
: Entity_Id
:= Empty
;
10737 Rdef
: constant Node_Id
:=
10738 Type_Definition
(Declaration_Node
(Typ
));
10739 Dummy_Counter
: Int
:= 0;
10742 -- Construct the discriminants typecodes
10744 if Has_Discriminants
(Typ
) then
10745 Disc
:= First_Discriminant
(Typ
);
10748 while Present
(Disc
) loop
10749 Add_TypeCode_Parameter
(
10750 Build_TypeCode_Call
(Loc
, Etype
(Disc
), Decls
),
10752 Get_Name_String
(Chars
(Disc
));
10753 Add_String_Parameter
(
10754 String_From_Name_Buffer
,
10756 Next_Discriminant
(Disc
);
10759 -- then the components typecodes
10761 TC_Append_Record_Traversal
10762 (Parameters
, Component_List
(Rdef
),
10763 Empty
, Dummy_Counter
);
10764 Return_Constructed_TypeCode
(RTE
(RE_Tk_Struct
));
10768 elsif Is_Array_Type
(Typ
) then
10770 Ndim
: constant Pos
:= Number_Dimensions
(Typ
);
10771 Inner_TypeCode
: Node_Id
;
10772 Constrained
: constant Boolean := Is_Constrained
(Typ
);
10773 Indx
: Node_Id
:= First_Index
(Typ
);
10777 Build_TypeCode_Call
(Loc
, Component_Type
(Typ
), Decls
);
10779 for J
in 1 .. Ndim
loop
10780 if Constrained
then
10781 Inner_TypeCode
:= Make_Constructed_TypeCode
10782 (RTE
(RE_Tk_Array
), New_List
(
10783 Build_To_Any_Call
(Loc
,
10784 OK_Convert_To
(RTE
(RE_Unsigned_32
),
10785 Make_Attribute_Reference
(Loc
,
10786 Prefix
=> New_Occurrence_Of
(Typ
, Loc
),
10787 Attribute_Name
=> Name_Length
,
10788 Expressions
=> New_List
(
10789 Make_Integer_Literal
(Loc
,
10790 Intval
=> Ndim
- J
+ 1)))),
10792 Build_To_Any_Call
(Loc
, Inner_TypeCode
, Decls
)));
10795 -- Unconstrained case: add low bound for each
10798 Add_TypeCode_Parameter
10799 (Build_TypeCode_Call
(Loc
, Etype
(Indx
), Decls
),
10801 Get_Name_String
(New_External_Name
('L', J
));
10802 Add_String_Parameter
(
10803 String_From_Name_Buffer
,
10807 Inner_TypeCode
:= Make_Constructed_TypeCode
10808 (RTE
(RE_Tk_Sequence
), New_List
(
10809 Build_To_Any_Call
(Loc
,
10810 OK_Convert_To
(RTE
(RE_Unsigned_32
),
10811 Make_Integer_Literal
(Loc
, 0)),
10813 Build_To_Any_Call
(Loc
, Inner_TypeCode
, Decls
)));
10817 if Constrained
then
10818 Return_Alias_TypeCode
(Inner_TypeCode
);
10820 Add_TypeCode_Parameter
(Inner_TypeCode
, Parameters
);
10822 Store_String_Char
('V');
10823 Add_String_Parameter
(End_String
, Parameters
);
10824 Return_Constructed_TypeCode
(RTE
(RE_Tk_Struct
));
10829 -- Default: type is represented as an opaque sequence of bytes
10831 Return_Alias_TypeCode
10832 (New_Occurrence_Of
(RTE
(RE_TC_Opaque
), Loc
));
10836 Make_Subprogram_Body
(Loc
,
10837 Specification
=> Spec
,
10838 Declarations
=> Decls
,
10839 Handled_Statement_Sequence
=>
10840 Make_Handled_Sequence_Of_Statements
(Loc
,
10841 Statements
=> Stms
));
10842 end Build_TypeCode_Function
;
10844 ---------------------------------
10845 -- Find_Numeric_Representation --
10846 ---------------------------------
10848 function Find_Numeric_Representation
10849 (Typ
: Entity_Id
) return Entity_Id
10851 FST
: constant Entity_Id
:= First_Subtype
(Typ
);
10852 P_Size
: constant Uint
:= Esize
(FST
);
10855 -- Special case: for Stream_Element_Offset and Storage_Offset,
10856 -- always force transmission as a 64-bit value.
10858 if Is_RTE
(FST
, RE_Stream_Element_Offset
)
10860 Is_RTE
(FST
, RE_Storage_Offset
)
10862 return RTE
(RE_Unsigned_64
);
10865 if Is_Unsigned_Type
(Typ
) then
10866 if P_Size
<= 8 then
10867 return RTE
(RE_Unsigned_8
);
10869 elsif P_Size
<= 16 then
10870 return RTE
(RE_Unsigned_16
);
10872 elsif P_Size
<= 32 then
10873 return RTE
(RE_Unsigned_32
);
10876 return RTE
(RE_Unsigned_64
);
10879 elsif Is_Integer_Type
(Typ
) then
10880 if P_Size
<= 8 then
10881 return RTE
(RE_Integer_8
);
10883 elsif P_Size
<= Standard_Short_Integer_Size
then
10884 return RTE
(RE_Integer_16
);
10886 elsif P_Size
<= Standard_Integer_Size
then
10887 return RTE
(RE_Integer_32
);
10890 return RTE
(RE_Integer_64
);
10893 elsif Is_Floating_Point_Type
(Typ
) then
10894 if P_Size
<= Standard_Short_Float_Size
then
10895 return Standard_Short_Float
;
10897 elsif P_Size
<= Standard_Float_Size
then
10898 return Standard_Float
;
10900 elsif P_Size
<= Standard_Long_Float_Size
then
10901 return Standard_Long_Float
;
10904 return Standard_Long_Long_Float
;
10908 raise Program_Error
;
10911 -- TBD: fixed point types???
10912 -- TBverified numeric types with a biased representation???
10914 end Find_Numeric_Representation
;
10916 ---------------------------
10917 -- Append_Array_Traversal --
10918 ---------------------------
10920 procedure Append_Array_Traversal
10923 Counter
: Entity_Id
:= Empty
;
10926 Loc
: constant Source_Ptr
:= Sloc
(Subprogram
);
10927 Typ
: constant Entity_Id
:= Etype
(Arry
);
10928 Constrained
: constant Boolean := Is_Constrained
(Typ
);
10929 Ndim
: constant Pos
:= Number_Dimensions
(Typ
);
10931 Inner_Any
, Inner_Counter
: Entity_Id
;
10933 Loop_Stm
: Node_Id
;
10934 Inner_Stmts
: constant List_Id
:= New_List
;
10937 if Depth
> Ndim
then
10939 -- Processing for one element of an array
10942 Element_Expr
: constant Node_Id
:=
10943 Make_Indexed_Component
(Loc
,
10944 New_Occurrence_Of
(Arry
, Loc
),
10947 Set_Etype
(Element_Expr
, Component_Type
(Typ
));
10948 Add_Process_Element
(Stmts
,
10950 Counter
=> Counter
,
10951 Datum
=> Element_Expr
);
10957 Append_To
(Indexes
,
10958 Make_Identifier
(Loc
, New_External_Name
('L', Depth
)));
10960 if not Constrained
or else Depth
> 1 then
10961 Inner_Any
:= Make_Defining_Identifier
(Loc
,
10962 New_External_Name
('A', Depth
));
10963 Set_Etype
(Inner_Any
, RTE
(RE_Any
));
10965 Inner_Any
:= Empty
;
10968 if Present
(Counter
) then
10969 Inner_Counter
:= Make_Defining_Identifier
(Loc
,
10970 New_External_Name
('J', Depth
));
10972 Inner_Counter
:= Empty
;
10976 Loop_Any
: Node_Id
:= Inner_Any
;
10979 -- For the first dimension of a constrained array, we add
10980 -- elements directly in the corresponding Any; there is no
10981 -- intervening inner Any.
10983 if No
(Loop_Any
) then
10987 Append_Array_Traversal
(Inner_Stmts
,
10989 Counter
=> Inner_Counter
,
10990 Depth
=> Depth
+ 1);
10994 Make_Implicit_Loop_Statement
(Subprogram
,
10995 Iteration_Scheme
=>
10996 Make_Iteration_Scheme
(Loc
,
10997 Loop_Parameter_Specification
=>
10998 Make_Loop_Parameter_Specification
(Loc
,
10999 Defining_Identifier
=>
11000 Make_Defining_Identifier
(Loc
,
11001 Chars
=> New_External_Name
('L', Depth
)),
11003 Discrete_Subtype_Definition
=>
11004 Make_Attribute_Reference
(Loc
,
11005 Prefix
=> New_Occurrence_Of
(Arry
, Loc
),
11006 Attribute_Name
=> Name_Range
,
11008 Expressions
=> New_List
(
11009 Make_Integer_Literal
(Loc
, Depth
))))),
11010 Statements
=> Inner_Stmts
);
11013 Decls
: constant List_Id
:= New_List
;
11014 Dimen_Stmts
: constant List_Id
:= New_List
;
11015 Length_Node
: Node_Id
;
11017 Inner_Any_TypeCode
: constant Entity_Id
:=
11018 Make_Defining_Identifier
(Loc
,
11019 New_External_Name
('T', Depth
));
11021 Inner_Any_TypeCode_Expr
: Node_Id
;
11025 if Constrained
then
11026 Inner_Any_TypeCode_Expr
:=
11027 Make_Function_Call
(Loc
,
11028 Name
=> New_Occurrence_Of
(RTE
(RE_Get_TC
), Loc
),
11029 Parameter_Associations
=> New_List
(
11030 New_Occurrence_Of
(Any
, Loc
)));
11033 Inner_Any_TypeCode_Expr
:=
11034 Make_Function_Call
(Loc
,
11036 New_Occurrence_Of
(RTE
(RE_Any_Member_Type
), Loc
),
11037 Parameter_Associations
=> New_List
(
11038 New_Occurrence_Of
(Any
, Loc
),
11039 Make_Integer_Literal
(Loc
, Ndim
)));
11043 Inner_Any_TypeCode_Expr
:=
11044 Make_Function_Call
(Loc
,
11045 Name
=> New_Occurrence_Of
(RTE
(RE_Content_Type
), Loc
),
11046 Parameter_Associations
=> New_List
(
11047 Make_Identifier
(Loc
,
11048 Chars
=> New_External_Name
('T', Depth
- 1))));
11052 Make_Object_Declaration
(Loc
,
11053 Defining_Identifier
=> Inner_Any_TypeCode
,
11054 Constant_Present
=> True,
11055 Object_Definition
=> New_Occurrence_Of
(
11056 RTE
(RE_TypeCode
), Loc
),
11057 Expression
=> Inner_Any_TypeCode_Expr
));
11059 if Present
(Inner_Any
) then
11061 Make_Object_Declaration
(Loc
,
11062 Defining_Identifier
=> Inner_Any
,
11063 Object_Definition
=>
11064 New_Occurrence_Of
(RTE
(RE_Any
), Loc
),
11066 Make_Function_Call
(Loc
,
11068 New_Occurrence_Of
(
11069 RTE
(RE_Create_Any
), Loc
),
11070 Parameter_Associations
=> New_List
(
11071 New_Occurrence_Of
(Inner_Any_TypeCode
, Loc
)))));
11074 if Present
(Inner_Counter
) then
11076 Make_Object_Declaration
(Loc
,
11077 Defining_Identifier
=> Inner_Counter
,
11078 Object_Definition
=>
11079 New_Occurrence_Of
(RTE
(RE_Unsigned_32
), Loc
),
11081 Make_Integer_Literal
(Loc
, 0)));
11084 if not Constrained
then
11085 Length_Node
:= Make_Attribute_Reference
(Loc
,
11086 Prefix
=> New_Occurrence_Of
(Arry
, Loc
),
11087 Attribute_Name
=> Name_Length
,
11089 New_List
(Make_Integer_Literal
(Loc
, Depth
)));
11090 Set_Etype
(Length_Node
, RTE
(RE_Unsigned_32
));
11092 Add_Process_Element
(Dimen_Stmts
,
11093 Datum
=> Length_Node
,
11095 Counter
=> Inner_Counter
);
11098 -- Loop_Stm does appropriate processing for each element
11101 Append_To
(Dimen_Stmts
, Loop_Stm
);
11103 -- Link outer and inner any
11105 if Present
(Inner_Any
) then
11106 Add_Process_Element
(Dimen_Stmts
,
11108 Counter
=> Counter
,
11109 Datum
=> New_Occurrence_Of
(Inner_Any
, Loc
));
11113 Make_Block_Statement
(Loc
,
11116 Handled_Statement_Sequence
=>
11117 Make_Handled_Sequence_Of_Statements
(Loc
,
11118 Statements
=> Dimen_Stmts
)));
11120 end Append_Array_Traversal
;
11122 -------------------------------
11123 -- Make_Helper_Function_Name --
11124 -------------------------------
11126 function Make_Helper_Function_Name
11129 Nam
: Name_Id
) return Entity_Id
11134 -- For tagged types that aren't frozen yet, generate the helper
11135 -- under its canonical name so that it matches the primitive
11136 -- spec. For all other cases, we use a serialized name so that
11137 -- multiple generations of the same procedure do not clash.
11140 if Is_Tagged_Type
(Typ
) and then not Is_Frozen
(Typ
) then
11143 Serial
:= Increment_Serial_Number
;
11146 -- Use prefixed underscore to avoid potential clash with user
11147 -- identifier (we use attribute names for Nam).
11150 Make_Defining_Identifier
(Loc
,
11153 (Related_Id
=> Nam
,
11155 Suffix_Index
=> Serial
,
11158 end Make_Helper_Function_Name
;
11161 -----------------------------------
11162 -- Reserve_NamingContext_Methods --
11163 -----------------------------------
11165 procedure Reserve_NamingContext_Methods
is
11166 Str_Resolve
: constant String := "resolve";
11168 Name_Buffer
(1 .. Str_Resolve
'Length) := Str_Resolve
;
11169 Name_Len
:= Str_Resolve
'Length;
11170 Overload_Counter_Table
.Set
(Name_Find
, 1);
11171 end Reserve_NamingContext_Methods
;
11173 -----------------------
11174 -- RPC_Receiver_Decl --
11175 -----------------------
11177 function RPC_Receiver_Decl
(RACW_Type
: Entity_Id
) return Node_Id
is
11178 Loc
: constant Source_Ptr
:= Sloc
(RACW_Type
);
11181 Make_Object_Declaration
(Loc
,
11182 Defining_Identifier
=> Make_Temporary
(Loc
, 'R'),
11183 Aliased_Present
=> True,
11184 Object_Definition
=> New_Occurrence_Of
(RTE
(RE_Servant
), Loc
));
11185 end RPC_Receiver_Decl
;
11187 end PolyORB_Support
;
11189 -------------------------------
11190 -- RACW_Type_Is_Asynchronous --
11191 -------------------------------
11193 procedure RACW_Type_Is_Asynchronous
(RACW_Type
: Entity_Id
) is
11194 Asynchronous_Flag
: constant Entity_Id
:=
11195 Asynchronous_Flags_Table
.Get
(RACW_Type
);
11197 Replace
(Expression
(Parent
(Asynchronous_Flag
)),
11198 New_Occurrence_Of
(Standard_True
, Sloc
(Asynchronous_Flag
)));
11199 end RACW_Type_Is_Asynchronous
;
11201 -------------------------
11202 -- RCI_Package_Locator --
11203 -------------------------
11205 function RCI_Package_Locator
11207 Package_Spec
: Node_Id
) return Node_Id
11210 Pkg_Name
: constant String_Id
:=
11211 Fully_Qualified_Name_String
11212 (Defining_Entity
(Package_Spec
), Append_NUL
=> False);
11216 Make_Package_Instantiation
(Loc
,
11217 Defining_Unit_Name
=> Make_Temporary
(Loc
, 'R'),
11220 New_Occurrence_Of
(RTE
(RE_RCI_Locator
), Loc
),
11222 Generic_Associations
=> New_List
(
11223 Make_Generic_Association
(Loc
,
11225 Make_Identifier
(Loc
, Name_RCI_Name
),
11226 Explicit_Generic_Actual_Parameter
=>
11227 Make_String_Literal
(Loc
,
11228 Strval
=> Pkg_Name
)),
11230 Make_Generic_Association
(Loc
,
11232 Make_Identifier
(Loc
, Name_Version
),
11233 Explicit_Generic_Actual_Parameter
=>
11234 Make_Attribute_Reference
(Loc
,
11236 New_Occurrence_Of
(Defining_Entity
(Package_Spec
), Loc
),
11240 RCI_Locator_Table
.Set
11241 (Defining_Unit_Name
(Package_Spec
),
11242 Defining_Unit_Name
(Inst
));
11244 end RCI_Package_Locator
;
11246 -----------------------------------------------
11247 -- Remote_Types_Tagged_Full_View_Encountered --
11248 -----------------------------------------------
11250 procedure Remote_Types_Tagged_Full_View_Encountered
11251 (Full_View
: Entity_Id
)
11253 Stub_Elements
: constant Stub_Structure
:=
11254 Stubs_Table
.Get
(Full_View
);
11257 -- For an RACW encountered before the freeze point of its designated
11258 -- type, the stub type is generated at the point of the RACW declaration
11259 -- but the primitives are generated only once the designated type is
11260 -- frozen. That freeze can occur in another scope, for example when the
11261 -- RACW is declared in a nested package. In that case we need to
11262 -- reestablish the stub type's scope prior to generating its primitive
11265 if Stub_Elements
/= Empty_Stub_Structure
then
11267 Saved_Scope
: constant Entity_Id
:= Current_Scope
;
11268 Stubs_Scope
: constant Entity_Id
:=
11269 Scope
(Stub_Elements
.Stub_Type
);
11272 if Current_Scope
/= Stubs_Scope
then
11273 Push_Scope
(Stubs_Scope
);
11276 Add_RACW_Primitive_Declarations_And_Bodies
11278 Stub_Elements
.RPC_Receiver_Decl
,
11279 Stub_Elements
.Body_Decls
);
11281 if Current_Scope
/= Saved_Scope
then
11286 end Remote_Types_Tagged_Full_View_Encountered
;
11288 -------------------
11289 -- Scope_Of_Spec --
11290 -------------------
11292 function Scope_Of_Spec
(Spec
: Node_Id
) return Entity_Id
is
11293 Unit_Name
: Node_Id
;
11296 Unit_Name
:= Defining_Unit_Name
(Spec
);
11297 while Nkind
(Unit_Name
) /= N_Defining_Identifier
loop
11298 Unit_Name
:= Defining_Identifier
(Unit_Name
);
11304 ----------------------
11305 -- Set_Renaming_TSS --
11306 ----------------------
11308 procedure Set_Renaming_TSS
11311 TSS_Nam
: TSS_Name_Type
)
11313 Loc
: constant Source_Ptr
:= Sloc
(Nam
);
11314 Spec
: constant Node_Id
:= Parent
(Nam
);
11316 TSS_Node
: constant Node_Id
:=
11317 Make_Subprogram_Renaming_Declaration
(Loc
,
11319 Copy_Specification
(Loc
,
11321 New_Name
=> Make_TSS_Name
(Typ
, TSS_Nam
)),
11322 Name
=> New_Occurrence_Of
(Nam
, Loc
));
11324 Snam
: constant Entity_Id
:=
11325 Defining_Unit_Name
(Specification
(TSS_Node
));
11328 if Nkind
(Spec
) = N_Function_Specification
then
11329 Set_Ekind
(Snam
, E_Function
);
11330 Set_Etype
(Snam
, Entity
(Result_Definition
(Spec
)));
11332 Set_Ekind
(Snam
, E_Procedure
);
11333 Set_Etype
(Snam
, Standard_Void_Type
);
11336 Set_TSS
(Typ
, Snam
);
11337 end Set_Renaming_TSS
;
11339 ----------------------------------------------
11340 -- Specific_Add_Obj_RPC_Receiver_Completion --
11341 ----------------------------------------------
11343 procedure Specific_Add_Obj_RPC_Receiver_Completion
11346 RPC_Receiver
: Entity_Id
;
11347 Stub_Elements
: Stub_Structure
)
11350 case Get_PCS_Name
is
11351 when Name_PolyORB_DSA
=>
11352 PolyORB_Support
.Add_Obj_RPC_Receiver_Completion
11353 (Loc
, Decls
, RPC_Receiver
, Stub_Elements
);
11356 GARLIC_Support
.Add_Obj_RPC_Receiver_Completion
11357 (Loc
, Decls
, RPC_Receiver
, Stub_Elements
);
11359 end Specific_Add_Obj_RPC_Receiver_Completion
;
11361 --------------------------------
11362 -- Specific_Add_RACW_Features --
11363 --------------------------------
11365 procedure Specific_Add_RACW_Features
11366 (RACW_Type
: Entity_Id
;
11368 Stub_Type
: Entity_Id
;
11369 Stub_Type_Access
: Entity_Id
;
11370 RPC_Receiver_Decl
: Node_Id
;
11371 Body_Decls
: List_Id
)
11374 case Get_PCS_Name
is
11375 when Name_PolyORB_DSA
=>
11376 PolyORB_Support
.Add_RACW_Features
11385 GARLIC_Support
.Add_RACW_Features
11392 end Specific_Add_RACW_Features
;
11394 --------------------------------
11395 -- Specific_Add_RAST_Features --
11396 --------------------------------
11398 procedure Specific_Add_RAST_Features
11399 (Vis_Decl
: Node_Id
;
11400 RAS_Type
: Entity_Id
)
11403 case Get_PCS_Name
is
11404 when Name_PolyORB_DSA
=>
11405 PolyORB_Support
.Add_RAST_Features
(Vis_Decl
, RAS_Type
);
11408 GARLIC_Support
.Add_RAST_Features
(Vis_Decl
, RAS_Type
);
11410 end Specific_Add_RAST_Features
;
11412 --------------------------------------------------
11413 -- Specific_Add_Receiving_Stubs_To_Declarations --
11414 --------------------------------------------------
11416 procedure Specific_Add_Receiving_Stubs_To_Declarations
11417 (Pkg_Spec
: Node_Id
;
11422 case Get_PCS_Name
is
11423 when Name_PolyORB_DSA
=>
11424 PolyORB_Support
.Add_Receiving_Stubs_To_Declarations
11425 (Pkg_Spec
, Decls
, Stmts
);
11428 GARLIC_Support
.Add_Receiving_Stubs_To_Declarations
11429 (Pkg_Spec
, Decls
, Stmts
);
11431 end Specific_Add_Receiving_Stubs_To_Declarations
;
11433 ------------------------------------------
11434 -- Specific_Build_General_Calling_Stubs --
11435 ------------------------------------------
11437 procedure Specific_Build_General_Calling_Stubs
11439 Statements
: List_Id
;
11440 Target
: RPC_Target
;
11441 Subprogram_Id
: Node_Id
;
11442 Asynchronous
: Node_Id
:= Empty
;
11443 Is_Known_Asynchronous
: Boolean := False;
11444 Is_Known_Non_Asynchronous
: Boolean := False;
11445 Is_Function
: Boolean;
11447 Stub_Type
: Entity_Id
:= Empty
;
11448 RACW_Type
: Entity_Id
:= Empty
;
11452 case Get_PCS_Name
is
11453 when Name_PolyORB_DSA
=>
11454 PolyORB_Support
.Build_General_Calling_Stubs
11460 Is_Known_Asynchronous
,
11461 Is_Known_Non_Asynchronous
,
11469 GARLIC_Support
.Build_General_Calling_Stubs
11473 Target
.RPC_Receiver
,
11476 Is_Known_Asynchronous
,
11477 Is_Known_Non_Asynchronous
,
11484 end Specific_Build_General_Calling_Stubs
;
11486 --------------------------------------
11487 -- Specific_Build_RPC_Receiver_Body --
11488 --------------------------------------
11490 procedure Specific_Build_RPC_Receiver_Body
11491 (RPC_Receiver
: Entity_Id
;
11492 Request
: out Entity_Id
;
11493 Subp_Id
: out Entity_Id
;
11494 Subp_Index
: out Entity_Id
;
11495 Stmts
: out List_Id
;
11496 Decl
: out Node_Id
)
11499 case Get_PCS_Name
is
11500 when Name_PolyORB_DSA
=>
11501 PolyORB_Support
.Build_RPC_Receiver_Body
11510 GARLIC_Support
.Build_RPC_Receiver_Body
11518 end Specific_Build_RPC_Receiver_Body
;
11520 --------------------------------
11521 -- Specific_Build_Stub_Target --
11522 --------------------------------
11524 function Specific_Build_Stub_Target
11527 RCI_Locator
: Entity_Id
;
11528 Controlling_Parameter
: Entity_Id
) return RPC_Target
11531 case Get_PCS_Name
is
11532 when Name_PolyORB_DSA
=>
11534 PolyORB_Support
.Build_Stub_Target
11535 (Loc
, Decls
, RCI_Locator
, Controlling_Parameter
);
11539 GARLIC_Support
.Build_Stub_Target
11540 (Loc
, Decls
, RCI_Locator
, Controlling_Parameter
);
11542 end Specific_Build_Stub_Target
;
11544 --------------------------------
11545 -- Specific_RPC_Receiver_Decl --
11546 --------------------------------
11548 function Specific_RPC_Receiver_Decl
11549 (RACW_Type
: Entity_Id
) return Node_Id
11552 case Get_PCS_Name
is
11553 when Name_PolyORB_DSA
=>
11554 return PolyORB_Support
.RPC_Receiver_Decl
(RACW_Type
);
11557 return GARLIC_Support
.RPC_Receiver_Decl
(RACW_Type
);
11559 end Specific_RPC_Receiver_Decl
;
11561 -----------------------------------------------
11562 -- Specific_Build_Subprogram_Receiving_Stubs --
11563 -----------------------------------------------
11565 function Specific_Build_Subprogram_Receiving_Stubs
11566 (Vis_Decl
: Node_Id
;
11567 Asynchronous
: Boolean;
11568 Dynamically_Asynchronous
: Boolean := False;
11569 Stub_Type
: Entity_Id
:= Empty
;
11570 RACW_Type
: Entity_Id
:= Empty
;
11571 Parent_Primitive
: Entity_Id
:= Empty
) return Node_Id
11574 case Get_PCS_Name
is
11575 when Name_PolyORB_DSA
=>
11577 PolyORB_Support
.Build_Subprogram_Receiving_Stubs
11580 Dynamically_Asynchronous
,
11587 GARLIC_Support
.Build_Subprogram_Receiving_Stubs
11590 Dynamically_Asynchronous
,
11595 end Specific_Build_Subprogram_Receiving_Stubs
;
11597 -------------------------------
11598 -- Transmit_As_Unconstrained --
11599 -------------------------------
11601 function Transmit_As_Unconstrained
(Typ
: Entity_Id
) return Boolean is
11604 not (Is_Elementary_Type
(Typ
) or else Is_Constrained
(Typ
))
11605 or else (Is_Access_Type
(Typ
) and then Can_Never_Be_Null
(Typ
));
11606 end Transmit_As_Unconstrained
;
11608 --------------------------
11609 -- Underlying_RACW_Type --
11610 --------------------------
11612 function Underlying_RACW_Type
(RAS_Typ
: Entity_Id
) return Entity_Id
is
11613 Record_Type
: Entity_Id
;
11616 if Ekind
(RAS_Typ
) = E_Record_Type
then
11617 Record_Type
:= RAS_Typ
;
11619 pragma Assert
(Present
(Equivalent_Type
(RAS_Typ
)));
11620 Record_Type
:= Equivalent_Type
(RAS_Typ
);
11624 Etype
(Subtype_Indication
11625 (Component_Definition
11626 (First
(Component_Items
11629 (Declaration_Node
(Record_Type
))))))));
11630 end Underlying_RACW_Type
;