1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2010-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. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with Atree
; use Atree
;
34 with Sinfo
; use Sinfo
;
35 with System
.HTable
; use System
.HTable
;
37 package body SCIL_LL
is
39 procedure Copy_SCIL_Node
(Target
: Node_Id
; Source
: Node_Id
);
40 -- Copy the SCIL field from Source to Target (it is used as the argument
41 -- for a call to Set_Reporting_Proc in package atree).
43 type Header_Num
is range 1 .. 4096;
45 function Hash
(N
: Node_Id
) return Header_Num
;
46 -- Hash function for Node_Ids
48 --------------------------
49 -- Internal Hash Tables --
50 --------------------------
52 package Contract_Only_Body_Flag
is new Simple_HTable
53 (Header_Num
=> Header_Num
,
59 -- This table records the value of flag Is_Contract_Only_Flag of tree nodes
61 package Contract_Only_Body_Nodes
is new Simple_HTable
62 (Header_Num
=> Header_Num
,
68 -- This table records the value of attribute Contract_Only_Body of tree
71 package SCIL_Nodes
is new Simple_HTable
72 (Header_Num
=> Header_Num
,
78 -- This table records the value of attribute SCIL_Node of tree nodes
84 procedure Copy_SCIL_Node
(Target
: Node_Id
; Source
: Node_Id
) is
86 Set_SCIL_Node
(Target
, Get_SCIL_Node
(Source
));
89 ----------------------------
90 -- Get_Contract_Only_Body --
91 ----------------------------
93 function Get_Contract_Only_Body
(N
: Node_Id
) return Node_Id
is
98 return Contract_Only_Body_Nodes
.Get
(N
);
102 end Get_Contract_Only_Body
;
108 function Get_SCIL_Node
(N
: Node_Id
) return Node_Id
is
113 return SCIL_Nodes
.Get
(N
);
123 function Hash
(N
: Node_Id
) return Header_Num
is
125 return Header_Num
(1 + N
mod Node_Id
(Header_Num
'Last));
132 procedure Initialize
is
135 Contract_Only_Body_Nodes
.Reset
;
136 Contract_Only_Body_Flag
.Reset
;
137 Set_Reporting_Proc
(Copy_SCIL_Node
'Access);
140 ---------------------------
141 -- Is_Contract_Only_Body --
142 ---------------------------
144 function Is_Contract_Only_Body
(E
: Entity_Id
) return Boolean is
146 return Contract_Only_Body_Flag
.Get
(E
);
147 end Is_Contract_Only_Body
;
149 ----------------------------
150 -- Set_Contract_Only_Body --
151 ----------------------------
153 procedure Set_Contract_Only_Body
(N
: Node_Id
; Value
: Node_Id
) is
155 pragma Assert
(CodePeer_Mode
157 and then Is_Contract_Only_Body
(Value
));
159 Contract_Only_Body_Nodes
.Set
(N
, Value
);
160 end Set_Contract_Only_Body
;
162 -------------------------------
163 -- Set_Is_Contract_Only_Body --
164 -------------------------------
166 procedure Set_Is_Contract_Only_Body
(E
: Entity_Id
) is
168 Contract_Only_Body_Flag
.Set
(E
, True);
169 end Set_Is_Contract_Only_Body
;
175 procedure Set_SCIL_Node
(N
: Node_Id
; Value
: Node_Id
) is
177 pragma Assert
(Generate_SCIL
);
179 if Present
(Value
) then
180 case Nkind
(Value
) is
181 when N_SCIL_Dispatch_Table_Tag_Init
=>
182 pragma Assert
(Nkind
(N
) = N_Object_Declaration
);
185 when N_SCIL_Dispatching_Call
=>
186 pragma Assert
(Nkind
(N
) in N_Subprogram_Call
);
189 when N_SCIL_Membership_Test
=>
190 pragma Assert
(Nkind_In
(N
, N_Identifier
,
193 N_Expression_With_Actions
));
197 pragma Assert
(False);
202 SCIL_Nodes
.Set
(N
, Value
);