OSDN Git Service

2006-10-31 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / sprint.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S P R I N T                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2006, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package (source print) contains routines for printing the source
28 --  program corresponding to a specified syntax tree. These routines are
29 --  intended for debugging use in the compiler (not as a user level pretty
30 --  print tool). Only information present in the tree is output (e.g. no
31 --  comments are present in the output), and as far as possible we avoid
32 --  making any assumptions about the correctness of the tree, so a bad
33 --  tree may either blow up on a debugging check, or list incorrect source.
34
35 with Types; use Types;
36 package Sprint is
37
38    -----------------------
39    -- Syntax Extensions --
40    -----------------------
41
42    --  When the generated tree is printed, it contains constructs that are not
43    --  pure Ada. For convenience, syntactic extensions to Ada have been defined
44    --  purely for the purposes of this printout (they are not recognized by the
45    --  parser)
46
47    --    Allocator                           new xxx [storage_pool = xxx]
48    --    Cleanup action                      at end procedure name;
49    --    Conditional expression              (if expr then expr else expr)
50    --    Conversion wi Float_Truncate        target^(source)
51    --    Convert wi Conversion_OK            target?(source)
52    --    Convert wi Rounded_Result           target@(source)
53    --    Divide wi Treat_Fixed_As_Integer    x #/ y
54    --    Divide wi Rounded_Result            x @/ y
55    --    Expression with range check         {expression}
56    --    Operator with range check           {operator} (e.g. {+})
57    --    Free statement                      free expr [storage_pool = xxx]
58    --    Freeze entity with freeze actions   freeze entityname [ actions ]
59    --    Implicit call to run time routine   $routine-name
60    --    Interpretation                      interpretation type [, entity]
61    --    Intrinsic calls                     function-name!(arg, arg, arg)
62    --    Itype declaration                   [(sub)type declaration without ;]
63    --    Itype reference                     reference itype
64    --    Label declaration                   labelname : label
65    --    Mod wi Treat_Fixed_As_Integer       x #mod y
66    --    Multiple concatenation              expr && expr && expr ... && expr
67    --    Multiply wi Treat_Fixed_As_Integer  x #* y
68    --    Multiply wi Rounded_Result          x @* y
69    --    Others choice for cleanup           when all others
70    --    Raise xxx error                     [xxx_error [when cond]]
71    --    Raise xxx error with msg            [xxx_error [when cond], "msg"]
72    --    Rational literal                    See UR_Write for details
73    --    Rem wi Treat_Fixed_As_Integer       x #rem y
74    --    Reference                           expression'reference
75    --    Shift nodes                         shift_name!(expr, count)
76    --    Subprogram_Info                     subprog'Subprogram_Info
77    --    Unchecked conversion                target_type!(source_expression)
78    --    Unchecked expression                `(expression)
79    --    Validate_Unchecked_Conversion       validate unchecked_conversion
80    --                                                  (src-type, target-typ);
81
82    --  Note: the storage_pool parameters for allocators and the free node
83    --  are omitted if the Storage_Pool field is Empty, indicating use of
84    --  the standard default pool.
85
86    -----------------
87    -- Subprograms --
88    -----------------
89
90    procedure Source_Dump;
91    --  This routine is called from the GNAT main program to dump source as
92    --  requested by debug options. The relevant debug options are:
93    --    -ds  print source from tree, both original and generated code
94    --    -dg  print source from tree, including only the generated code
95    --    -do  print source from tree, including only the original code
96    --    -df  modify the above to include all units, not just the main unit
97    --    -sz  print source from tree for package Standard
98
99    procedure Sprint_Comma_List (List : List_Id);
100    --  Prints the nodes in a list, with separating commas. If the list
101    --  is empty then no output is generated.
102
103    procedure Sprint_Paren_Comma_List (List : List_Id);
104    --  Prints the nodes in a list, surrounded by parentheses, and separated
105    --  by comas. If the list is empty, then no output is generated. A blank
106    --  is output before the initial left parenthesis.
107
108    procedure Sprint_Opt_Paren_Comma_List (List : List_Id);
109    --  Same as normal Sprint_Paren_Comma_List procedure, except that
110    --  an extra blank is output if List is non-empty, and nothing at all is
111    --  printed it the argument is No_List.
112
113    procedure Sprint_Node_List (List : List_Id);
114    --  Prints the nodes in a list with no separating characters. This is used
115    --  in the case of lists of items which are printed on separate lines using
116    --  the current indentation amount. Note that Sprint_Node_List itself
117    --  does not generate any New_Line calls.
118
119    procedure Sprint_Opt_Node_List (List : List_Id);
120    --  Like Sprint_Node_List, but prints nothing if List = No_List
121
122    procedure Sprint_Indented_List (List : List_Id);
123    --  Like Sprint_Line_List, except that the indentation level is
124    --  increased before outputting the list of items, and then decremented
125    --  (back to its original level) before returning to the caller.
126
127    procedure Sprint_Node (Node : Node_Id);
128    --  Prints a single node. No new lines are output, except as required for
129    --  splitting lines that are too long to fit on a single physical line.
130    --  No output is generated at all if Node is Empty. No trailing or leading
131    --  blank characters are generated.
132
133    procedure Sprint_Opt_Node (Node : Node_Id);
134    --  Same as normal Sprint_Node procedure, except that one leading
135    --  blank is output before the node if it is non-empty.
136
137    procedure pg (Node : Node_Id);
138    pragma Export (Ada, pg);
139    --  Print generated source for node N (like -gnatdg output). This is
140    --  intended only for use from gdb for debugging purposes.
141
142    procedure po (Node : Node_Id);
143    pragma Export (Ada, po);
144    --  Print original source for node N (like -gnatdo output). This is
145    --  intended only for use from gdb for debugging purposes.
146
147    procedure ps (Node : Node_Id);
148    pragma Export (Ada, ps);
149    --  Print generated and original source for node N (like -gnatds output).
150    --  This is intended only for use from gdb for debugging purposes.
151
152 end Sprint;