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