1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- S E M _ C A S E --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1996-2010, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
13 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- Package containing the routines to process a list of discrete choices.
|
27 |
|
|
-- Such lists can occur in two different constructs: case statements and
|
28 |
|
|
-- record variants. We have factorized what used to be two very similar
|
29 |
|
|
-- sets of routines in one place. These are not currently used for the
|
30 |
|
|
-- aggregate case, since issues with nested aggregates make that case
|
31 |
|
|
-- substantially different.
|
32 |
|
|
|
33 |
|
|
with Types; use Types;
|
34 |
|
|
|
35 |
|
|
package Sem_Case is
|
36 |
|
|
|
37 |
|
|
procedure No_OP (C : Node_Id);
|
38 |
|
|
-- The no-operation routine. Does absolutely nothing. Can be used
|
39 |
|
|
-- in the following generic for the parameter Process_Empty_Choice.
|
40 |
|
|
|
41 |
|
|
generic
|
42 |
|
|
with function Get_Alternatives (N : Node_Id) return List_Id;
|
43 |
|
|
-- Function needed to get to the actual list of case statement
|
44 |
|
|
-- alternatives, or array aggregate component associations or
|
45 |
|
|
-- record variants from which we can then access the actual lists
|
46 |
|
|
-- of discrete choices. N is the node for the original construct
|
47 |
|
|
-- i.e. a case statement, an array aggregate or a record variant.
|
48 |
|
|
|
49 |
|
|
with function Get_Choices (A : Node_Id) return List_Id;
|
50 |
|
|
-- Given a case statement alternative, array aggregate component
|
51 |
|
|
-- association or record variant A we need different access functions
|
52 |
|
|
-- to get to the actual list of discrete choices.
|
53 |
|
|
|
54 |
|
|
with procedure Process_Empty_Choice (Choice : Node_Id);
|
55 |
|
|
-- Processing to carry out for an empty Choice
|
56 |
|
|
|
57 |
|
|
with procedure Process_Non_Static_Choice (Choice : Node_Id);
|
58 |
|
|
-- Processing to carry out for a non static Choice
|
59 |
|
|
|
60 |
|
|
with procedure Process_Associated_Node (A : Node_Id);
|
61 |
|
|
-- Associated with each case alternative, aggregate component
|
62 |
|
|
-- association or record variant A there is a node or list of nodes
|
63 |
|
|
-- that need semantic processing. This routine implements that
|
64 |
|
|
-- processing.
|
65 |
|
|
|
66 |
|
|
package Generic_Choices_Processing is
|
67 |
|
|
|
68 |
|
|
procedure Analyze_Choices
|
69 |
|
|
(N : Node_Id;
|
70 |
|
|
Subtyp : Entity_Id;
|
71 |
|
|
Raises_CE : out Boolean;
|
72 |
|
|
Others_Present : out Boolean);
|
73 |
|
|
-- From a case expression, case statement, array aggregate or record
|
74 |
|
|
-- variant N, this routine analyzes the corresponding list of discrete
|
75 |
|
|
-- choices. Subtyp is the subtype of the discrete choices. The type
|
76 |
|
|
-- against which the discrete choices must be resolved is its base type.
|
77 |
|
|
--
|
78 |
|
|
-- In one of the bounds of a discrete choice raises a constraint
|
79 |
|
|
-- error the flag Raise_CE is set.
|
80 |
|
|
--
|
81 |
|
|
-- Finally Others_Present is set to True if an Others choice is present
|
82 |
|
|
-- in the list of choices, and in this case the call also sets
|
83 |
|
|
-- Others_Discrete_Choices in the N_Others_Choice node.
|
84 |
|
|
|
85 |
|
|
end Generic_Choices_Processing;
|
86 |
|
|
|
87 |
|
|
end Sem_Case;
|