| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- T R E E P R -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, 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 |
with Types; use Types; |
| 27 |
package Treepr is |
| 28 |
|
| 29 |
-- This package provides printing routines for the abstract syntax tree. |
| 30 |
-- These routines are intended only for debugging use. |
| 31 |
|
| 32 |
procedure Tree_Dump; |
| 33 |
-- This routine is called from the GNAT main program to dump trees as |
| 34 |
-- requested by debug options (including tree of Standard if requested). |
| 35 |
|
| 36 |
procedure Print_Tree_Node (N : Node_Id; Label : String := ""); |
| 37 |
-- Prints a single tree node, without printing descendants. The Label |
| 38 |
-- string is used to preface each line of the printed output. |
| 39 |
|
| 40 |
procedure Print_Node_Briefly (N : Node_Id); |
| 41 |
-- Terse version of Print_Tree_Node |
| 42 |
|
| 43 |
procedure Print_Tree_List (L : List_Id); |
| 44 |
-- Prints a single node list, without printing the descendants of any |
| 45 |
-- of the nodes in the list. |
| 46 |
|
| 47 |
procedure Print_Tree_Elist (E : Elist_Id); |
| 48 |
-- Prints a single node list, without printing the descendants of any |
| 49 |
-- of the nodes in the list. |
| 50 |
|
| 51 |
procedure Print_Node_Subtree (N : Node_Id); |
| 52 |
-- Prints the subtree rooted at a specified tree node, including all |
| 53 |
-- referenced descendants. |
| 54 |
|
| 55 |
procedure Print_List_Subtree (L : List_Id); |
| 56 |
-- Prints the subtree consisting of the given node list and all its |
| 57 |
-- referenced descendants. |
| 58 |
|
| 59 |
procedure Print_Elist_Subtree (E : Elist_Id); |
| 60 |
-- Prints the subtree consisting of the given element list and all its |
| 61 |
-- referenced descendants. |
| 62 |
|
| 63 |
-- The following debugging procedures are intended to be called from gdb. |
| 64 |
-- Note that in several cases there are synonyms which represent historical |
| 65 |
-- development, and we keep them because some people are used to them! |
| 66 |
|
| 67 |
function p (N : Union_Id) return Node_Or_Entity_Id; |
| 68 |
function par (N : Union_Id) return Node_Or_Entity_Id; |
| 69 |
pragma Export (Ada, p); |
| 70 |
pragma Export (Ada, par); |
| 71 |
-- Return parent of a list or node (depending on the value of N). If N |
| 72 |
-- is neither a list nor a node id, then prints a message to that effect |
| 73 |
-- and returns Empty. |
| 74 |
|
| 75 |
procedure pn (N : Union_Id); |
| 76 |
procedure pp (N : Union_Id); |
| 77 |
procedure pe (N : Union_Id); |
| 78 |
pragma Export (Ada, pn); |
| 79 |
pragma Export (Ada, pp); |
| 80 |
pragma Export (Ada, pe); |
| 81 |
-- Print a node, node list, uint, or anything else that falls under |
| 82 |
-- the definition of Union_Id. Historically this was only for printing |
| 83 |
-- nodes, hence the name pn. These are all the same, but the renamings |
| 84 |
-- need to be in the body, or else the debugger can't find them. |
| 85 |
|
| 86 |
procedure ppar (N : Union_Id); |
| 87 |
pragma Export (Ada, ppar); |
| 88 |
-- Print the node, its parent, its parent's parent, and so on |
| 89 |
|
| 90 |
procedure pt (N : Union_Id); |
| 91 |
procedure ppp (N : Union_Id); |
| 92 |
pragma Export (Ada, pt); |
| 93 |
pragma Export (Ada, ppp); |
| 94 |
-- Same as pn/pp, except prints subtrees. For Nodes, it is exactly the same |
| 95 |
-- as Print_Node_Subtree. For Elists it is the same as Print_Elist_Subtree. |
| 96 |
-- For Lists, it is the same as Print_Tree_List. If given anything other |
| 97 |
-- than a Node, List, or Elist, same effect as pn. |
| 98 |
|
| 99 |
procedure pl (L : Int); |
| 100 |
pragma Export (Ada, pl); |
| 101 |
-- Same as Print_Tree_List, except that you can use e.g. 66 instead of |
| 102 |
-- -99999966. In other words for the positive case we fill out to 8 digits |
| 103 |
-- on the left and add a minus sign. This just saves some typing in the |
| 104 |
-- debugger. |
| 105 |
|
| 106 |
end Treepr; |