1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- E X P _ S P A R K --
9 -- Copyright (C) 1992-2013, 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 Exp_Dbug
; use Exp_Dbug
;
29 with Exp_Util
; use Exp_Util
;
30 with Sem_Res
; use Sem_Res
;
31 with Sem_Util
; use Sem_Util
;
32 with Sinfo
; use Sinfo
;
34 package body Exp_SPARK
is
36 -----------------------
37 -- Local Subprograms --
38 -----------------------
40 procedure Expand_SPARK_N_Object_Renaming_Declaration
(N
: Node_Id
);
41 -- Perform name evaluation for a renamed object
43 procedure Expand_Potential_Renaming
(N
: Node_Id
);
44 -- N denotes a N_Identifier or N_Expanded_Name. If N references a renaming,
45 -- replace N with the renamed object.
51 procedure Expand_SPARK
(N
: Node_Id
) is
55 -- Qualification of entity names in formal verification mode
56 -- is limited to the addition of a suffix for homonyms (see
57 -- Exp_Dbug.Qualify_Entity_Name). We used to qualify entity names
58 -- as full expansion does, but this was removed as this prevents the
59 -- verification back-end from using a short name for debugging and
60 -- user interaction. The verification back-end already takes care
61 -- of qualifying names when needed.
63 when N_Block_Statement |
65 N_Package_Declaration |
67 Qualify_Entity_Names
(N
);
69 when N_Expanded_Name |
71 Expand_Potential_Renaming
(N
);
73 when N_Object_Renaming_Declaration
=>
74 Expand_SPARK_N_Object_Renaming_Declaration
(N
);
76 -- In SPARK mode, no other constructs require expansion
83 ------------------------------------------------
84 -- Expand_SPARK_N_Object_Renaming_Declaration --
85 ------------------------------------------------
87 procedure Expand_SPARK_N_Object_Renaming_Declaration
(N
: Node_Id
) is
89 -- Unconditionally remove all side effects from the name
91 Evaluate_Name
(Name
(N
));
92 end Expand_SPARK_N_Object_Renaming_Declaration
;
94 -------------------------------
95 -- Expand_Potential_Renaming --
96 -------------------------------
98 procedure Expand_Potential_Renaming
(N
: Node_Id
) is
99 E
: constant Entity_Id
:= Entity
(N
);
100 T
: constant Entity_Id
:= Etype
(N
);
103 -- Replace a reference to a renaming with the actual renamed object
105 if Ekind
(E
) in Object_Kind
and then Present
(Renamed_Object
(E
)) then
106 Rewrite
(N
, New_Copy_Tree
(Renamed_Object
(E
)));
107 Reset_Analyzed_Flags
(N
);
108 Analyze_And_Resolve
(N
, T
);
110 end Expand_Potential_Renaming
;