]>
Commit | Line | Data |
---|---|---|
996ae0b0 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- S P R I N T -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
1d005acc | 9 | -- Copyright (C) 1992-2019, Free Software Foundation, Inc. -- |
996ae0b0 RK |
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- -- | |
b5c84c3c | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
996ae0b0 RK |
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 -- | |
b5c84c3c RD |
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. -- | |
996ae0b0 RK |
20 | -- -- |
21 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 22 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
996ae0b0 RK |
23 | -- -- |
24 | ------------------------------------------------------------------------------ | |
25 | ||
26 | -- This package (source print) contains routines for printing the source | |
27 | -- program corresponding to a specified syntax tree. These routines are | |
28 | -- intended for debugging use in the compiler (not as a user level pretty | |
29 | -- print tool). Only information present in the tree is output (e.g. no | |
30 | -- comments are present in the output), and as far as possible we avoid | |
31 | -- making any assumptions about the correctness of the tree, so a bad | |
32 | -- tree may either blow up on a debugging check, or list incorrect source. | |
33 | ||
34 | with Types; use Types; | |
d4fc0fb4 | 35 | |
996ae0b0 RK |
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 | |
9c5719f6 | 45 | -- parser). |
996ae0b0 | 46 | |
0c1edb56 ES |
47 | -- Could use more documentation for all of these ??? |
48 | ||
996ae0b0 RK |
49 | -- Allocator new xxx [storage_pool = xxx] |
50 | -- Cleanup action at end procedure name; | |
996ae0b0 | 51 | -- Convert wi Conversion_OK target?(source) |
5aa76fe1 | 52 | -- Convert wi Float_Truncate target^(source) |
996ae0b0 RK |
53 | -- Convert wi Rounded_Result target@(source) |
54 | -- Divide wi Treat_Fixed_As_Integer x #/ y | |
55 | -- Divide wi Rounded_Result x @/ y | |
955871d3 | 56 | -- Expression with actions do action; .. action; in expr end |
996ae0b0 | 57 | -- Expression with range check {expression} |
996ae0b0 RK |
58 | -- Free statement free expr [storage_pool = xxx] |
59 | -- Freeze entity with freeze actions freeze entityname [ actions ] | |
5a8a6763 | 60 | -- Freeze generic entity freeze_generic entityname |
62b80eaf | 61 | -- Implicit call to run time routine $routine-name |
b99282c4 RD |
62 | -- Implicit exportation $pragma import (...) |
63 | -- Implicit importation $pragma export (...) | |
996ae0b0 RK |
64 | -- Interpretation interpretation type [, entity] |
65 | -- Intrinsic calls function-name!(arg, arg, arg) | |
653da906 | 66 | -- Itype declaration [(sub)type declaration without ;] |
996ae0b0 RK |
67 | -- Itype reference reference itype |
68 | -- Label declaration labelname : label | |
69 | -- Mod wi Treat_Fixed_As_Integer x #mod y | |
70 | -- Multiple concatenation expr && expr && expr ... && expr | |
71 | -- Multiply wi Treat_Fixed_As_Integer x #* y | |
72 | -- Multiply wi Rounded_Result x @* y | |
c936411f | 73 | -- Operator with overflow check {operator} (e.g. {+}) |
996ae0b0 | 74 | -- Others choice for cleanup when all others |
f28573f4 ES |
75 | -- Pop exception label %pop_xxx_exception_label |
76 | -- Push exception label %push_xxx_exception_label (label) | |
07fc65c4 GB |
77 | -- Raise xxx error [xxx_error [when cond]] |
78 | -- Raise xxx error with msg [xxx_error [when cond], "msg"] | |
0d57c6f4 | 79 | -- Rational literal [expression] |
996ae0b0 RK |
80 | -- Rem wi Treat_Fixed_As_Integer x #rem y |
81 | -- Reference expression'reference | |
82 | -- Shift nodes shift_name!(expr, count) | |
0c1edb56 | 83 | -- Static declaration name : static xxx |
996ae0b0 RK |
84 | -- Unchecked conversion target_type!(source_expression) |
85 | -- Unchecked expression `(expression) | |
86 | -- Validate_Unchecked_Conversion validate unchecked_conversion | |
87 | -- (src-type, target-typ); | |
88 | ||
6fb4cdde AC |
89 | -- Note: the storage_pool parameters for allocators and the free node are |
90 | -- omitted if the Storage_Pool field is Empty, indicating use of the | |
91 | -- standard default pool. | |
996ae0b0 RK |
92 | |
93 | ----------------- | |
94 | -- Subprograms -- | |
95 | ----------------- | |
96 | ||
97 | procedure Source_Dump; | |
98 | -- This routine is called from the GNAT main program to dump source as | |
99 | -- requested by debug options. The relevant debug options are: | |
100 | -- -ds print source from tree, both original and generated code | |
101 | -- -dg print source from tree, including only the generated code | |
102 | -- -do print source from tree, including only the original code | |
103 | -- -df modify the above to include all units, not just the main unit | |
104 | -- -sz print source from tree for package Standard | |
105 | ||
106 | procedure Sprint_Comma_List (List : List_Id); | |
6fb4cdde AC |
107 | -- Prints the nodes in a list, with separating commas. If the list is empty |
108 | -- then no output is generated. | |
996ae0b0 RK |
109 | |
110 | procedure Sprint_Paren_Comma_List (List : List_Id); | |
6fb4cdde AC |
111 | -- Prints the nodes in a list, surrounded by parentheses, and separated by |
112 | -- commas. If the list is empty, then no output is generated. A blank is | |
113 | -- output before the initial left parenthesis. | |
996ae0b0 RK |
114 | |
115 | procedure Sprint_Opt_Paren_Comma_List (List : List_Id); | |
6fb4cdde AC |
116 | -- Same as normal Sprint_Paren_Comma_List procedure, except that an extra |
117 | -- blank is output if List is non-empty, and nothing at all is printed it | |
118 | -- the argument is No_List. | |
996ae0b0 | 119 | |
3ffd18f1 | 120 | procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False); |
996ae0b0 RK |
121 | -- Prints the nodes in a list with no separating characters. This is used |
122 | -- in the case of lists of items which are printed on separate lines using | |
3ffd18f1 AC |
123 | -- the current indentation amount. New_Lines controls the generation of |
124 | -- New_Line calls. If False, no New_Line calls are generated. If True, | |
125 | -- then New_Line calls are generated as needed to ensure that each list | |
126 | -- item starts at the beginning of a line. | |
996ae0b0 RK |
127 | |
128 | procedure Sprint_Opt_Node_List (List : List_Id); | |
9de61fcb | 129 | -- Like Sprint_Node_List, but prints nothing if List = No_List |
996ae0b0 RK |
130 | |
131 | procedure Sprint_Indented_List (List : List_Id); | |
6fb4cdde AC |
132 | -- Like Sprint_Line_List, except that the indentation level is increased |
133 | -- before outputting the list of items, and then decremented (back to its | |
134 | -- original level) before returning to the caller. | |
996ae0b0 RK |
135 | |
136 | procedure Sprint_Node (Node : Node_Id); | |
137 | -- Prints a single node. No new lines are output, except as required for | |
138 | -- splitting lines that are too long to fit on a single physical line. | |
139 | -- No output is generated at all if Node is Empty. No trailing or leading | |
140 | -- blank characters are generated. | |
141 | ||
142 | procedure Sprint_Opt_Node (Node : Node_Id); | |
6fb4cdde AC |
143 | -- Same as normal Sprint_Node procedure, except that one leading blank is |
144 | -- output before the node if it is non-empty. | |
996ae0b0 | 145 | |
0c1edb56 | 146 | procedure pg (Arg : Union_Id); |
07fc65c4 | 147 | pragma Export (Ada, pg); |
0c1edb56 ES |
148 | -- Print generated source for argument N (like -gnatdg output). Intended |
149 | -- only for use from gdb for debugging purposes. Currently, Arg may be a | |
150 | -- List_Id or a Node_Id (anything else outputs a blank line). | |
996ae0b0 | 151 | |
0c1edb56 | 152 | procedure po (Arg : Union_Id); |
07fc65c4 | 153 | pragma Export (Ada, po); |
0c1edb56 | 154 | -- Like pg, but prints original source for the argument (like -gnatdo |
3ffd18f1 AC |
155 | -- output). Intended only for use from gdb for debugging purposes. In |
156 | -- the list case, an end of line is output to separate list elements. | |
996ae0b0 | 157 | |
0c1edb56 | 158 | procedure ps (Arg : Union_Id); |
07fc65c4 | 159 | pragma Export (Ada, ps); |
0c1edb56 ES |
160 | -- Like pg, but prints generated and original source for the argument (like |
161 | -- -gnatds output). Intended only for use from gdb for debugging purposes. | |
3ffd18f1 | 162 | -- In the list case, an end of line is output to separate list elements. |
996ae0b0 RK |
163 | |
164 | end Sprint; |