Update concepts branch to revision 131834
[official-gcc.git] / gcc / ada / exp_ch6.ads
blob79836a0e2bf054b0430c67ba4f0369b940386632
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ C H 6 --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Expand routines for chapter 6 constructs
28 with Types; use Types;
30 package Exp_Ch6 is
32 procedure Expand_N_Function_Call (N : Node_Id);
33 procedure Expand_N_Subprogram_Body (N : Node_Id);
34 procedure Expand_N_Subprogram_Body_Stub (N : Node_Id);
35 procedure Expand_N_Subprogram_Declaration (N : Node_Id);
36 procedure Expand_N_Procedure_Call_Statement (N : Node_Id);
38 procedure Expand_Call (N : Node_Id);
39 -- This procedure contains common processing for Expand_N_Function_Call,
40 -- Expand_N_Procedure_Statement, and Expand_N_Entry_Call.
42 procedure Freeze_Subprogram (N : Node_Id);
43 -- generate the appropriate expansions related to Subprogram freeze
44 -- nodes (e.g. the filling of the corresponding Dispatch Table for
45 -- Primitive Operations)
47 -- The following type defines the various forms of allocation used for the
48 -- results of build-in-place function calls.
50 type BIP_Allocation_Form is
51 (Unspecified,
52 Caller_Allocation,
53 Secondary_Stack,
54 Global_Heap,
55 User_Storage_Pool);
57 type BIP_Formal_Kind is
58 -- Ada 2005 (AI-318-02): This type defines the kinds of implicit extra
59 -- formals created for build-in-place functions. The order of the above
60 -- enumeration literals matches the order in which the formals are
61 -- declared. See Sem_Ch6.Create_Extra_Formals.
62 (BIP_Alloc_Form,
63 -- Present if result subtype is unconstrained, or if the result type
64 -- is tagged. Indicates whether the return object is allocated by the
65 -- caller or callee, and if the callee, whether to use the secondary
66 -- stack or the heap. See Create_Extra_Formals.
67 BIP_Final_List,
68 -- Present if result type has controlled parts. Pointer to caller's
69 -- finalization list.
70 BIP_Master,
71 -- Present if result type contains tasks. Master associated with
72 -- calling context.
73 BIP_Activation_Chain,
74 -- Present if result type contains tasks. Caller's activation chain
75 BIP_Object_Access);
76 -- Present for all build-in-place functions. Address at which to place
77 -- the return object, or null if BIP_Alloc_Form indicates
78 -- allocated by callee.
79 -- ??? We also need to be able to pass in some way to access a
80 -- user-defined storage pool at some point. And perhaps a constrained
81 -- flag.
83 function BIP_Formal_Suffix (Kind : BIP_Formal_Kind) return String;
84 -- Ada 2005 (AI-318-02): Returns a string to be used as the suffix of names
85 -- for build-in-place formal parameters of the given kind.
87 function Build_In_Place_Formal
88 (Func : Entity_Id;
89 Kind : BIP_Formal_Kind) return Entity_Id;
90 -- Ada 2005 (AI-318-02): Locates and returns the entity for the implicit
91 -- build-in-place formal parameter of the given kind associated with the
92 -- function Func, and returns its Entity_Id. It is a bug if not found; the
93 -- caller should ensure this is called only when the extra formal exists.
95 function Is_Build_In_Place_Function (E : Entity_Id) return Boolean;
96 -- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic
97 -- function, or access-to-function type whose result must be built in
98 -- place; otherwise returns False. For Ada 2005, this is currently
99 -- restricted to the set of functions whose result subtype is an inherently
100 -- limited type. In Ada 95, this must be False for inherently limited
101 -- result types (but currently returns False for all Ada 95 functions).
102 -- Eventually we plan to support build-in-place for nonlimited types.
103 -- Build-in-place is usually more efficient for large things, and less
104 -- efficient for small things. However, we never use build-in-place if the
105 -- convention is other than Ada, because that would disturb mixed-language
106 -- programs. Note that for the non-inherently-limited cases, we must make
107 -- the same decision for Ada 95 and 2005, so that mixed-dialect programs
108 -- will work.
110 function Is_Build_In_Place_Function_Call (N : Node_Id) return Boolean;
111 -- Ada 2005 (AI-318-02): Returns True if N denotes a call to a function
112 -- that requires handling as a build-in-place call or is a qualified
113 -- expression applied to such a call; otherwise returns False.
115 function Is_Build_In_Place_Function_Return (N : Node_Id) return Boolean;
116 -- Ada 2005 (AI-318-02): Returns True if N is an N_Simple_Return_Statement
117 -- or N_Extended_Return_Statement and it applies to a build-in-place
118 -- function or generic function.
120 procedure Make_Build_In_Place_Call_In_Allocator
121 (Allocator : Node_Id;
122 Function_Call : Node_Id);
123 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
124 -- occurs as the expression initializing an allocator, by passing access
125 -- to the allocated object as an additional parameter of the function call.
126 -- A new access object is declared that is initialized to the result of the
127 -- allocator, passed to the function, and the allocator is rewritten to
128 -- refer to that access object. Function_Call must denote either an
129 -- N_Function_Call node for which Is_Build_In_Place_Call is True, or else
130 -- an N_Qualified_Expression node applied to such a function call.
132 procedure Make_Build_In_Place_Call_In_Anonymous_Context
133 (Function_Call : Node_Id);
134 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
135 -- occurs in a context that does not provide a separate object. A temporary
136 -- object is created to act as the return object and an access to the
137 -- temporary is passed as an additional parameter of the call. This occurs
138 -- in contexts such as subprogram call actuals and object renamings.
139 -- Function_Call must denote either an N_Function_Call node for which
140 -- Is_Build_In_Place_Call is True, or else an N_Qualified_Expression node
141 -- applied to such a function call.
143 procedure Make_Build_In_Place_Call_In_Assignment
144 (Assign : Node_Id;
145 Function_Call : Node_Id);
146 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
147 -- occurs as the right-hand side of an assignment statement by passing
148 -- access to the left-hand side as an additional parameter of the function
149 -- call. Assign must denote a N_Assignment_Statement. Function_Call must
150 -- denote either an N_Function_Call node for which Is_Build_In_Place_Call
151 -- is True, or an N_Qualified_Expression node applied to such a function
152 -- call.
154 procedure Make_Build_In_Place_Call_In_Object_Declaration
155 (Object_Decl : Node_Id;
156 Function_Call : Node_Id);
157 -- Ada 2005 (AI-318-02): Handle a call to a build-in-place function that
158 -- occurs as the expression initializing an object declaration by
159 -- passing access to the declared object as an additional parameter of the
160 -- function call. Function_Call must denote either an N_Function_Call node
161 -- for which Is_Build_In_Place_Call is True, or an N_Qualified_Expression
162 -- node applied to such a function call.
164 end Exp_Ch6;