OSDN Git Service

Nathanael Nerode <neroden@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / sinfo-cn.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S I N F O . C N                              --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- GNAT was originally developed  by the GNAT team at  New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
25 --                                                                          --
26 ------------------------------------------------------------------------------
27
28 --  This child package of Sinfo contains some routines that permit in place
29 --  alteration of existing tree nodes by changing the value in the Nkind
30 --  field. Since Nkind functions logically in a manner similart to a variant
31 --  record discriminant part, such alterations cannot be permitted in a
32 --  general manner, but in some specific cases, the fields of related nodes
33 --  have been deliberately layed out in a manner that permits such alteration.
34 --  that determin
35
36 with Atree; use Atree;
37
38 package body Sinfo.CN is
39
40    use Atree.Unchecked_Access;
41    --  This package is one of the few packages which is allowed to make direct
42    --  references to tree nodes (since it is in the business of providing a
43    --  higher level of tree access which other clients are expected to use and
44    --  which implements checks).
45
46    ------------------------------------------------------------
47    -- Change_Character_Literal_To_Defining_Character_Literal --
48    ------------------------------------------------------------
49
50    procedure Change_Character_Literal_To_Defining_Character_Literal
51      (N : in out Node_Id)
52    is
53    begin
54       Set_Nkind (N, N_Defining_Character_Literal);
55       N := Extend_Node (N);
56    end Change_Character_Literal_To_Defining_Character_Literal;
57
58    ------------------------------------
59    -- Change_Conversion_To_Unchecked --
60    ------------------------------------
61
62    procedure Change_Conversion_To_Unchecked (N : Node_Id) is
63    begin
64       Set_Do_Overflow_Check (N, False);
65       Set_Do_Tag_Check (N, False);
66       Set_Do_Length_Check (N, False);
67       Set_Nkind (N, N_Unchecked_Type_Conversion);
68    end Change_Conversion_To_Unchecked;
69
70    ----------------------------------------------
71    -- Change_Identifier_To_Defining_Identifier --
72    ----------------------------------------------
73
74    procedure Change_Identifier_To_Defining_Identifier (N : in out Node_Id) is
75    begin
76       Set_Nkind (N, N_Defining_Identifier);
77       N := Extend_Node (N);
78    end Change_Identifier_To_Defining_Identifier;
79
80    --------------------------------------------------------
81    -- Change_Operator_Symbol_To_Defining_Operator_Symbol --
82    --------------------------------------------------------
83
84    procedure Change_Operator_Symbol_To_Defining_Operator_Symbol
85      (N : in out Node_Id)
86    is
87    begin
88       Set_Nkind (N, N_Defining_Operator_Symbol);
89       Set_Node2 (N, Empty); -- Clear unused Str2 field
90       N := Extend_Node (N);
91    end Change_Operator_Symbol_To_Defining_Operator_Symbol;
92
93    ----------------------------------------------
94    -- Change_Operator_Symbol_To_String_Literal --
95    ----------------------------------------------
96
97    procedure Change_Operator_Symbol_To_String_Literal (N : Node_Id) is
98    begin
99       Set_Nkind (N, N_String_Literal);
100       Set_Node1 (N, Empty); -- clear Name1 field
101    end Change_Operator_Symbol_To_String_Literal;
102
103    ------------------------------------------------
104    -- Change_Selected_Component_To_Expanded_Name --
105    ------------------------------------------------
106
107    procedure Change_Selected_Component_To_Expanded_Name (N : Node_Id) is
108    begin
109       Set_Nkind (N, N_Expanded_Name);
110       Set_Chars (N, Chars (Selector_Name (N)));
111    end Change_Selected_Component_To_Expanded_Name;
112
113 end Sinfo.CN;