LCOV - code coverage report
Current view: top level - gcc/m2/gm2-gcc - m2pp.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 0.2 % 1639 4
Test Date: 2026-02-28 14:20:25 Functions: 0.8 % 124 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* m2pp.c pretty print trees, output in Modula-2 where possible.
       2              : 
       3              : Copyright (C) 2007-2026 Free Software Foundation, Inc.
       4              : Contributed by Gaius Mulley <gaius@glam.ac.uk>.
       5              : 
       6              : This file is part of GNU Modula-2.
       7              : 
       8              : GNU Modula-2 is free software; you can redistribute it and/or modify
       9              : it under the terms of the GNU General Public License as published by
      10              : the Free Software Foundation; either version 3, or (at your option)
      11              : any later version.
      12              : 
      13              : GNU Modula-2 is distributed in the hope that it will be useful, but
      14              : WITHOUT ANY WARRANTY; without even the implied warranty of
      15              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16              : General Public License for more details.
      17              : 
      18              : You should have received a copy of the GNU General Public License
      19              : along with GNU Modula-2; see the file COPYING3.  If not see
      20              : <http://www.gnu.org/licenses/>.  */
      21              : 
      22              : #include "gcc-consolidation.h"
      23              : 
      24              : #include "../m2-tree.h"
      25              : #include "../gm2-lang.h"
      26              : 
      27              : #include "m2tree.h"
      28              : #include "m2expr.h"
      29              : #include "m2type.h"
      30              : #include "m2decl.h"
      31              : #include "m2options.h"
      32              : #include "m2langdump.h"
      33              : 
      34              : #define M2PP_C
      35              : #include "m2pp.h"
      36              : 
      37              : #define GM2
      38              : /* VERBOSE_TYPE_DESC enables type descriptions to be generated in the
      39              :    assignment and during variable declarations.  It generates
      40              :    moderately ugly output, although the assignment type information
      41              :    can be useful when tracking down non gimple complient trees (during
      42              :    assignment).  */
      43              : #undef VERBOSE_TYPE_DESC
      44              : 
      45              : const char *m2pp_dump_description[M2PP_DUMP_END] =
      46              : {
      47              :   "interactive user invoked output",
      48              :   "modula-2 gimple trees pre genercize",
      49              :   "modula-2 gimple trees post genercize",
      50              : };
      51              : 
      52              : namespace modula2 {
      53              : 
      54              : #undef DEBUGGING
      55              : 
      56              : typedef struct pretty_t
      57              : {
      58              :   m2pp_dump_kind output;
      59              :   bool needs_space;
      60              :   bool needs_indent;
      61              :   int curpos;
      62              :   int indent;
      63              :   bool issued_begin;
      64              :   bool in_vars;
      65              :   bool in_types;
      66              :   tree block;
      67              :   int bits;
      68              : } pretty;
      69              : 
      70              : typedef struct m2stack_t
      71              : {
      72              :   tree value;
      73              :   struct m2stack_t *next;
      74              : } stack;
      75              : 
      76              : /* Prototypes.  */
      77              : 
      78              : static pretty *initPretty (m2pp_dump_kind kind, int bits);
      79              : static pretty *dupPretty (pretty *s);
      80              : static int getindent (pretty *s);
      81              : static void setindent (pretty *s, int n);
      82              : static int getcurpos (pretty *s);
      83              : static void m2pp_identifier (pretty *s, tree t);
      84              : static void m2pp_needspace (pretty *s);
      85              : static void m2pp_function (pretty *s, tree t);
      86              : static void m2pp_function_header (pretty *s, tree t);
      87              : static void m2pp_function_vars (pretty *s, tree t);
      88              : static void m2pp_statement_sequence (pretty *s, tree t);
      89              : static void m2pp_print (pretty *s, const char *p);
      90              : static void m2pp_print_char (pretty *s, char ch);
      91              : static void m2pp_parameter (pretty *s, tree t);
      92              : static void m2pp_type (pretty *s, tree t);
      93              : static void m2pp_ident_pointer (pretty *s, tree t);
      94              : static void m2pp_set_type (pretty *s, tree t);
      95              : static void m2pp_enum (pretty *s, tree t);
      96              : static void m2pp_array (pretty *s, tree t);
      97              : static void m2pp_subrange (pretty *s, tree t);
      98              : static void m2pp_gimpified (pretty *s, tree t);
      99              : static void m2pp_pointer_type (pretty *s, tree t);
     100              : static void m2pp_record_type (pretty *s, tree t);
     101              : static void m2pp_union_type (pretty *s, tree t);
     102              : static void m2pp_simple_type (pretty *s, tree t);
     103              : static void m2pp_expression (pretty *s, tree t);
     104              : static void m2pp_relop (pretty *s, tree t, const char *p);
     105              : static void m2pp_simple_expression (pretty *s, tree t);
     106              : static void m2pp_statement_sequence (pretty *s, tree t);
     107              : static void m2pp_unknown (pretty *s, const char *s1, const char *s2);
     108              : static void m2pp_statement (pretty *s, tree t);
     109              : static void m2pp_assignment (pretty *s, tree t);
     110              : static void m2pp_designator (pretty *s, tree t);
     111              : static void m2pp_conditional (pretty *s, tree t);
     112              : static void m2pp_label_expr (pretty *s, tree t);
     113              : static void m2pp_label_decl (pretty *s, tree t);
     114              : static void m2pp_goto (pretty *s, tree t);
     115              : static void m2pp_list (pretty *s, tree t);
     116              : static void m2pp_offset (pretty *s, tree t);
     117              : static void m2pp_indirect_ref (pretty *s, tree t);
     118              : static void m2pp_integer_cst (pretty *s, tree t);
     119              : static void m2pp_real_cst (pretty *s, tree t);
     120              : static void m2pp_string_cst (pretty *s, tree t);
     121              : static void m2pp_integer (pretty *s, tree t);
     122              : static void m2pp_addr_expr (pretty *s, tree t);
     123              : static void m2pp_nop (pretty *s, tree t);
     124              : static void m2pp_convert (pretty *s, tree t);
     125              : static void m2pp_var_decl (pretty *s, tree t);
     126              : static void m2pp_binary (pretty *s, tree t, const char *p);
     127              : static void m2pp_unary (pretty *s, tree t, const char *p);
     128              : static void m2pp_call_expr (pretty *s, tree t);
     129              : static void m2pp_procedure_call (pretty *s, tree t);
     130              : static void m2pp_ssa (pretty *s, tree t);
     131              : static void m2pp_block (pretty *s, tree t);
     132              : static void m2pp_block_list (pretty *s, tree t);
     133              : static void m2pp_var_list (pretty *s, tree t);
     134              : static void m2pp_bind_expr (pretty *s, tree t);
     135              : static void m2pp_return_expr (pretty *s, tree t);
     136              : static void m2pp_result_decl (pretty *s, tree t);
     137              : static void m2pp_try_block (pretty *s, tree t);
     138              : static void m2pp_cleanup_point_expr (pretty *s, tree t);
     139              : static void m2pp_handler (pretty *s, tree t);
     140              : static void m2pp_component_ref (pretty *s, tree t);
     141              : static void m2pp_array_ref (pretty *s, tree t);
     142              : static void m2pp_begin (pretty *s);
     143              : static void m2pp_var (pretty *s);
     144              : static void m2pp_types (pretty *s);
     145              : static void m2pp_decl_expr (pretty *s, tree t);
     146              : static void m2pp_var_type_decl (pretty *s, tree t);
     147              : static void m2pp_non_lvalue_expr (pretty *s, tree t);
     148              : static void m2pp_procedure_type (pretty *s, tree t);
     149              : static void m2pp_param_type (pretty *s, tree t);
     150              : static void m2pp_type_lowlevel (pretty *s, tree t);
     151              : static void m2pp_try_catch_expr (pretty *s, tree t);
     152              : static void m2pp_throw (pretty *s, tree t);
     153              : static void m2pp_catch_expr (pretty *s, tree t);
     154              : static void m2pp_try_finally_expr (pretty *s, tree t);
     155              : static void m2pp_complex (pretty *s, tree t);
     156              : static void killPretty (pretty *s);
     157              : static void m2pp_compound_expression (pretty *s, tree t);
     158              : static void m2pp_target_expression (pretty *s, tree t);
     159              : static void m2pp_constructor (pretty *s, tree t);
     160              : static void m2pp_translation (pretty *s, tree t);
     161              : static void m2pp_module_block (pretty *s, tree t);
     162              : static void push (tree t);
     163              : static void pop (void);
     164              : static bool begin_printed (tree t);
     165              : static void m2pp_decl_list (pretty *s, tree t);
     166              : static void m2pp_loc (pretty *s, tree t);
     167              : static FILE *getoutput (pretty *s);
     168              : 
     169              : 
     170              : void pet (tree t);
     171              : void m2pp_integer (pretty *s, tree t);
     172              : 
     173              : extern void stop (void);
     174              : 
     175              : static stack *stackPtr = NULL;
     176              : static FILE *m2pp_output_file[M2PP_DUMP_END];
     177              : 
     178              : /* do_pf helper function for pf.  */
     179              : 
     180              : void
     181            0 : do_pf (tree t, int bits)
     182              : {
     183            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, bits);
     184              : 
     185            0 :   if (TREE_CODE (t) == TRANSLATION_UNIT_DECL)
     186            0 :     m2pp_translation (state, t);
     187            0 :   else if (TREE_CODE (t) == BLOCK)
     188            0 :     m2pp_module_block (state, t);
     189            0 :   else if (TREE_CODE (t) == FUNCTION_DECL)
     190            0 :     m2pp_function (state, t);
     191              :   else
     192            0 :     m2pp_statement_sequence (state, t);
     193            0 :   killPretty (state);
     194            0 : }
     195              : 
     196              : /* pf print function.  Expected to be printed interactively from
     197              :    the debugger: print modula2::pf(func), or to be called from code.  */
     198              : 
     199              : void
     200            0 : pf (tree t)
     201              : {
     202            0 :   do_pf (t, false);
     203            0 : }
     204              : 
     205              : /* pe print expression.  Expected to be printed interactively from
     206              :    the debugger: print modula2::pe(expr), or to be called from code.  */
     207              : 
     208              : void
     209            0 : pe (tree t)
     210              : {
     211            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     212              : 
     213            0 :   m2pp_expression (state, t);
     214            0 :   m2pp_needspace (state);
     215            0 :   m2pp_print (state, ";\n");
     216            0 :   killPretty (state);
     217            0 : }
     218              : 
     219              : /* pet print expression and its type.  Expected to be printed
     220              :    interactively from the debugger: print modula2::pet(expr), or to
     221              :    be called from code.  */
     222              : 
     223              : void
     224            0 : pet (tree t)
     225              : {
     226            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     227              : 
     228            0 :   m2pp_expression (state, t);
     229            0 :   m2pp_needspace (state);
     230            0 :   m2pp_print (state, ":");
     231            0 :   m2pp_type (state, TREE_TYPE (t));
     232            0 :   m2pp_print (state, ";\n");
     233            0 :   killPretty (state);
     234            0 : }
     235              : 
     236              : /* pt print type.  Expected to be printed interactively from the
     237              :    debugger: print pt(expr), or to be called from code.  */
     238              : 
     239              : void
     240            0 : pt (tree t)
     241              : {
     242            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     243            0 :   m2pp_type (state, t);
     244            0 :   m2pp_needspace (state);
     245            0 :   m2pp_print (state, ";\n");
     246            0 :   killPretty (state);
     247            0 : }
     248              : 
     249              : /* ptl print type low level.  Expected to be printed interactively
     250              :    from the debugger: print ptl(type), or to be called from code.  */
     251              : 
     252              : void
     253            0 : ptl (tree t)
     254              : {
     255            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     256            0 :   m2pp_type_lowlevel (state, t);
     257            0 :   m2pp_needspace (state);
     258            0 :   m2pp_print (state, ";\n");
     259            0 :   killPretty (state);
     260            0 : }
     261              : 
     262              : /* ptcl print TREE_CHAINed list.  */
     263              : 
     264              : void
     265            0 : ptcl (tree t)
     266              : {
     267            0 :   pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     268              : 
     269            0 :   m2pp_decl_list (state, t);
     270            0 :   m2pp_print (state, "\n");
     271            0 :   killPretty (state);
     272            0 : }
     273              : 
     274              : /* loc if tree has a location then display it within a comment.  */
     275              : 
     276              : static void
     277            0 : m2pp_loc (pretty *s, tree t)
     278              : {
     279            0 :   if (CAN_HAVE_LOCATION_P (t))
     280              :     {
     281            0 :       if (EXPR_HAS_LOCATION (t))
     282              :         {
     283            0 :           if (EXPR_LOCATION (t) == UNKNOWN_LOCATION)
     284            0 :             m2pp_print (s, "(* missing location1 *)\n");
     285              :           else
     286              :             {
     287            0 :               expanded_location l = expand_location (EXPR_LOCATION (t));
     288              : 
     289            0 :               m2pp_print (s, "(* ");
     290            0 :               m2pp_print (s, l.file);
     291            0 :               m2pp_print (s, ":");
     292            0 :               fprintf (getoutput (s), "%d", l.line);
     293            0 :               m2pp_print (s, " *)");
     294            0 :               m2pp_print (s, "\n");
     295              :             }
     296              :         }
     297              :       else
     298              :         {
     299            0 :           m2pp_print (s, "(* missing location2 *)\n");
     300              :         }
     301              :     }
     302            0 : }
     303              : 
     304              : /* m2pp_decl_list prints a TREE_CHAINed list for a decl node.  */
     305              : 
     306              : static void
     307            0 : m2pp_decl_list (pretty *s, tree t)
     308              : {
     309            0 :   tree u = t;
     310              : 
     311            0 :   m2pp_print (s, "(");
     312            0 :   m2pp_needspace (s);
     313            0 :   while (t != NULL_TREE)
     314              :     {
     315            0 :       m2pp_identifier (s, t);
     316            0 :       t = TREE_CHAIN (t);
     317            0 :       if (t == u || t == NULL_TREE)
     318              :         break;
     319            0 :       m2pp_print (s, ",");
     320            0 :       m2pp_needspace (s);
     321              :     }
     322            0 :   m2pp_needspace (s);
     323            0 :   m2pp_print (s, ")");
     324            0 : }
     325              : 
     326              : static void
     327            0 : m2pp_decl_bool (pretty *s, tree t)
     328              : {
     329            0 :   if (TREE_STATIC (t))
     330            0 :     m2pp_print (s, "static, ");
     331            0 :   if (DECL_EXTERNAL (t))
     332            0 :     m2pp_print (s, "external, ");
     333            0 :   if (DECL_SEEN_IN_BIND_EXPR_P (t))
     334            0 :     m2pp_print (s, "in bind expr, ");
     335            0 : }
     336              : 
     337              : void
     338            0 : pv (tree t)
     339              : {
     340            0 :   if (t)
     341              :     {
     342            0 :       enum tree_code code = TREE_CODE (t);
     343              : 
     344            0 :       if (code == PARM_DECL)
     345              :         {
     346            0 :           pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     347            0 :           m2pp_identifier (state, t);
     348            0 :           m2pp_needspace (state);
     349            0 :           m2pp_print (state, "<parm_decl context = ");
     350            0 :           m2pp_identifier (state, DECL_CONTEXT (t));
     351            0 :           if (DECL_ABSTRACT_ORIGIN (t) == t)
     352            0 :             m2pp_print (state, ">\n");
     353              :           else
     354              :             {
     355            0 :               m2pp_print (state, ", abstract origin = ");
     356            0 :               m2pp_identifier (state, DECL_ABSTRACT_ORIGIN (t));
     357            0 :               m2pp_print (state, ">\n");
     358            0 :               modula2::pv (DECL_ABSTRACT_ORIGIN (t));
     359              :             }
     360            0 :           killPretty (state);
     361              :         }
     362            0 :       if (code == VAR_DECL)
     363              :         {
     364            0 :           pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     365            0 :           m2pp_identifier (state, t);
     366            0 :           m2pp_needspace (state);
     367            0 :           m2pp_print (state, "(* <var_decl context = ");
     368            0 :           m2pp_identifier (state, DECL_CONTEXT (t));
     369            0 :           m2pp_decl_bool (state, t);
     370            0 :           if (DECL_ABSTRACT_ORIGIN (t) == t)
     371            0 :             m2pp_print (state, "> *)\n");
     372              :           else
     373              :             {
     374            0 :               m2pp_print (state, ", abstract origin = ");
     375            0 :               m2pp_identifier (state, DECL_ABSTRACT_ORIGIN (t));
     376            0 :               m2pp_print (state, "> *)\n");
     377            0 :               modula2::pv (DECL_ABSTRACT_ORIGIN (t));
     378              :             }
     379            0 :           killPretty (state);
     380              :         }
     381              :     }
     382            0 : }
     383              : 
     384              : #if defined(GM2_MAINTAINER)
     385              : 
     386              : /* remember an internal debugging hook. */
     387              : static tree rememberF = NULL;
     388              : 
     389              : static void
     390              : remember (tree t)
     391              : {
     392              :   rememberF = t;
     393              :   printf ("type:  watch *((tree *) %p) != %p\n", (void *)&DECL_SAVED_TREE (t),
     394              :           (void *)DECL_SAVED_TREE (t));
     395              : }
     396              : #endif
     397              : 
     398              : /* push pushes tree t onto stack.  */
     399              : 
     400              : static void
     401            0 : push (tree t)
     402              : {
     403            0 :   stack *s = (stack *)xmalloc (sizeof (stack));
     404              : 
     405            0 :   s->value = t;
     406            0 :   s->next = stackPtr;
     407            0 :   stackPtr = s;
     408            0 : }
     409              : 
     410              : /* pop pops a tree, from the stack.  */
     411              : 
     412              : static void
     413            0 : pop (void)
     414              : {
     415            0 :   stack *s = stackPtr;
     416              : 
     417            0 :   stackPtr = stackPtr->next;
     418            0 :   free (s);
     419            0 : }
     420              : 
     421              : /* being_printed returns true if t is held on the stack.  */
     422              : 
     423              : static bool
     424            0 : begin_printed (tree t)
     425              : {
     426            0 :   stack *s = stackPtr;
     427              : 
     428            0 :   while (s != NULL)
     429              :     {
     430            0 :       if (s->value == t)
     431              :         return true;
     432              :       else
     433            0 :         s = s->next;
     434              :     }
     435              :   return false;
     436              : }
     437              : 
     438              : /* dupPretty duplicate and return a copy of state s.  */
     439              : 
     440              : static pretty *
     441            0 : dupPretty (pretty *s)
     442              : {
     443            0 :   pretty *p = initPretty (s->output, s->bits);
     444            0 :   *p = *s;
     445            0 :   return p;
     446              : }
     447              : 
     448              : /* initPretty initialise the state of the pretty printer.  */
     449              : 
     450              : static pretty *
     451            0 : initPretty (m2pp_dump_kind kind, int bits)
     452              : {
     453            0 :   pretty *state = (pretty *)xmalloc (sizeof (pretty));
     454            0 :   state->output = kind;
     455            0 :   state->needs_space = false;
     456            0 :   state->needs_indent = false;
     457            0 :   state->curpos = 0;
     458            0 :   state->indent = 0;
     459            0 :   state->issued_begin = false;
     460            0 :   state->in_vars = false;
     461            0 :   state->in_types = false;
     462            0 :   state->block = NULL_TREE;
     463            0 :   state->bits = bits;
     464            0 :   return state;
     465              : }
     466              : 
     467              : /* killPretty cleans up the state.  */
     468              : 
     469              : static void
     470            0 : killPretty (pretty *s)
     471              : {
     472            0 :   fflush (getoutput (s));
     473            0 :   free (s);
     474            0 : }
     475              : 
     476              : /* getindent returns the current indent value.  */
     477              : 
     478              : static int
     479            0 : getindent (pretty *s)
     480              : {
     481            0 :   return s->indent;
     482              : }
     483              : 
     484              : /* setindent sets the current indent to, n.  */
     485              : 
     486              : static void
     487            0 : setindent (pretty *s, int n)
     488              : {
     489            0 :   s->indent = n;
     490            0 : }
     491              : 
     492              : /* getcurpos returns the current cursor position.  */
     493              : 
     494              : static int
     495            0 : getcurpos (pretty *s)
     496              : {
     497            0 :   if (s->needs_space)
     498            0 :     return s->curpos + 1;
     499              :   else
     500            0 :     return s->curpos;
     501              : }
     502              : 
     503              : static FILE *
     504            0 : getoutput (pretty *s)
     505              : {
     506            0 :   return m2pp_output_file[s->output];
     507              : }
     508              : 
     509              : /* m2pp_type_lowlevel prints out the low level details of a
     510              :    fundamental type.  */
     511              : 
     512              : static void
     513            0 : m2pp_type_lowlevel (pretty *s, tree t)
     514              : {
     515            0 :   if (TREE_CODE (t) == INTEGER_TYPE)
     516              :     {
     517            0 :       m2pp_print (s, "min");
     518            0 :       m2pp_needspace (s);
     519            0 :       m2pp_integer_cst (s, TYPE_MIN_VALUE (t));
     520            0 :       m2pp_print (s, ", max");
     521            0 :       m2pp_needspace (s);
     522            0 :       m2pp_integer_cst (s, TYPE_MAX_VALUE (t));
     523            0 :       m2pp_print (s, ", type size unit");
     524            0 :       m2pp_needspace (s);
     525            0 :       m2pp_integer_cst (s, TYPE_SIZE_UNIT (t));
     526            0 :       m2pp_print (s, ", type size");
     527            0 :       m2pp_needspace (s);
     528            0 :       m2pp_integer_cst (s, TYPE_SIZE (t));
     529              : 
     530            0 :       fprintf (getoutput (s),
     531              :                ", precision %d, mode %d, align %d, user align %d",
     532            0 :                TYPE_PRECISION (t), TYPE_MODE (t), TYPE_ALIGN (t),
     533            0 :                TYPE_USER_ALIGN (t));
     534              : 
     535            0 :       m2pp_needspace (s);
     536            0 :       if (TYPE_UNSIGNED (t))
     537            0 :         m2pp_print (s, "unsigned");
     538              :       else
     539            0 :         m2pp_print (s, "signed");
     540              :     }
     541            0 : }
     542              : 
     543              : /* m2pp_var emit a VAR if necessary.  */
     544              : 
     545              : static void
     546            0 : m2pp_var (pretty *s)
     547              : {
     548            0 :   if (!s->in_vars)
     549              :     {
     550            0 :       s->in_vars = true;
     551            0 :       m2pp_print (s, "VAR\n");
     552            0 :       setindent (s, getindent (s) + 3);
     553              :     }
     554            0 : }
     555              : 
     556              : /* m2pp_types emit a TYPE if necessary.  */
     557              : 
     558              : static void
     559            0 : m2pp_types (pretty *s)
     560              : {
     561            0 :   if (!s->in_types)
     562              :     {
     563            0 :       s->in_types = true;
     564            0 :       m2pp_print (s, "TYPE\n");
     565            0 :       setindent (s, getindent (s) + 3);
     566              :     }
     567            0 : }
     568              : 
     569              : #ifdef DEBUGGING
     570              : /* hextree displays the critical fields for function, block and
     571              :    bind_expr trees in raw hex.  */
     572              : 
     573              : static void
     574              : hextree (tree t)
     575              : {
     576              :   if (t == NULL_TREE)
     577              :     return;
     578              : 
     579              :   if (TREE_CODE (t) == BLOCK)
     580              :     {
     581              :       printf ("(* BLOCK %p *)\n", (void *)t);
     582              :       printf ("BLOCK_VARS (t) =  %p\n", (void *)BLOCK_VARS (t));
     583              :       printf ("BLOCK_SUPERCONTEXT (t)  =  %p\n",
     584              :               (void *)BLOCK_SUPERCONTEXT (t));
     585              :     }
     586              :   if (TREE_CODE (t) == BIND_EXPR)
     587              :     {
     588              :       printf ("(* BIND_EXPR %p *)\n", (void *)t);
     589              :       printf ("BIND_EXPR_VARS (t) =  %p\n", (void *)BIND_EXPR_VARS (t));
     590              :       printf ("BIND_EXPR_BLOCK (t) =  %p\n", (void *)BIND_EXPR_BLOCK (t));
     591              :       printf ("BIND_EXPR_BODY (t) =  %p\n", (void *)BIND_EXPR_BODY (t));
     592              :     }
     593              :   if (TREE_CODE (t) == FUNCTION_DECL)
     594              :     {
     595              :       printf ("(* FUNCTION_DECL %p *)\n", (void *)t);
     596              :       printf ("DECL_INITIAL (t) =  %p\n", (void *)DECL_INITIAL (t));
     597              :       printf ("DECL_SAVED_TREE (t) = %p\n", (void *)DECL_SAVED_TREE (t));
     598              :       hextree (DECL_INITIAL (t));
     599              :       hextree (DECL_SAVED_TREE (t));
     600              :     }
     601              :   if (VAR_P (t))
     602              :     {
     603              :       pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     604              : 
     605              :       printf ("(* VAR_DECL %p <", (void *)t);
     606              :       if (DECL_SEEN_IN_BIND_EXPR_P (t))
     607              :         printf ("b");
     608              :       if (DECL_EXTERNAL (t))
     609              :         printf ("e");
     610              :       if (TREE_STATIC (t))
     611              :         printf ("s");
     612              :       printf ("> context = %p*)\n", (void *)decl_function_context (t));
     613              :       m2pp_type (state, TREE_TYPE (t));
     614              :       m2pp_needspace (state);
     615              :       m2pp_print (state, ";\n");
     616              :       killPretty (state);
     617              :     }
     618              :   if (TREE_CODE (t) == PARM_DECL)
     619              :     {
     620              :       pretty *state = initPretty (M2PP_DUMP_STDOUT, 0);
     621              : 
     622              :       printf ("(* PARM_DECL %p <", (void *)t);
     623              :       printf ("> context = %p*)\n", (void *)decl_function_context (t));
     624              :       m2pp_type (state, TREE_TYPE (t));
     625              :       m2pp_needspace (state);
     626              :       m2pp_print (state, ";\n");
     627              :       killPretty (state);
     628              :     }
     629              : }
     630              : #endif
     631              : 
     632              : /* translation produce a pseudo implementation module from the tree t.  */
     633              : 
     634              : static void
     635            0 : m2pp_translation (pretty *s, tree t)
     636              : {
     637            0 :   tree block = DECL_INITIAL (t);
     638              : 
     639            0 :   m2pp_print (s, "IMPLEMENTATION MODULE ");
     640            0 :   m2pp_identifier (s, t);
     641            0 :   m2pp_print (s, "\n\n");
     642              : 
     643            0 :   if (block != NULL)
     644              :     {
     645            0 :       m2pp_module_block (s, block);
     646            0 :       m2pp_print (s, "\n");
     647              :     }
     648              : 
     649            0 :   m2pp_print (s, "\n");
     650            0 :   m2pp_print (s, "END ");
     651            0 :   m2pp_identifier (s, t);
     652            0 :   m2pp_print (s, ".\n");
     653            0 : }
     654              : 
     655              : static void
     656            0 : m2pp_module_block (pretty *s, tree t)
     657              : {
     658            0 :   t = BLOCK_VARS (t);
     659              : 
     660            0 :   if (t != NULL_TREE)
     661            0 :     for (; t != NULL_TREE; t = TREE_CHAIN (t))
     662              :       {
     663            0 :         switch (TREE_CODE (t))
     664              :           {
     665            0 :           case FUNCTION_DECL:
     666            0 :             if (!DECL_EXTERNAL (t))
     667              :               {
     668            0 :                 pretty *p = dupPretty (s);
     669            0 :                 fprintf (getoutput (s), "\n");
     670            0 :                 p->in_vars = false;
     671            0 :                 p->in_types = false;
     672            0 :                 m2pp_function (p, t);
     673            0 :                 killPretty (p);
     674            0 :                 fprintf (getoutput (s), "\n");
     675            0 :                 s->in_vars = false;
     676            0 :                 s->in_types = false;
     677              :               }
     678              :             break;
     679              : 
     680            0 :           case TYPE_DECL:
     681            0 :             {
     682            0 :               int o = getindent (s);
     683            0 :               int p;
     684              : 
     685            0 :               m2pp_print (s, "\n");
     686            0 :               m2pp_types (s);
     687            0 :               setindent (s, o + 3);
     688            0 :               m2pp_identifier (s, t);
     689            0 :               m2pp_print (s, " = ");
     690            0 :               p = getcurpos (s);
     691            0 :               setindent (s, p);
     692            0 :               m2pp_type (s, TREE_TYPE (t));
     693            0 :               setindent (s, o);
     694            0 :               m2pp_needspace (s);
     695            0 :               m2pp_print (s, ";\n");
     696            0 :               s->in_vars = false;
     697              :             }
     698            0 :             break;
     699              : 
     700            0 :           case VAR_DECL:
     701            0 :             m2pp_var (s);
     702            0 :             m2pp_identifier (s, t);
     703            0 :             m2pp_needspace (s);
     704            0 :             m2pp_print (s, ":");
     705            0 :             m2pp_needspace (s);
     706            0 :             m2pp_type (s, TREE_TYPE (t));
     707            0 :             m2pp_needspace (s);
     708            0 :             m2pp_print (s, ";\n");
     709            0 :             s->in_types = false;
     710            0 :             break;
     711              : 
     712            0 :           case DECL_EXPR:
     713            0 :             fprintf (getoutput (s), "is this node legal here? \n");
     714            0 :             m2pp_decl_expr (s, t);
     715            0 :             break;
     716              : 
     717            0 :           default:
     718            0 :             m2pp_unknown (s, __FUNCTION__, get_tree_code_name (TREE_CODE (t)));
     719              :           }
     720              :       }
     721            0 : }
     722              : 
     723              : /* m2pp_begin emit a BEGIN if necessary.  */
     724              : 
     725              : static void
     726            0 : m2pp_begin (pretty *s)
     727              : {
     728            0 :   if (!s->issued_begin)
     729              :     {
     730            0 :       if (s->in_vars || s->in_types)
     731              :         {
     732            0 :           setindent (s, getindent (s) - 3);
     733            0 :           m2pp_print (s, "BEGIN\n");
     734            0 :           setindent (s, getindent (s) + 3);
     735              :         }
     736              :       else
     737              :         {
     738            0 :           m2pp_print (s, "BEGIN\n");
     739            0 :           setindent (s, getindent (s) + 3);
     740              :         }
     741            0 :       s->issued_begin = true;
     742            0 :       s->in_vars = false;
     743            0 :       s->in_types = false;
     744              :     }
     745            0 : }
     746              : 
     747              : /* m2pp_function walk over the function.  */
     748              : 
     749              : static void
     750            0 : m2pp_function (pretty *s, tree t)
     751              : {
     752            0 :   m2pp_function_header (s, t);
     753            0 :   m2pp_function_vars (s, t);
     754            0 :   m2pp_statement_sequence (s, DECL_SAVED_TREE (t));
     755            0 :   if (TREE_CODE (t) == FUNCTION_DECL)
     756              :     {
     757            0 :       m2pp_begin (s);
     758            0 :       setindent (s, getindent (s) - 3);
     759            0 :       m2pp_print (s, "END");
     760            0 :       m2pp_needspace (s);
     761            0 :       m2pp_identifier (s, t);
     762            0 :       m2pp_needspace (s);
     763            0 :       m2pp_print (s, ";\n");
     764              :     }
     765            0 : }
     766              : 
     767              : /* m2pp_bind_expr displays the bind expr tree node.  */
     768              : 
     769              : static void
     770            0 : m2pp_bind_expr (pretty *s, tree t)
     771              : {
     772            0 :   if (TREE_CODE (t) == BIND_EXPR)
     773              :     {
     774            0 :       if (BIND_EXPR_VARS (t))
     775              :         {
     776            0 :           m2pp_print (s, "(* variables in bind_expr *)\n");
     777            0 :           m2pp_var (s);
     778            0 :           m2pp_var_list (s, BIND_EXPR_VARS (t));
     779              :         }
     780            0 :       if (BIND_EXPR_BLOCK (t))
     781              :         {
     782            0 :           m2pp_print (s, "(* bind_expr_block *)\n");
     783            0 :           m2pp_statement_sequence (s, BIND_EXPR_BLOCK (t));
     784            0 :           m2pp_needspace (s);
     785            0 :           m2pp_print (s, "; \n");
     786              :         }
     787            0 :       m2pp_statement_sequence (s, BIND_EXPR_BODY (t));
     788              :     }
     789            0 : }
     790              : 
     791              : /* m2pp_block_list iterates over the list of blocks.  */
     792              : 
     793              : static void
     794            0 : m2pp_block_list (pretty *s, tree t)
     795              : {
     796            0 :   for (; t; t = BLOCK_CHAIN (t))
     797            0 :     m2pp_block (s, t);
     798            0 : }
     799              : 
     800              : /* m2pp_block prints the VARiables and the TYPEs inside a block.  */
     801              : 
     802              : static void
     803            0 : m2pp_block (pretty *s, tree t)
     804              : {
     805            0 :   if ((BLOCK_VARS (t) != NULL_TREE) && (s->block != BLOCK_VARS (t)))
     806              :     {
     807            0 :       s->block = BLOCK_VARS (t);
     808            0 :       m2pp_print (s, "(* block variables *)\n");
     809            0 :       m2pp_var (s);
     810            0 :       m2pp_var_list (s, BLOCK_VARS (t));
     811              :     }
     812            0 : }
     813              : 
     814              : /* m2pp_var_type_decl displays the variable and type declaration.  */
     815              : 
     816              : static void
     817            0 : m2pp_var_type_decl (pretty *s, tree t)
     818              : {
     819            0 :   m2pp_identifier (s, t);
     820            0 :   m2pp_needspace (s);
     821            0 :   m2pp_print (s, ":");
     822            0 :   m2pp_needspace (s);
     823            0 :   m2pp_type (s, TREE_TYPE (t));
     824            0 :   m2pp_needspace (s);
     825            0 :   m2pp_print (s, ";\n");
     826            0 : }
     827              : 
     828              : /* m2pp_var_list print a variable list.  */
     829              : 
     830              : static void
     831            0 : m2pp_var_list (pretty *s, tree t)
     832              : {
     833            0 :   if (t != NULL_TREE)
     834            0 :     for (; t; t = TREE_CHAIN (t))
     835              :       {
     836            0 :         if (TREE_CODE (t) == FUNCTION_DECL)
     837              :           {
     838            0 :             pretty *p = dupPretty (s);
     839            0 :             fprintf (getoutput (s), "\n");
     840            0 :             p->in_vars = false;
     841            0 :             p->in_types = false;
     842            0 :             m2pp_function (p, t);
     843            0 :             killPretty (p);
     844            0 :             fprintf (getoutput (s), "\n");
     845              :           }
     846            0 :         else if (TREE_CODE (t) == TYPE_DECL)
     847            0 :           m2pp_identifier (s, t);
     848            0 :         else if (TREE_CODE (t) == DECL_EXPR)
     849              :           {
     850            0 :             fprintf (getoutput (s), "is this node legal here? \n");
     851              :             // is it legal to have a DECL_EXPR here ?
     852            0 :             m2pp_var_type_decl (s, DECL_EXPR_DECL (t));
     853              :           }
     854              :         else
     855            0 :           m2pp_var_type_decl (s, t);
     856              :       }
     857            0 : }
     858              : 
     859              : #if 0
     860              : /* m2pp_type_list print a variable list.  */
     861              : 
     862              : static void
     863              : m2pp_type_list (pretty *s, tree t)
     864              : {
     865              :   if (t != NULL_TREE)
     866              :     for (; t; t = TREE_CHAIN (t))
     867              :       {
     868              :         m2pp_identifier (s, t);
     869              :         m2pp_needspace (s);
     870              :         m2pp_print (s, "=");
     871              :         m2pp_needspace (s);
     872              :         m2pp_type (s, TREE_TYPE (t));
     873              :         m2pp_needspace (s);
     874              :         m2pp_print (s, ";\n");
     875              :       }
     876              : }
     877              : #endif
     878              : 
     879              : /* m2pp_needspace sets appropriate flag to true.  */
     880              : 
     881              : static void
     882            0 : m2pp_needspace (pretty *s)
     883              : {
     884            0 :   s->needs_space = true;
     885            0 : }
     886              : 
     887              : /* m2pp_identifer prints an identifier.  */
     888              : 
     889              : static void
     890            0 : m2pp_identifier (pretty *s, tree t)
     891              : {
     892            0 :   if (t)
     893              :     {
     894            0 :       if (TREE_CODE (t) == COMPONENT_REF)
     895            0 :         m2pp_component_ref (s, t);
     896            0 :       else if (DECL_NAME (t) && IDENTIFIER_POINTER (DECL_NAME (t)))
     897            0 :         m2pp_ident_pointer (s, DECL_NAME (t));
     898              :       else
     899              :         {
     900            0 :           char name[100];
     901              : 
     902            0 :           if (TREE_CODE (t) == CONST_DECL)
     903            0 :             snprintf (name, 100, "C_%u", DECL_UID (t));
     904              :           else
     905            0 :             snprintf (name, 100, "D_%u", DECL_UID (t));
     906            0 :           m2pp_print (s, name);
     907              : #ifdef VERBOSE_TYPE_DESC
     908              :           if (TREE_TYPE (t) != NULL_TREE)
     909              :             {
     910              :               m2pp_needspace (s);
     911              :               m2pp_print (s, "(* type:");
     912              :               m2pp_needspace (s);
     913              :               m2pp_simple_type (s, TREE_TYPE (t));
     914              :               m2pp_needspace (s);
     915              :               m2pp_type_lowlevel (s, TREE_TYPE (t));
     916              :               m2pp_needspace (s);
     917              :               m2pp_print (s, "*)");
     918              :             }
     919              : #endif
     920              :         }
     921              :     }
     922            0 : }
     923              : 
     924              : /* m2pp_ident_pointer displays an ident pointer.  */
     925              : 
     926              : static void
     927            0 : m2pp_ident_pointer (pretty *s, tree t)
     928              : {
     929            0 :   if (t)
     930            0 :     m2pp_print (s, IDENTIFIER_POINTER (t));
     931            0 : }
     932              : 
     933              : /* m2pp_parameter prints out a param decl tree.  */
     934              : 
     935              : static void
     936            0 : m2pp_parameter (pretty *s, tree t)
     937              : {
     938            0 :   if (TREE_CODE (t) == PARM_DECL)
     939              :     {
     940            0 :       if (TREE_TYPE (t) && (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE))
     941              :         {
     942            0 :           m2pp_print (s, "VAR");
     943            0 :           m2pp_needspace (s);
     944            0 :           m2pp_identifier (s, t);
     945            0 :           m2pp_print (s, ":");
     946            0 :           m2pp_needspace (s);
     947            0 :           m2pp_simple_type (s, TREE_TYPE (TREE_TYPE (t)));
     948              :         }
     949              :       else
     950              :         {
     951            0 :           m2pp_identifier (s, t);
     952            0 :           m2pp_print (s, ":");
     953            0 :           m2pp_needspace (s);
     954            0 :           m2pp_simple_type (s, TREE_TYPE (t));
     955              :         }
     956              :     }
     957            0 : }
     958              : 
     959              : /* m2pp_param_type prints out the type of parameter.  */
     960              : 
     961              : static void
     962            0 : m2pp_param_type (pretty *s, tree t)
     963              : {
     964            0 :   if (t && (TREE_CODE (t) == REFERENCE_TYPE))
     965              :     {
     966            0 :       m2pp_print (s, "VAR");
     967            0 :       m2pp_needspace (s);
     968            0 :       m2pp_simple_type (s, TREE_TYPE (t));
     969              :     }
     970              :   else
     971            0 :     m2pp_simple_type (s, t);
     972            0 : }
     973              : 
     974              : /* m2pp_procedure_type displays a procedure type.  */
     975              : 
     976              : static void
     977            0 : m2pp_procedure_type (pretty *s, tree t)
     978              : {
     979            0 :   push (t);
     980            0 :   if (TREE_CODE (t) == FUNCTION_TYPE)
     981              :     {
     982            0 :       tree i = TYPE_ARG_TYPES (t);
     983            0 :       tree returnType = TREE_TYPE (TREE_TYPE (t));
     984              : 
     985            0 :       m2pp_needspace (s);
     986            0 :       m2pp_print (s, "PROCEDURE");
     987            0 :       m2pp_needspace (s);
     988            0 :       if (i != NULL_TREE)
     989              :         {
     990            0 :           int o = getindent (s);
     991            0 :           int p;
     992            0 :           bool first = true;
     993              : 
     994            0 :           m2pp_print (s, "(");
     995            0 :           p = getcurpos (s);
     996            0 :           setindent (s, p);
     997            0 :           while (i != NULL_TREE)
     998              :             {
     999            0 :               if (TREE_CHAIN (i) == NULL_TREE)
    1000              :                 {
    1001            0 :                   if (TREE_VALUE (i) == void_type_node)
    1002              :                     /* Ignore void_type_node at the end.  */
    1003              :                     ;
    1004              :                   else
    1005              :                     {
    1006            0 :                       m2pp_param_type (s, TREE_VALUE (i));
    1007            0 :                       m2pp_print (s, ", ...");
    1008              :                     }
    1009              :                   break;
    1010              :                 }
    1011              :               else
    1012              :                 {
    1013            0 :                   if (!first)
    1014              :                     {
    1015            0 :                       m2pp_print (s, ",");
    1016            0 :                       m2pp_needspace (s);
    1017              :                     }
    1018            0 :                   m2pp_param_type (s, TREE_VALUE (i));
    1019              :                 }
    1020            0 :               i = TREE_CHAIN (i);
    1021            0 :               first = false;
    1022              :             }
    1023            0 :           m2pp_print (s, ")");
    1024            0 :           setindent (s, o);
    1025              :         }
    1026            0 :       else if (returnType != NULL_TREE)
    1027              :         {
    1028            0 :           m2pp_needspace (s);
    1029            0 :           m2pp_print (s, "()");
    1030              :         }
    1031            0 :       if (returnType != NULL_TREE)
    1032              :         {
    1033            0 :           m2pp_needspace (s);
    1034            0 :           m2pp_print (s, ": ");
    1035            0 :           m2pp_simple_type (s, returnType);
    1036              :         }
    1037              :     }
    1038            0 :   pop ();
    1039            0 : }
    1040              : 
    1041              : /* m2pp_comment_header displays a simple header with some critical
    1042              :    tree info.  */
    1043              : 
    1044              : static void
    1045            0 : m2pp_comment_header (pretty *s, tree t)
    1046              : {
    1047            0 :   int o = getindent (s);
    1048              : 
    1049            0 :   m2pp_print (s, "(*\n");
    1050            0 :   setindent (s, o + 3);
    1051            0 :   m2pp_identifier (s, t);
    1052            0 :   m2pp_needspace (s);
    1053            0 :   m2pp_print (s, "-");
    1054            0 :   m2pp_needspace (s);
    1055            0 :   if (TREE_PUBLIC (t))
    1056              :     {
    1057            0 :       m2pp_needspace (s);
    1058            0 :       m2pp_print (s, "public,");
    1059              :     }
    1060            0 :   if (TREE_STATIC (t))
    1061              :     {
    1062            0 :       m2pp_needspace (s);
    1063            0 :       m2pp_print (s, "static,");
    1064              :     }
    1065            0 :   if (DECL_EXTERNAL (t))
    1066              :     {
    1067            0 :       m2pp_needspace (s);
    1068            0 :       m2pp_print (s, "extern");
    1069              :     }
    1070            0 :   m2pp_print (s, "\n");
    1071            0 :   setindent (s, o);
    1072            0 :   m2pp_print (s, "*)\n\n");
    1073            0 : }
    1074              : 
    1075              : /* m2pp_function_header displays the function header.  */
    1076              : 
    1077              : static void
    1078            0 : m2pp_function_header (pretty *s, tree t)
    1079              : {
    1080            0 :   push (t);
    1081            0 :   if (TREE_CODE (t) == FUNCTION_DECL)
    1082              :     {
    1083            0 :       tree i = DECL_ARGUMENTS (t);
    1084            0 :       tree returnType = TREE_TYPE (TREE_TYPE (t));
    1085              : 
    1086            0 :       m2pp_comment_header (s, t);
    1087            0 :       m2pp_print (s, "PROCEDURE ");
    1088            0 :       m2pp_identifier (s, t);
    1089            0 :       m2pp_needspace (s);
    1090            0 :       if (i != NULL_TREE)
    1091              :         {
    1092            0 :           int o = getindent (s);
    1093            0 :           int p;
    1094              : 
    1095            0 :           m2pp_print (s, "(");
    1096            0 :           p = getcurpos (s);
    1097            0 :           setindent (s, p);
    1098            0 :           while (i != NULL_TREE)
    1099              :             {
    1100            0 :               m2pp_parameter (s, i);
    1101            0 :               i = TREE_CHAIN (i);
    1102            0 :               if (i != NULL_TREE)
    1103            0 :                 m2pp_print (s, ";\n");
    1104              :             }
    1105            0 :           m2pp_print (s, ")");
    1106            0 :           m2pp_needspace (s);
    1107            0 :           setindent (s, o);
    1108              :         }
    1109            0 :       else if (returnType != void_type_node)
    1110              :         {
    1111            0 :           m2pp_print (s, "()");
    1112            0 :           m2pp_needspace (s);
    1113              :         }
    1114            0 :       if (returnType != void_type_node)
    1115              :         {
    1116            0 :           m2pp_print (s, ": ");
    1117            0 :           m2pp_simple_type (s, returnType);
    1118            0 :           m2pp_needspace (s);
    1119              :         }
    1120            0 :       m2pp_print (s, "; ");
    1121            0 :       m2pp_loc (s, t);
    1122            0 :       m2pp_print (s, "\n");
    1123              :     }
    1124            0 :   pop ();
    1125            0 : }
    1126              : 
    1127              : /* m2pp_add_var adds a variable into a list as defined by, data.  */
    1128              : 
    1129              : static tree
    1130            0 : m2pp_add_var (tree *tp, int *walk_subtrees, void *data)
    1131              : {
    1132            0 :   tree t = *tp;
    1133            0 :   pretty *s = (pretty *)data;
    1134            0 :   enum tree_code code = TREE_CODE (t);
    1135              : 
    1136            0 :   if (code == VAR_DECL)
    1137              :     {
    1138            0 :       m2pp_var (s);
    1139            0 :       m2pp_identifier (s, t);
    1140            0 :       m2pp_needspace (s);
    1141            0 :       m2pp_print (s, ":");
    1142            0 :       m2pp_needspace (s);
    1143            0 :       m2pp_type (s, TREE_TYPE (t));
    1144            0 :       m2pp_needspace (s);
    1145            0 :       m2pp_print (s, ";\n");
    1146              :     }
    1147            0 :   if (code == SSA_NAME)
    1148              :     {
    1149            0 :       m2pp_var (s);
    1150            0 :       m2pp_ssa (s, t);
    1151            0 :       m2pp_identifier (s, SSA_NAME_VAR (t));
    1152            0 :       m2pp_needspace (s);
    1153            0 :       m2pp_print (s, ":");
    1154            0 :       m2pp_needspace (s);
    1155            0 :       m2pp_type (s, TREE_TYPE (t));
    1156            0 :       m2pp_needspace (s);
    1157            0 :       m2pp_print (s, ";\n");
    1158              :     }
    1159              : 
    1160            0 :   *walk_subtrees = 1;
    1161            0 :   return NULL_TREE;
    1162              : }
    1163              : 
    1164              : /* m2pp_function_vars displays variables as defined by the function
    1165              :    tree.  */
    1166              : 
    1167              : static void
    1168            0 : m2pp_function_vars (pretty *s, tree t)
    1169              : {
    1170            0 :   walk_tree_without_duplicates (&t, m2pp_add_var, s);
    1171              : 
    1172            0 :   if (TREE_CODE (t) == FUNCTION_DECL && DECL_INITIAL (t))
    1173              :     {
    1174            0 :       m2pp_print (s, "(* variables in function_decl (decl_initial) *)\n");
    1175            0 :       m2pp_var (s);
    1176            0 :       m2pp_statement_sequence (s, DECL_INITIAL (t));
    1177              :     }
    1178            0 : }
    1179              : 
    1180              : /* m2pp_print print out a string p interpreting '\n' and
    1181              :    adjusting the fields within state s.  */
    1182              : 
    1183              : static void
    1184            0 : m2pp_print (pretty *s, const char *p)
    1185              : {
    1186            0 :   if (p)
    1187              :     {
    1188            0 :       int l = strlen (p);
    1189            0 :       int i = 0;
    1190              : 
    1191            0 :       if (s->needs_space)
    1192              :         {
    1193            0 :           fprintf (getoutput (s), " ");
    1194            0 :           s->needs_space = false;
    1195            0 :           s->curpos++;
    1196              :         }
    1197              : 
    1198            0 :       while (i < l)
    1199              :         {
    1200            0 :           if (p[i] == '\n')
    1201              :             {
    1202            0 :               s->needs_indent = true;
    1203            0 :               s->curpos = 0;
    1204            0 :               fprintf (getoutput (s), "\n");
    1205              :             }
    1206              :           else
    1207              :             {
    1208            0 :               if (s->needs_indent)
    1209              :                 {
    1210            0 :                   if (s->indent > 0)
    1211            0 :                     fprintf (getoutput (s), "%*c", s->indent, ' ');
    1212            0 :                   s->needs_indent = false;
    1213            0 :                   s->curpos += s->indent;
    1214              :                 }
    1215            0 :               s->curpos++;
    1216            0 :               fputc (p[i], getoutput (s));
    1217              :             }
    1218            0 :           i++;
    1219              :         }
    1220              :     }
    1221            0 : }
    1222              : 
    1223              : /* m2pp_print_char prints out a character ch obeying needs_space
    1224              :    and needs_indent.  */
    1225              : 
    1226              : static void
    1227            0 : m2pp_print_char (pretty *s, char ch)
    1228              : {
    1229            0 :   if (s->needs_space)
    1230              :     {
    1231            0 :       fprintf (getoutput (s), " ");
    1232            0 :       s->needs_space = false;
    1233            0 :       s->curpos++;
    1234              :     }
    1235            0 :   if (s->needs_indent)
    1236              :     {
    1237            0 :       if (s->indent > 0)
    1238            0 :         fprintf (getoutput (s), "%*c", s->indent, ' ');
    1239            0 :       s->needs_indent = false;
    1240            0 :       s->curpos += s->indent;
    1241              :     }
    1242            0 :   if (ch == '\n')
    1243              :     {
    1244            0 :       s->curpos++;
    1245            0 :       fputc ('\\', getoutput (s));
    1246            0 :       fputc ('n', getoutput (s));
    1247              :     }
    1248              :   else
    1249            0 :     fputc (ch, getoutput (s));
    1250            0 :   s->curpos++;
    1251            0 : }
    1252              : 
    1253              : /* m2pp_integer display the appropriate integer type.  */
    1254              : 
    1255              : #if defined(GM2)
    1256              : void
    1257            0 : m2pp_integer (pretty *s, tree t)
    1258              : {
    1259            0 :   if (t == m2type_GetM2ZType ())
    1260            0 :     m2pp_print (s, "M2ZTYPE");
    1261            0 :   else if (t == m2type_GetM2LongIntType ())
    1262            0 :     m2pp_print (s, "LONGINT");
    1263            0 :   else if (t == m2type_GetM2IntegerType ())
    1264            0 :     m2pp_print (s, "INTEGER");
    1265            0 :   else if (t == m2type_GetM2ShortIntType ())
    1266            0 :     m2pp_print (s, "SHORTINT");
    1267            0 :   else if (t == m2type_GetLongIntType ())
    1268            0 :     m2pp_print (s, "long int");
    1269            0 :   else if (t == m2type_GetIntegerType ())
    1270            0 :     m2pp_print (s, "int");
    1271            0 :   else if (t == m2type_GetShortIntType ())
    1272            0 :     m2pp_print (s, "short");
    1273            0 :   else if (t == m2type_GetM2LongCardType ())
    1274            0 :     m2pp_print (s, "LONGCARD");
    1275            0 :   else if (t == m2type_GetM2CardinalType ())
    1276            0 :     m2pp_print (s, "CARDINAL");
    1277            0 :   else if (t == m2type_GetM2ShortCardType ())
    1278            0 :     m2pp_print (s, "SHORTCARD");
    1279            0 :   else if (t == m2type_GetCardinalType ())
    1280            0 :     m2pp_print (s, "CARDINAL");
    1281            0 :   else if (t == m2type_GetPointerType ())
    1282            0 :     m2pp_print (s, "ADDRESS");
    1283            0 :   else if (t == m2type_GetByteType ())
    1284            0 :     m2pp_print (s, "BYTE");
    1285            0 :   else if (t == m2type_GetCharType ())
    1286            0 :     m2pp_print (s, "CHAR");
    1287            0 :   else if (t == m2type_GetBitsetType ())
    1288            0 :     m2pp_print (s, "BITSET");
    1289            0 :   else if (t == m2type_GetBitnumType ())
    1290            0 :     m2pp_print (s, "BITNUM");
    1291              :   else
    1292              :     {
    1293            0 :       if (TYPE_UNSIGNED (t))
    1294            0 :         m2pp_print (s, "CARDINAL");
    1295              :       else
    1296            0 :         m2pp_print (s, "INTEGER");
    1297            0 :       m2pp_integer_cst (s, TYPE_SIZE (t));
    1298              :     }
    1299            0 : }
    1300              : #else
    1301              : void
    1302              : m2pp_integer (pretty *s, tree t ATTRIBUTE_UNUSED)
    1303              : {
    1304              :   m2pp_print (s, "INTEGER");
    1305              : }
    1306              : #endif
    1307              : 
    1308              : /* m2pp_complex display the actual complex type.  */
    1309              : 
    1310              : #if defined(GM2)
    1311              : static void
    1312            0 : m2pp_complex (pretty *s, tree t)
    1313              : {
    1314            0 :   if (t == m2type_GetM2ComplexType ())
    1315            0 :     m2pp_print (s, "COMPLEX");
    1316            0 :   else if (t == m2type_GetM2LongComplexType ())
    1317            0 :     m2pp_print (s, "LONGCOMPLEX");
    1318            0 :   else if (t == m2type_GetM2ShortComplexType ())
    1319            0 :     m2pp_print (s, "SHORTCOMPLEX");
    1320            0 :   else if (t == m2type_GetM2CType ())
    1321            0 :     m2pp_print (s, "C'omplex' type");
    1322            0 :   else if (t == m2type_GetM2Complex32 ())
    1323            0 :     m2pp_print (s, "COMPLEX32");
    1324            0 :   else if (t == m2type_GetM2Complex64 ())
    1325            0 :     m2pp_print (s, "COMPLEX64");
    1326            0 :   else if (t == m2type_GetM2Complex96 ())
    1327            0 :     m2pp_print (s, "COMPLEX96");
    1328            0 :   else if (t == m2type_GetM2Complex128 ())
    1329            0 :     m2pp_print (s, "COMPLEX128");
    1330              :   else
    1331            0 :     m2pp_print (s, "unknown COMPLEX type");
    1332            0 : }
    1333              : 
    1334              : #else
    1335              : 
    1336              : static void
    1337              : m2pp_complex (pretty *s, tree t ATTRIBUTE_UNUSED)
    1338              : {
    1339              :   m2pp_print (s, "a COMPLEX type");
    1340              : }
    1341              : #endif
    1342              : 
    1343              : void
    1344            0 : m2pp_real_type (pretty *s, tree t)
    1345              : {
    1346            0 :   if (t == m2type_GetRealType ())
    1347            0 :     m2pp_print (s, "C double");
    1348            0 :   else if (t == m2type_GetShortRealType ())
    1349            0 :     m2pp_print (s, "C float");
    1350            0 :   else if (t == m2type_GetLongRealType ())
    1351            0 :     m2pp_print (s, "C long double");
    1352            0 :   else if (t == m2type_GetM2RealType ())
    1353            0 :     m2pp_print (s, "REAL");
    1354            0 :   else if (t == m2type_GetM2ShortRealType ())
    1355            0 :     m2pp_print (s, "SHORTREAL");
    1356            0 :   else if (t == m2type_GetM2LongRealType ())
    1357            0 :     m2pp_print (s, "LONGREAL");
    1358            0 :   else if (t == m2type_GetM2Real128 ())
    1359            0 :     m2pp_print (s, "REAL128");
    1360            0 :   else if (t == m2type_GetM2Real64 ())
    1361            0 :     m2pp_print (s, "REAL64");
    1362            0 :   else if (t == m2type_GetM2Real32 ())
    1363            0 :     m2pp_print (s, "REAL32");
    1364            0 :   else if (t == m2type_GetM2RType ())
    1365            0 :     m2pp_print (s, "R Type");
    1366              :   else
    1367            0 :     m2pp_print (s, "unknown REAL");
    1368            0 : }
    1369              : 
    1370              : /* m2pp_type prints a full type.  */
    1371              : 
    1372              : void
    1373            0 : m2pp_type (pretty *s, tree t)
    1374              : {
    1375            0 :   if (begin_printed (t))
    1376              :     {
    1377            0 :       m2pp_print (s, "<...>");
    1378            0 :       return;
    1379              :     }
    1380            0 :   if ((TREE_CODE (t) != FIELD_DECL) && (TREE_CODE (t) != TYPE_DECL))
    1381            0 :     m2pp_gimpified (s, t);
    1382            0 :   switch (TREE_CODE (t))
    1383              :     {
    1384            0 :     case INTEGER_TYPE:
    1385            0 :       m2pp_integer (s, t);
    1386            0 :       break;
    1387            0 :     case REAL_TYPE:
    1388            0 :       m2pp_real_type (s, t);
    1389            0 :       break;
    1390            0 :     case ENUMERAL_TYPE:
    1391            0 :       m2pp_enum (s, t);
    1392            0 :       break;
    1393            0 :     case UNION_TYPE:
    1394            0 :       m2pp_union_type (s, t);
    1395            0 :       break;
    1396            0 :     case RECORD_TYPE:
    1397            0 :       m2pp_record_type (s, t);
    1398            0 :       break;
    1399            0 :     case ARRAY_TYPE:
    1400            0 :       m2pp_array (s, t);
    1401            0 :       break;
    1402              : #if 0
    1403              :     case FUNCTION_TYPE:
    1404              :       m2pp_function_type (s, t);
    1405              :       break;
    1406              : #endif
    1407            0 :     case TYPE_DECL:
    1408            0 :       m2pp_identifier (s, t);
    1409            0 :       break;
    1410            0 :     case POINTER_TYPE:
    1411            0 :       m2pp_pointer_type (s, t);
    1412            0 :       break;
    1413              : #if defined(GM2)
    1414            0 :     case SET_TYPE:
    1415            0 :       m2pp_set_type (s, t);
    1416            0 :       break;
    1417              : #endif
    1418            0 :     case VOID_TYPE:
    1419            0 :       m2pp_print (s, "ADDRESS");
    1420            0 :       break;
    1421            0 :     case COMPLEX_TYPE:
    1422            0 :       m2pp_complex (s, t);
    1423            0 :       break;
    1424            0 :     default:
    1425            0 :       m2pp_unknown (s, __FUNCTION__, get_tree_code_name (TREE_CODE (t)));
    1426              :     }
    1427              : }
    1428              : 
    1429              : /* m2pp_set_type prints out the set type.  */
    1430              : 
    1431              : static void
    1432            0 : m2pp_set_type (pretty *s, tree t)
    1433              : {
    1434            0 :   push (t);
    1435            0 :   m2pp_print (s, "SET OF");
    1436            0 :   m2pp_needspace (s);
    1437            0 :   m2pp_type (s, TREE_TYPE (t));
    1438            0 :   pop ();
    1439            0 : }
    1440              : 
    1441              : /* m2pp_enum print out the enumeration type.  */
    1442              : 
    1443              : static void
    1444            0 : m2pp_enum (pretty *s, tree t)
    1445              : {
    1446            0 :   tree chain_p = TYPE_VALUES (t);
    1447              : 
    1448            0 :   push (t);
    1449            0 :   m2pp_print (s, "(");
    1450            0 :   while (chain_p)
    1451              :     {
    1452            0 :       m2pp_ident_pointer (s, TREE_PURPOSE (chain_p));
    1453            0 :       chain_p = TREE_CHAIN (chain_p);
    1454            0 :       if (chain_p)
    1455            0 :         m2pp_print (s, ", ");
    1456              :     }
    1457            0 :   m2pp_print (s, ")");
    1458            0 :   pop ();
    1459            0 : }
    1460              : 
    1461              : /* m2pp_array prints out the array type.  */
    1462              : 
    1463              : static void
    1464            0 : m2pp_array (pretty *s, tree t)
    1465              : {
    1466            0 :   push (t);
    1467            0 :   m2pp_print (s, "ARRAY");
    1468            0 :   m2pp_needspace (s);
    1469            0 :   m2pp_subrange (s, TYPE_DOMAIN (t));
    1470            0 :   m2pp_needspace (s);
    1471            0 :   m2pp_print (s, "OF");
    1472            0 :   m2pp_needspace (s);
    1473            0 :   m2pp_type (s, TREE_TYPE (t));
    1474            0 :   pop ();
    1475            0 : }
    1476              : 
    1477              : /* m2pp_subrange prints out the subrange, but probably the lower
    1478              :    bound will always be zero.  */
    1479              : 
    1480              : static void
    1481            0 : m2pp_subrange (pretty *s, tree t)
    1482              : {
    1483            0 :   tree min = TYPE_MIN_VALUE (t);
    1484            0 :   tree max = TYPE_MAX_VALUE (t);
    1485              : 
    1486            0 :   m2pp_print (s, "[");
    1487            0 :   m2pp_expression (s, min);
    1488            0 :   m2pp_print (s, "..");
    1489            0 :   m2pp_expression (s, max);
    1490            0 :   m2pp_print (s, "]");
    1491            0 : }
    1492              : 
    1493              : /* m2pp_gimplified print out a gimplified comment.  */
    1494              : 
    1495              : static void
    1496            0 : m2pp_gimpified (pretty *s, tree t)
    1497              : {
    1498            0 :   if (!TYPE_SIZES_GIMPLIFIED (t))
    1499              :     {
    1500            0 :       m2pp_print (s, "(* <!g> *)");
    1501            0 :       m2pp_needspace (s);
    1502              :     }
    1503            0 : }
    1504              : 
    1505              : /* m2pp_printer_type display the pointer type.  */
    1506              : 
    1507              : static void
    1508            0 : m2pp_pointer_type (pretty *s, tree t)
    1509              : {
    1510            0 :   push (t);
    1511            0 :   if (TREE_CODE (t) == POINTER_TYPE)
    1512              :     {
    1513            0 :       if (TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
    1514            0 :         m2pp_procedure_type (s, TREE_TYPE (t));
    1515            0 :       else if (t == ptr_type_node)
    1516            0 :         m2pp_print (s, "ADDRESS");
    1517              :       else
    1518              :         {
    1519            0 :           m2pp_print (s, "POINTER TO");
    1520            0 :           m2pp_needspace (s);
    1521            0 :           m2pp_type (s, TREE_TYPE (t));
    1522              :         }
    1523              :     }
    1524            0 :   pop ();
    1525            0 : }
    1526              : 
    1527              : /* m2pp_record_alignment prints out whether this record is aligned
    1528              :    (packed).  */
    1529              : 
    1530              : static void
    1531            0 : m2pp_record_alignment (pretty *s, tree t)
    1532              : {
    1533            0 :   if (TYPE_PACKED (t))
    1534            0 :     m2pp_print (s, "<* bytealignment (0) *>\n");
    1535            0 : }
    1536              : 
    1537              : static unsigned int
    1538            0 : m2pp_getaligned (tree t)
    1539              : {
    1540            0 :   if (DECL_P (t))
    1541              :     {
    1542            0 :       if (DECL_USER_ALIGN (t))
    1543            0 :         return DECL_ALIGN (t);
    1544              :     }
    1545            0 :   else if (TYPE_P (t))
    1546              :     {
    1547            0 :       if (TYPE_USER_ALIGN (t))
    1548            0 :         return TYPE_ALIGN (t);
    1549              :     }
    1550              :   return 0;
    1551              : }
    1552              : 
    1553              : static void
    1554            0 : m2pp_recordfield_alignment (pretty *s, tree t)
    1555              : {
    1556            0 :   unsigned int aligned = m2pp_getaligned (t);
    1557              : 
    1558            0 :   if (aligned != 0)
    1559              :     {
    1560            0 :       int o = getindent (s);
    1561            0 :       int p = getcurpos (s);
    1562            0 :       m2pp_needspace (s);
    1563            0 :       m2pp_print (s, "<* bytealignment (");
    1564            0 :       setindent (s, p + 18);
    1565              : 
    1566            0 :       fprintf (getoutput (s), "%d", aligned / BITS_PER_UNIT);
    1567              : 
    1568            0 :       m2pp_print (s, ")");
    1569            0 :       m2pp_needspace (s);
    1570            0 :       setindent (s, p);
    1571            0 :       m2pp_print (s, "*>");
    1572            0 :       setindent (s, o);
    1573              :     }
    1574            0 : }
    1575              : 
    1576              : static void
    1577            0 : m2pp_recordfield_bitfield (pretty *s, tree t)
    1578              : {
    1579            0 :   if ((TREE_CODE (t) == FIELD_DECL) && DECL_PACKED (t))
    1580              :     {
    1581            0 :       m2pp_print (s, " (* packed");
    1582            0 :       if (DECL_NONADDRESSABLE_P (t))
    1583            0 :         m2pp_print (s, ", non-addressible");
    1584            0 :       if (DECL_BIT_FIELD (t))
    1585            0 :         m2pp_print (s, ", bit-field");
    1586            0 :       m2pp_print (s, ", offset: ");
    1587            0 :       m2pp_expression (s, DECL_FIELD_OFFSET (t));
    1588            0 :       m2pp_print (s, ", bit offset:");
    1589            0 :       m2pp_expression (s, DECL_FIELD_BIT_OFFSET (t));
    1590            0 :       m2pp_print (s, " *) ");
    1591              :     }
    1592            0 : }
    1593              : 
    1594              : /* m2pp_record_type displays the record type.  */
    1595              : 
    1596              : static void
    1597            0 : m2pp_record_type (pretty *s, tree t)
    1598              : {
    1599            0 :   push (t);
    1600            0 :   if (TREE_CODE (t) == RECORD_TYPE)
    1601              :     {
    1602            0 :       tree i;
    1603            0 :       int o = getindent (s);
    1604            0 :       int p = getcurpos (s);
    1605              : 
    1606            0 :       m2pp_print (s, "RECORD\n");
    1607            0 :       setindent (s, p + 3);
    1608            0 :       m2pp_record_alignment (s, t);
    1609            0 :       for (i = TYPE_FIELDS (t); i != NULL_TREE; i = TREE_CHAIN (i))
    1610              :         {
    1611            0 :           m2pp_identifier (s, i);
    1612            0 :           m2pp_print (s, " : ");
    1613            0 :           m2pp_type (s, TREE_TYPE (i));
    1614            0 :           m2pp_recordfield_bitfield (s, i);
    1615            0 :           m2pp_recordfield_alignment (s, i);
    1616            0 :           m2pp_print (s, ";\n");
    1617              :         }
    1618            0 :       setindent (s, p);
    1619            0 :       m2pp_print (s, "END");
    1620            0 :       setindent (s, o);
    1621              :     }
    1622            0 :   pop ();
    1623            0 : }
    1624              : 
    1625              : /* m2pp_record_type displays the record type.  */
    1626              : 
    1627              : static void
    1628            0 : m2pp_union_type (pretty *s, tree t)
    1629              : {
    1630            0 :   push (t);
    1631            0 :   if (TREE_CODE (t) == UNION_TYPE)
    1632              :     {
    1633            0 :       tree i;
    1634            0 :       int o = getindent (s);
    1635            0 :       int p = getcurpos (s);
    1636              : 
    1637            0 :       m2pp_print (s, "CASE .. OF\n");
    1638            0 :       setindent (s, p + 3);
    1639            0 :       m2pp_record_alignment (s, t);
    1640            0 :       for (i = TYPE_FIELDS (t); i != NULL_TREE; i = TREE_CHAIN (i))
    1641              :         {
    1642            0 :           m2pp_identifier (s, i);
    1643            0 :           m2pp_print (s, " : ");
    1644            0 :           m2pp_type (s, TREE_TYPE (i));
    1645            0 :           m2pp_recordfield_bitfield (s, i);
    1646            0 :           m2pp_print (s, ";\n");
    1647              :         }
    1648            0 :       setindent (s, p);
    1649            0 :       m2pp_print (s, "END");
    1650            0 :       setindent (s, o);
    1651              :     }
    1652            0 :   pop ();
    1653            0 : }
    1654              : 
    1655              : /* m2pp_print_mode.  */
    1656              : 
    1657              : static void
    1658            0 : m2pp_print_mode (pretty *s, tree t)
    1659              : {
    1660            0 :   int mode = SCALAR_FLOAT_TYPE_MODE (t);
    1661            0 :   char buf[100];
    1662              : 
    1663            0 :   snprintf (buf, sizeof (buf), "%d", mode);
    1664            0 :   m2pp_print (s, "<*");
    1665            0 :   m2pp_needspace (s);
    1666            0 :   m2pp_print (s, buf);
    1667            0 :   m2pp_needspace (s);
    1668            0 :   m2pp_print (s, "*>");
    1669            0 : }
    1670              : 
    1671              : /* m2pp_simple_type.  */
    1672              : 
    1673              : static void
    1674            0 : m2pp_simple_type (pretty *s, tree t)
    1675              : {
    1676            0 :   if (begin_printed (t))
    1677              :     {
    1678            0 :       m2pp_print (s, "<...>");
    1679            0 :       return;
    1680              :     }
    1681              : 
    1682            0 :   m2pp_gimpified (s, t);
    1683            0 :   switch (TREE_CODE (t))
    1684              :     {
    1685            0 :     case INTEGER_TYPE:
    1686            0 :       m2pp_integer (s, t);
    1687            0 :       break;
    1688            0 :     case REAL_TYPE:
    1689            0 :       m2pp_real_type (s, t);
    1690            0 :       m2pp_print_mode (s, t);
    1691            0 :       break;
    1692            0 :     case BOOLEAN_TYPE:
    1693            0 :       m2pp_print (s, "BOOLEAN");
    1694            0 :       break;
    1695            0 :     case VOID_TYPE:
    1696            0 :       m2pp_print (s, "ADDRESS");
    1697            0 :       break;
    1698            0 :     case TYPE_DECL:
    1699            0 :       m2pp_identifier (s, t);
    1700            0 :       break;
    1701            0 :     case POINTER_TYPE:
    1702            0 :       m2pp_pointer_type (s, t);
    1703            0 :       break;
    1704            0 :     case RECORD_TYPE:
    1705            0 :       m2pp_record_type (s, t);
    1706            0 :       break;
    1707            0 :     case UNION_TYPE:
    1708            0 :       m2pp_union_type (s, t);
    1709            0 :       break;
    1710            0 :     case ENUMERAL_TYPE:
    1711            0 :       m2pp_enum (s, t);
    1712            0 :       break;
    1713            0 :     case COMPLEX_TYPE:
    1714            0 :       m2pp_complex (s, t);
    1715            0 :       break;
    1716            0 :     default:
    1717            0 :       m2pp_unknown (s, __FUNCTION__, get_tree_code_name (TREE_CODE (t)));
    1718              :     }
    1719              : }
    1720              : 
    1721              : /* m2pp_float issue a VAL (type, expr) expression.  */
    1722              : 
    1723              : static void
    1724            0 : m2pp_float (pretty *s, tree t)
    1725              : {
    1726            0 :   m2pp_needspace (s);
    1727            0 :   m2pp_print (s, "VAL (");
    1728            0 :   m2pp_simple_type (s, TREE_TYPE (t));
    1729            0 :   m2pp_print (s, ", ");
    1730            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    1731            0 :   m2pp_print (s, ")");
    1732            0 : }
    1733              : 
    1734              : /* m2pp_expression display an expression.  */
    1735              : 
    1736              : static void
    1737            0 : m2pp_expression (pretty *s, tree t)
    1738              : {
    1739            0 :   enum tree_code code = TREE_CODE (t);
    1740              : 
    1741            0 :   switch (code)
    1742              :     {
    1743            0 :     case EQ_EXPR:
    1744            0 :       m2pp_relop (s, t, "=");
    1745            0 :       break;
    1746            0 :     case NE_EXPR:
    1747            0 :       m2pp_relop (s, t, "#");
    1748            0 :       break;
    1749            0 :     case LE_EXPR:
    1750            0 :       m2pp_relop (s, t, "<=");
    1751            0 :       break;
    1752            0 :     case GE_EXPR:
    1753            0 :       m2pp_relop (s, t, ">=");
    1754            0 :       break;
    1755            0 :     case LT_EXPR:
    1756            0 :       m2pp_relop (s, t, "<");
    1757            0 :       break;
    1758            0 :     case GT_EXPR:
    1759            0 :       m2pp_relop (s, t, ">");
    1760            0 :       break;
    1761            0 :     case FLOAT_EXPR:
    1762            0 :       m2pp_float (s, t);
    1763            0 :       break;
    1764            0 :     default:
    1765            0 :       m2pp_simple_expression (s, t);
    1766              :     }
    1767            0 : }
    1768              : 
    1769              : /* m2pp_relop displays the lhs relop rhs.  */
    1770              : 
    1771              : static void
    1772            0 : m2pp_relop (pretty *s, tree t, const char *p)
    1773              : {
    1774            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    1775            0 :   m2pp_needspace (s);
    1776            0 :   m2pp_print (s, p);
    1777            0 :   m2pp_needspace (s);
    1778            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    1779            0 : }
    1780              : 
    1781              : /* m2pp_compound_expression handle compound expression tree.  */
    1782              : 
    1783              : static void
    1784            0 : m2pp_compound_expression (pretty *s, tree t)
    1785              : {
    1786            0 :   m2pp_print (s, "compound expression {");
    1787            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    1788            0 :   m2pp_print (s, " (* result ignored *), ");
    1789            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    1790            0 :   m2pp_print (s, "}");
    1791            0 :   m2pp_needspace (s);
    1792            0 : }
    1793              : 
    1794              : /* m2pp_target_expression handle target expression tree.  */
    1795              : 
    1796              : static void
    1797            0 : m2pp_target_expression (pretty *s, tree t)
    1798              : {
    1799            0 :   m2pp_print (s, "{");
    1800            0 :   m2pp_needspace (s);
    1801            0 :   if (TREE_OPERAND (t, 0) != NULL_TREE)
    1802              :     {
    1803            0 :       m2pp_print (s, "(* target *) ");
    1804            0 :       m2pp_expression (s, TREE_OPERAND (t, 0));
    1805            0 :       m2pp_print (s, ",");
    1806            0 :       m2pp_needspace (s);
    1807              :     }
    1808            0 :   if (TREE_OPERAND (t, 1) != NULL_TREE)
    1809              :     {
    1810            0 :       m2pp_print (s, "(* initializer *) ");
    1811            0 :       m2pp_expression (s, TREE_OPERAND (t, 1));
    1812            0 :       m2pp_print (s, ",");
    1813            0 :       m2pp_needspace (s);
    1814              :     }
    1815            0 :   if (TREE_OPERAND (t, 2) != NULL_TREE)
    1816              :     {
    1817            0 :       m2pp_print (s, "(* cleanup *) ");
    1818            0 :       m2pp_expression (s, TREE_OPERAND (t, 2));
    1819            0 :       m2pp_print (s, ",");
    1820            0 :       m2pp_needspace (s);
    1821              :     }
    1822            0 :   if (TREE_OPERAND (t, 3) != NULL_TREE)
    1823              :     {
    1824            0 :       m2pp_print (s, "(* saved initializer *) ");
    1825            0 :       m2pp_expression (s, TREE_OPERAND (t, 3));
    1826            0 :       m2pp_print (s, ",");
    1827            0 :       m2pp_needspace (s);
    1828              :     }
    1829            0 :   m2pp_print (s, "}");
    1830            0 :   m2pp_needspace (s);
    1831            0 : }
    1832              : 
    1833              : /* m2pp_constructor print out a constructor.  */
    1834              : 
    1835              : static void
    1836            0 : m2pp_constructor (pretty *s, tree t)
    1837              : {
    1838            0 :   tree purpose, value;
    1839            0 :   unsigned HOST_WIDE_INT ix;
    1840              : 
    1841            0 :   m2pp_print (s, "{ ");
    1842            0 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), ix, purpose, value)
    1843              :   {
    1844            0 :     m2pp_print (s, "(index: ");
    1845            0 :     m2pp_simple_expression (s, purpose);
    1846            0 :     m2pp_print (s, ") ");
    1847            0 :     m2pp_simple_expression (s, value);
    1848            0 :     m2pp_print (s, ", ");
    1849              :   }
    1850            0 :   m2pp_print (s, "}");
    1851              : #ifdef VERBOSE_TYPE_DESC
    1852              :   m2pp_print (s, "(* type: ");
    1853              :   setindent (s, getindent (s) + 8);
    1854              :   m2pp_type (s, TREE_TYPE (t));
    1855              :   setindent (s, getindent (s) - 8);
    1856              :   m2pp_print (s, " *)\n");
    1857              : #endif
    1858            0 : }
    1859              : 
    1860              : /* m2pp_complex_expr handle GCC complex_expr tree.  */
    1861              : 
    1862              : static void
    1863            0 : m2pp_complex_expr (pretty *s, tree t)
    1864              : {
    1865            0 :   if (TREE_CODE (t) == COMPLEX_CST)
    1866              :     {
    1867            0 :       m2pp_print (s, "CMPLX(");
    1868            0 :       m2pp_needspace (s);
    1869            0 :       m2pp_expression (s, TREE_REALPART (t));
    1870            0 :       m2pp_print (s, ",");
    1871            0 :       m2pp_needspace (s);
    1872            0 :       m2pp_expression (s, TREE_IMAGPART (t));
    1873            0 :       m2pp_print (s, ")");
    1874              :     }
    1875              :   else
    1876              :     {
    1877            0 :       m2pp_print (s, "CMPLX(");
    1878            0 :       m2pp_needspace (s);
    1879            0 :       m2pp_expression (s, TREE_OPERAND (t, 0));
    1880            0 :       m2pp_print (s, ",");
    1881            0 :       m2pp_needspace (s);
    1882            0 :       m2pp_expression (s, TREE_OPERAND (t, 1));
    1883            0 :       m2pp_print (s, ")");
    1884              :     }
    1885            0 : }
    1886              : 
    1887              : /* m2pp_imagpart_expr handle imagpart_expr tree.  */
    1888              : 
    1889              : static void
    1890            0 : m2pp_imagpart_expr (pretty *s, tree t)
    1891              : {
    1892            0 :   m2pp_print (s, "IM(");
    1893            0 :   m2pp_needspace (s);
    1894            0 :   if (TREE_CODE (t) == IMAGPART_EXPR)
    1895            0 :     m2pp_expression (s, TREE_OPERAND (t, 0));
    1896            0 :   else if (TREE_CODE (t) == COMPLEX_CST)
    1897            0 :     m2pp_expression (s, TREE_IMAGPART (t));
    1898            0 :   m2pp_needspace (s);
    1899            0 :   m2pp_print (s, ")");
    1900            0 : }
    1901              : 
    1902              : /* m2pp_realpart_expr handle imagpart_expr tree.  */
    1903              : 
    1904              : static void
    1905            0 : m2pp_realpart_expr (pretty *s, tree t)
    1906              : {
    1907            0 :   m2pp_print (s, "RE(");
    1908            0 :   m2pp_needspace (s);
    1909            0 :   if (TREE_CODE (t) == REALPART_EXPR)
    1910            0 :     m2pp_expression (s, TREE_OPERAND (t, 0));
    1911            0 :   else if (TREE_CODE (t) == COMPLEX_CST)
    1912            0 :     m2pp_expression (s, TREE_REALPART (t));
    1913            0 :   m2pp_needspace (s);
    1914            0 :   m2pp_print (s, ")");
    1915            0 : }
    1916              : 
    1917              : /* m2pp_bit_ior_expr generate a C style bit or.  */
    1918              : 
    1919              : static void
    1920            0 : m2pp_bit_ior_expr (pretty *s, tree t)
    1921              : {
    1922            0 :   m2pp_binary (s, t, "|");
    1923            0 : }
    1924              : 
    1925              : /* m2pp_bit_and_expr generate a C style bit and.  */
    1926              : 
    1927              : static void
    1928            0 : m2pp_bit_and_expr (pretty *s, tree t)
    1929              : {
    1930            0 :   m2pp_binary (s, t, "&");
    1931            0 : }
    1932              : 
    1933              : /* m2pp_truth_expr.  */
    1934              : 
    1935              : static void
    1936            0 : m2pp_truth_expr (pretty *s, tree t, const char *op)
    1937              : {
    1938            0 :   m2pp_print (s, "(");
    1939            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    1940            0 :   m2pp_print (s, ")");
    1941            0 :   m2pp_needspace (s);
    1942            0 :   m2pp_print (s, op);
    1943            0 :   m2pp_needspace (s);
    1944            0 :   m2pp_print (s, "(");
    1945            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    1946            0 :   m2pp_print (s, ")");
    1947            0 : }
    1948              : 
    1949              : /* m2pp_binary_function handle GCC expression tree as a function.  */
    1950              : 
    1951              : static void
    1952            0 : m2pp_binary_function (pretty *s, tree t, const char *funcname)
    1953              : {
    1954            0 :   m2pp_print (s, funcname);
    1955            0 :   m2pp_needspace (s);
    1956            0 :   m2pp_print (s, "(");
    1957            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    1958            0 :   m2pp_print (s, ",");
    1959            0 :   m2pp_needspace (s);
    1960            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    1961            0 :   m2pp_print (s, ")");
    1962            0 : }
    1963              : 
    1964              : static void
    1965            0 : m2pp_shiftrotate_expr (pretty *s, tree t, const char *op)
    1966              : {
    1967            0 :   tree left = TREE_OPERAND (t, 0);
    1968            0 :   tree right = TREE_OPERAND (t, 1);
    1969            0 :   m2pp_print (s, "(");
    1970            0 :   m2pp_expression (s, left);
    1971            0 :   m2pp_print (s, ")");
    1972            0 :   m2pp_needspace (s);
    1973            0 :   m2pp_print (s, op);
    1974            0 :   m2pp_needspace (s);
    1975            0 :   m2pp_print (s, "(");
    1976            0 :   m2pp_expression (s, right);
    1977            0 :   m2pp_print (s, ")");
    1978            0 : }
    1979              : 
    1980              : /* m2pp_simple_expression handle GCC expression tree.  */
    1981              : 
    1982              : static void
    1983            0 : m2pp_simple_expression (pretty *s, tree t)
    1984              : {
    1985            0 :   enum tree_code code = TREE_CODE (t);
    1986              : 
    1987            0 :   switch (code)
    1988              :     {
    1989            0 :     case ERROR_MARK:
    1990            0 :       m2pp_print (s, "(* !!! ERROR NODE !!! *)");
    1991            0 :       break;
    1992            0 :     case CONSTRUCTOR:
    1993            0 :       m2pp_constructor (s, t);
    1994            0 :       break;
    1995            0 :     case IDENTIFIER_NODE:
    1996            0 :       m2pp_ident_pointer (s, t);
    1997            0 :       break;
    1998            0 :     case PARM_DECL:
    1999            0 :       m2pp_identifier (s, t);
    2000            0 :       break;
    2001            0 :     case FIELD_DECL:
    2002            0 :       m2pp_identifier (s, t);
    2003            0 :       break;
    2004            0 :     case TREE_LIST:
    2005            0 :       m2pp_list (s, t);
    2006            0 :       break;
    2007            0 :     case BLOCK:
    2008            0 :       m2pp_print (s, "(* BLOCK NODE *)");
    2009            0 :       break;
    2010            0 :     case OFFSET_TYPE:
    2011            0 :       m2pp_offset (s, t);
    2012            0 :       break;
    2013            0 :     case INTEGER_CST:
    2014            0 :       m2pp_integer_cst (s, t);
    2015            0 :       break;
    2016            0 :     case REAL_CST:
    2017            0 :       m2pp_real_cst (s, t);
    2018            0 :       break;
    2019            0 :     case STRING_CST:
    2020            0 :       m2pp_string_cst (s, t);
    2021            0 :       break;
    2022            0 :     case INDIRECT_REF:
    2023            0 :       m2pp_indirect_ref (s, t);
    2024            0 :       break;
    2025            0 :     case ADDR_EXPR:
    2026            0 :       m2pp_addr_expr (s, t);
    2027            0 :       break;
    2028            0 :     case NOP_EXPR:
    2029            0 :       m2pp_nop (s, t);
    2030            0 :       break;
    2031            0 :     case CONVERT_EXPR:
    2032            0 :       m2pp_convert (s, t);
    2033            0 :       break;
    2034            0 :     case VAR_DECL:
    2035            0 :       m2pp_var_decl (s, t);
    2036            0 :       break;
    2037            0 :     case RESULT_DECL:
    2038            0 :       m2pp_result_decl (s, t);
    2039            0 :       break;
    2040            0 :     case PLUS_EXPR:
    2041            0 :       m2pp_binary (s, t, "+");
    2042            0 :       break;
    2043            0 :     case MINUS_EXPR:
    2044            0 :       m2pp_binary (s, t, "-");
    2045            0 :       break;
    2046            0 :     case MULT_EXPR:
    2047            0 :       m2pp_binary (s, t, "*");
    2048            0 :       break;
    2049            0 :     case FLOOR_DIV_EXPR:
    2050            0 :     case CEIL_DIV_EXPR:
    2051            0 :     case TRUNC_DIV_EXPR:
    2052            0 :     case ROUND_DIV_EXPR:
    2053            0 :       m2pp_binary (s, t, "DIV");
    2054            0 :       break;
    2055            0 :     case FLOOR_MOD_EXPR:
    2056            0 :     case CEIL_MOD_EXPR:
    2057            0 :     case TRUNC_MOD_EXPR:
    2058            0 :     case ROUND_MOD_EXPR:
    2059            0 :       m2pp_binary (s, t, "MOD");
    2060            0 :       break;
    2061            0 :     case NEGATE_EXPR:
    2062            0 :       m2pp_unary (s, t, "-");
    2063            0 :       break;
    2064            0 :     case CALL_EXPR:
    2065            0 :       m2pp_call_expr (s, t);
    2066            0 :       break;
    2067            0 :     case SSA_NAME:
    2068            0 :       m2pp_ssa (s, t);
    2069            0 :       break;
    2070            0 :     case COMPONENT_REF:
    2071            0 :       m2pp_component_ref (s, t);
    2072            0 :       break;
    2073            0 :     case RETURN_EXPR:
    2074            0 :       m2pp_return_expr (s, t);
    2075            0 :       break;
    2076            0 :     case ARRAY_REF:
    2077            0 :       m2pp_array_ref (s, t);
    2078            0 :       break;
    2079            0 :     case NON_LVALUE_EXPR:
    2080            0 :       m2pp_non_lvalue_expr (s, t);
    2081            0 :       break;
    2082            0 :     case EXPR_STMT:
    2083            0 :       m2pp_expression (s, EXPR_STMT_EXPR (t));
    2084            0 :       break;
    2085              : #if 0
    2086              :     case EXC_PTR_EXPR:
    2087              :       m2pp_print (s, "GCC_EXCEPTION_OBJECT");
    2088              :       break;
    2089              : #endif
    2090            0 :     case INIT_EXPR:
    2091            0 :     case MODIFY_EXPR:
    2092            0 :       m2pp_assignment (s, t);
    2093            0 :       break;
    2094            0 :     case COMPOUND_EXPR:
    2095            0 :       m2pp_compound_expression (s, t);
    2096            0 :       break;
    2097            0 :     case TARGET_EXPR:
    2098            0 :       m2pp_target_expression (s, t);
    2099            0 :       break;
    2100            0 :     case THROW_EXPR:
    2101            0 :       m2pp_throw (s, t);
    2102            0 :       break;
    2103            0 :     case FUNCTION_DECL:
    2104            0 :       m2pp_identifier (s, t);
    2105            0 :       break;
    2106            0 :     case COMPLEX_EXPR:
    2107            0 :       m2pp_complex_expr (s, t);
    2108            0 :       break;
    2109            0 :     case REALPART_EXPR:
    2110            0 :       m2pp_realpart_expr (s, t);
    2111            0 :       break;
    2112            0 :     case IMAGPART_EXPR:
    2113            0 :       m2pp_imagpart_expr (s, t);
    2114            0 :       break;
    2115            0 :     case CONST_DECL:
    2116            0 :       m2pp_identifier (s, t);
    2117            0 :       break;
    2118            0 :     case POINTER_PLUS_EXPR:
    2119            0 :       m2pp_binary (s, t, "+");
    2120            0 :       break;
    2121            0 :     case CLEANUP_POINT_EXPR:
    2122            0 :       m2pp_cleanup_point_expr (s, t);
    2123            0 :       break;
    2124            0 :     case BIT_IOR_EXPR:
    2125            0 :       m2pp_bit_ior_expr (s, t);
    2126            0 :       break;
    2127            0 :     case BIT_AND_EXPR:
    2128            0 :       m2pp_bit_and_expr (s, t);
    2129            0 :       break;
    2130            0 :     case TRUTH_ANDIF_EXPR:
    2131            0 :       m2pp_truth_expr (s, t, "AND");
    2132            0 :       break;
    2133            0 :     case TRUTH_ORIF_EXPR:
    2134            0 :       m2pp_truth_expr (s, t, "OR");
    2135            0 :       break;
    2136            0 :     case LSHIFT_EXPR:
    2137            0 :       m2pp_shiftrotate_expr (s, t, "<<");
    2138            0 :       break;
    2139            0 :     case RSHIFT_EXPR:
    2140            0 :       m2pp_shiftrotate_expr (s, t, ">>");
    2141            0 :       break;
    2142            0 :     case LROTATE_EXPR:
    2143            0 :       m2pp_binary_function (s, t, "LROTATE");
    2144            0 :       break;
    2145            0 :     case RROTATE_EXPR:
    2146            0 :       m2pp_binary_function (s, t, "RROTATE");      
    2147            0 :       break;
    2148            0 :     default:
    2149            0 :       m2pp_unknown (s, __FUNCTION__, get_tree_code_name (code));
    2150              :     }
    2151            0 : }
    2152              : 
    2153              : /* non_lvalue_expr indicates that operand 0 is not an lvalue.  */
    2154              : 
    2155              : static void
    2156            0 : m2pp_non_lvalue_expr (pretty *s, tree t)
    2157              : {
    2158            0 :   m2pp_needspace (s);
    2159            0 :   m2pp_print (s, "assert_non_lvalue(");
    2160            0 :   m2pp_needspace (s);
    2161            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2162            0 :   m2pp_needspace (s);
    2163            0 :   m2pp_print (s, ")");
    2164            0 : }
    2165              : 
    2166              : /* m2pp_array_ref prints out the array reference.  */
    2167              : 
    2168              : static void
    2169            0 : m2pp_array_ref (pretty *s, tree t)
    2170              : {
    2171            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2172            0 :   m2pp_print (s, "[");
    2173            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    2174            0 :   m2pp_print (s, "]");
    2175            0 : }
    2176              : 
    2177              : /* m2pp_ssa prints out the ssa variable name.  */
    2178              : 
    2179              : static void
    2180            0 : m2pp_ssa (pretty *s, tree t)
    2181              : {
    2182            0 :   m2pp_identifier (s, SSA_NAME_VAR (t));
    2183            0 : }
    2184              : 
    2185              : /* m2pp_binary print the binary operator, p, and lhs, rhs.  */
    2186              : 
    2187              : static void
    2188            0 : m2pp_binary (pretty *s, tree t, const char *p)
    2189              : {
    2190            0 :   tree left = TREE_OPERAND (t, 0);
    2191            0 :   tree right = TREE_OPERAND (t, 1);
    2192              : 
    2193            0 :   m2pp_expression (s, left);
    2194            0 :   m2pp_needspace (s);
    2195            0 :   m2pp_print (s, p);
    2196            0 :   m2pp_needspace (s);
    2197            0 :   m2pp_expression (s, right);
    2198            0 : }
    2199              : 
    2200              : /* m2pp_unary print the unary operator, p, and expression.  */
    2201              : 
    2202              : static void
    2203            0 : m2pp_unary (pretty *s, tree t, const char *p)
    2204              : {
    2205            0 :   tree expr = TREE_OPERAND (t, 0);
    2206              : 
    2207            0 :   m2pp_needspace (s);
    2208            0 :   m2pp_print (s, p);
    2209            0 :   m2pp_expression (s, expr);
    2210            0 : }
    2211              : 
    2212              : /* m2pp_integer_cst displays the integer constant.  */
    2213              : 
    2214              : static void
    2215            0 : m2pp_integer_cst (pretty *s, tree t)
    2216              : {
    2217            0 :   char val[100];
    2218              : 
    2219            0 :   snprintf (val, 100, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (t));
    2220            0 :   m2pp_print (s, val);
    2221            0 : }
    2222              : 
    2223              : /* m2pp_real_cst displays the real constant.  */
    2224              : 
    2225              : static void
    2226            0 : m2pp_real_cst (pretty *s, tree t ATTRIBUTE_UNUSED)
    2227              : {
    2228            0 :   m2pp_print (s, "<unknown real>");
    2229            0 : }
    2230              : 
    2231              : /* m2pp_string_cst displays the real constant.  */
    2232              : 
    2233              : static void
    2234            0 : m2pp_string_cst (pretty *s, tree t)
    2235              : {
    2236            0 :   const char *p = TREE_STRING_POINTER (t);
    2237            0 :   int i = 0;
    2238              : 
    2239            0 :   m2pp_print (s, "\"");
    2240            0 :   while (p[i] != '\0')
    2241              :     {
    2242            0 :       m2pp_print_char (s, p[i]);
    2243            0 :       i++;
    2244              :     }
    2245            0 :   m2pp_print (s, "\"");
    2246            0 : }
    2247              : 
    2248              : /* m2pp_statement_sequence iterates over a statement list
    2249              :    displaying each statement in turn.  */
    2250              : 
    2251              : static void
    2252            0 : m2pp_statement_sequence (pretty *s, tree t)
    2253              : {
    2254            0 :   if (t != NULL_TREE)
    2255              :     {
    2256            0 :       if (TREE_CODE (t) == STATEMENT_LIST)
    2257              :         {
    2258            0 :           tree_stmt_iterator i;
    2259            0 :           m2pp_print (s, "(* statement list *)\n");
    2260              : 
    2261            0 :           for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
    2262            0 :             m2pp_statement (s, *tsi_stmt_ptr (i));
    2263              :         }
    2264              :       else
    2265            0 :         m2pp_statement (s, t);
    2266              :     }
    2267            0 : }
    2268              : 
    2269              : /* m2pp_unknown displays an error message.  */
    2270              : 
    2271              : static void
    2272            0 : m2pp_unknown (pretty *s, const char *s1, const char *s2)
    2273              : {
    2274            0 :   m2pp_begin (s);
    2275            0 :   m2pp_print (s, s1);
    2276            0 :   m2pp_needspace (s);
    2277            0 :   m2pp_print (s, s2);
    2278            0 :   m2pp_needspace (s);
    2279            0 : }
    2280              : 
    2281              : /* m2pp_throw displays a throw statement.  */
    2282              : 
    2283              : static void
    2284            0 : m2pp_throw (pretty *s, tree t)
    2285              : {
    2286            0 :   tree expr = TREE_OPERAND (t, 0);
    2287              : 
    2288            0 :   m2pp_begin (s);
    2289            0 :   if (expr == NULL_TREE)
    2290            0 :     m2pp_print (s, "THROW ;\n");
    2291              :   else
    2292              :     {
    2293            0 :       m2pp_print (s, "THROW (");
    2294            0 :       m2pp_expression (s, TREE_OPERAND (t, 0));
    2295            0 :       m2pp_print (s, ")\n");
    2296              :     }
    2297            0 : }
    2298              : 
    2299              : /* m2pp_catch_expr attempts to reconstruct a catch expr.  */
    2300              : 
    2301              : static void
    2302            0 : m2pp_catch_expr (pretty *s, tree t)
    2303              : {
    2304            0 :   tree types = CATCH_TYPES (t);
    2305            0 :   tree body = CATCH_BODY (t);
    2306              : 
    2307            0 :   m2pp_print (s, "(* CATCH expression ");
    2308            0 :   if (types != NULL_TREE)
    2309              :     {
    2310            0 :       m2pp_print (s, "(");
    2311            0 :       m2pp_expression (s, types);
    2312            0 :       m2pp_print (s, ")");
    2313              :     }
    2314            0 :   m2pp_print (s, "*)\n");
    2315            0 :   m2pp_print (s, "(* catch body *)\n");
    2316            0 :   m2pp_statement_sequence (s, body);
    2317            0 :   m2pp_print (s, "(* end catch body *)\n");
    2318            0 : }
    2319              : 
    2320              : /* m2pp_try_finally_expr attemts to reconstruct a try finally expr.  */
    2321              : 
    2322              : static void
    2323            0 : m2pp_try_finally_expr (pretty *s, tree t)
    2324              : {
    2325            0 :   m2pp_begin (s);
    2326            0 :   m2pp_print (s, "(* try_finally_expr *)\n");
    2327            0 :   setindent (s, getindent (s) + 3);
    2328            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 0));
    2329            0 :   setindent (s, getindent (s) - 3);
    2330            0 :   m2pp_print (s,
    2331              :               "(* finally (cleanup which is executed after the above) *)\n");
    2332            0 :   setindent (s, getindent (s) + 3);
    2333            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 1));
    2334            0 :   setindent (s, getindent (s) - 3);
    2335            0 :   m2pp_print (s, "(* end try_finally_expr *)\n");
    2336            0 : }
    2337              : 
    2338              : /* m2pp_if_stmt pretty print a if_stmt tree.  Modula-2 does not use this to
    2339              :    generate IF THEN ELSE END statements, instead it uses labels and gotos.  */
    2340              : 
    2341              : static void
    2342            0 : m2pp_if_stmt (pretty *s, tree t)
    2343              : {
    2344            0 :   m2pp_print (s, "(* An if_stmt node.  *)\n");
    2345            0 :   m2pp_print (s, "IF ");
    2346            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2347            0 :   m2pp_print (s, "\n");
    2348            0 :   m2pp_print (s, "THEN\n");
    2349            0 :   setindent (s, getindent (s) + 3);
    2350            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 1));
    2351            0 :   setindent (s, getindent (s) - 3);
    2352            0 :   m2pp_print (s, "ELSE\n");
    2353            0 :   setindent (s, getindent (s) + 3);
    2354            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 2));
    2355            0 :   setindent (s, getindent (s) - 3);
    2356            0 :   m2pp_print (s, "END\n");
    2357            0 : }
    2358              : 
    2359              : static void
    2360            0 : m2pp_asm_expr (pretty *state, tree node)
    2361              : {
    2362            0 :   m2pp_begin (state);
    2363            0 :   m2pp_print (state, "ASM");
    2364            0 :   m2pp_needspace (state);
    2365            0 :   if (ASM_VOLATILE_P (node))
    2366              :     {
    2367            0 :       m2pp_print (state, "VOLATILE");
    2368            0 :       m2pp_needspace (state);
    2369              :     }
    2370            0 :   m2pp_print (state, "(");
    2371            0 :   m2pp_expression (state, ASM_STRING (node));
    2372            0 :   m2pp_print (state, ":");
    2373            0 :   m2pp_needspace (state);
    2374            0 :   m2pp_expression (state, ASM_OUTPUTS (node));
    2375            0 :   m2pp_print (state, ":");
    2376            0 :   m2pp_needspace (state);
    2377            0 :   m2pp_expression (state, ASM_INPUTS (node));
    2378            0 :   if (ASM_CLOBBERS (node) != NULL)
    2379              :     {
    2380            0 :       m2pp_print (state, ":");
    2381            0 :       m2pp_needspace (state);
    2382            0 :       m2pp_expression (state, ASM_CLOBBERS (node));
    2383              :     }
    2384            0 :   m2pp_print (state, ");\n");
    2385            0 : }
    2386              : 
    2387              : /* m2pp_nop_expr display the nop_expr node.  */
    2388              : 
    2389              : static void
    2390            0 : m2pp_nop_expr (pretty *state, tree t)
    2391              : {
    2392            0 :   m2pp_begin (state);
    2393            0 :   m2pp_print (state, "(* NOP for debug location *)");
    2394            0 :   m2pp_needspace (state);
    2395            0 :   m2pp_loc (state, t);
    2396            0 : }
    2397              :   
    2398              : /* m2pp_statement attempts to reconstruct a statement.  */
    2399              : 
    2400              : static void
    2401            0 : m2pp_statement (pretty *s, tree t)
    2402              : {
    2403            0 :   enum tree_code code = TREE_CODE (t);
    2404              : 
    2405            0 :   m2pp_loc (s, t);
    2406            0 :   switch (code)
    2407              :     {
    2408            0 :     case COND_EXPR:
    2409            0 :       m2pp_conditional (s, t);
    2410            0 :       break;
    2411            0 :     case LABEL_EXPR:
    2412            0 :       m2pp_label_expr (s, t);
    2413            0 :       break;
    2414            0 :     case LABEL_DECL:
    2415            0 :       m2pp_label_decl (s, t);
    2416            0 :       break;
    2417            0 :     case GOTO_EXPR:
    2418            0 :       m2pp_goto (s, t);
    2419            0 :       break;
    2420            0 :     case INIT_EXPR:
    2421            0 :     case MODIFY_EXPR:
    2422            0 :       m2pp_assignment (s, t);
    2423            0 :       break;
    2424            0 :     case CALL_EXPR:
    2425            0 :       m2pp_procedure_call (s, t);
    2426            0 :       break;
    2427            0 :     case BLOCK:
    2428            0 :       m2pp_block_list (s, t);
    2429            0 :       break;
    2430            0 :     case BIND_EXPR:
    2431            0 :       m2pp_bind_expr (s, t);
    2432            0 :       break;
    2433            0 :     case RETURN_EXPR:
    2434            0 :       m2pp_return_expr (s, t);
    2435            0 :       break;
    2436            0 :     case DECL_EXPR:
    2437            0 :       m2pp_decl_expr (s, t);
    2438            0 :       break;
    2439            0 :     case TRY_BLOCK:
    2440            0 :       m2pp_try_block (s, t);
    2441            0 :       break;
    2442            0 :     case HANDLER:
    2443            0 :       m2pp_handler (s, t);
    2444            0 :       break;
    2445            0 :     case CLEANUP_POINT_EXPR:
    2446            0 :       m2pp_cleanup_point_expr (s, t);
    2447            0 :       break;
    2448            0 :     case THROW_EXPR:
    2449            0 :       m2pp_throw (s, t);
    2450            0 :       break;
    2451            0 :     case TRY_CATCH_EXPR:
    2452            0 :       m2pp_try_catch_expr (s, t);
    2453            0 :       break;
    2454            0 :     case TRY_FINALLY_EXPR:
    2455            0 :       m2pp_try_finally_expr (s, t);
    2456            0 :       break;
    2457            0 :     case CATCH_EXPR:
    2458            0 :       m2pp_catch_expr (s, t);
    2459            0 :       break;
    2460            0 :     case ASM_EXPR:
    2461            0 :       m2pp_asm_expr (s, t);
    2462            0 :       break;
    2463            0 :     case IF_STMT:
    2464            0 :       m2pp_if_stmt (s, t);
    2465            0 :       break;
    2466            0 :     case NOP_EXPR:
    2467            0 :       m2pp_nop_expr (s, t);
    2468            0 :       break;
    2469            0 :     case ERROR_MARK:
    2470            0 :       m2pp_print (s, "<ERROR CODE>\n");
    2471            0 :       break;
    2472            0 :     default:
    2473            0 :       m2pp_unknown (s, __FUNCTION__, get_tree_code_name (TREE_CODE (t)));
    2474              :     }
    2475            0 : }
    2476              : 
    2477              : /* m2pp_try_catch_expr is used after gimplification.  */
    2478              : 
    2479              : static void
    2480            0 : m2pp_try_catch_expr (pretty *s, tree t)
    2481              : {
    2482            0 :   m2pp_print (s, "(* try_catch_expr begins *)\n");
    2483            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 0));
    2484            0 :   setindent (s, 0);
    2485            0 :   m2pp_print (s, "EXCEPT\n");
    2486            0 :   setindent (s, 3);
    2487            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 1));
    2488            0 :   m2pp_print (s, "(* try_catch_expr ends *)\n");
    2489            0 : }
    2490              : 
    2491              : /* m2pp_cleanup_point_expr emits a comment indicating a GCC
    2492              :    cleanup_point_expr is present.  */
    2493              : 
    2494              : static void
    2495            0 : m2pp_cleanup_point_expr (pretty *s, tree t)
    2496              : {
    2497            0 :   m2pp_begin (s);
    2498            0 :   m2pp_print (s, "(* Cleanup point begins.  *)\n");
    2499            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2500            0 :   m2pp_print (s, "(* Cleanup point ends.  *)\n");
    2501            0 : }
    2502              : 
    2503              : /* m2pp_decl_expr displays a local declaration.  */
    2504              : 
    2505              : static void
    2506            0 : m2pp_decl_expr (pretty *s, tree t)
    2507              : {
    2508            0 :   m2pp_var (s);
    2509            0 :   m2pp_print (s, "(* Variable in decl_expr.  *)\n");
    2510            0 :   m2pp_var_type_decl (s, DECL_EXPR_DECL (t));
    2511            0 : }
    2512              : 
    2513              : /* m2pp_procedure_call print a call to a procedure.  */
    2514              : 
    2515              : static void
    2516            0 : m2pp_procedure_call (pretty *s, tree t)
    2517              : {
    2518            0 :   m2pp_begin (s);
    2519            0 :   m2pp_call_expr (s, t);
    2520            0 :   m2pp_needspace (s);
    2521            0 :   m2pp_print (s, ";\n");
    2522            0 : }
    2523              : 
    2524              : /* args displays each argument in an iter list by calling expression.  */
    2525              : 
    2526              : static void
    2527            0 : m2pp_args (pretty *s, tree e)
    2528              : {
    2529            0 :   call_expr_arg_iterator iter;
    2530            0 :   tree arg;
    2531              : 
    2532            0 :   m2pp_print (s, "(");
    2533            0 :   m2pp_needspace (s);
    2534            0 :   FOR_EACH_CALL_EXPR_ARG (arg, iter, e)
    2535              :   {
    2536            0 :     m2pp_expression (s, arg);
    2537            0 :     if (more_call_expr_args_p (&iter))
    2538              :       {
    2539            0 :         m2pp_print (s, ",");
    2540            0 :         m2pp_needspace (s);
    2541              :       }
    2542              :   }
    2543            0 :   m2pp_print (s, ")");
    2544            0 : }
    2545              : 
    2546              : /* m2pp_call_expr print a call to a procedure or function.  */
    2547              : 
    2548              : static void
    2549            0 : m2pp_call_expr (pretty *s, tree t)
    2550              : {
    2551            0 :   tree call = CALL_EXPR_FN (t);
    2552            0 :   tree args = TREE_OPERAND (t, 1);
    2553            0 :   tree type = TREE_TYPE (t);
    2554            0 :   bool has_return_type = true;
    2555            0 :   tree proc;
    2556              : 
    2557            0 :   if (type && VOID_TYPE_P (type))
    2558            0 :     has_return_type = false;
    2559              : 
    2560            0 :   if (TREE_CODE (call) == ADDR_EXPR || TREE_CODE (call) == NON_LVALUE_EXPR)
    2561            0 :     proc = TREE_OPERAND (call, 0);
    2562              :   else
    2563              :     proc = call;
    2564              : 
    2565            0 :   m2pp_expression (s, proc);
    2566            0 :   if (args || has_return_type)
    2567            0 :     m2pp_args (s, t);
    2568            0 : }
    2569              : 
    2570              : /* m2pp_return_expr displays the return statement.  */
    2571              : 
    2572              : static void
    2573            0 : m2pp_return_expr (pretty *s, tree t)
    2574              : {
    2575            0 :   tree e = TREE_OPERAND (t, 0);
    2576              : 
    2577            0 :   m2pp_begin (s);
    2578            0 :   if (e == NULL_TREE)
    2579              :     {
    2580            0 :       m2pp_print (s, "RETURN");
    2581              :     }
    2582            0 :   else if (TREE_CODE (e) == MODIFY_EXPR || (TREE_CODE (e) == INIT_EXPR))
    2583              :     {
    2584            0 :       m2pp_assignment (s, e);
    2585            0 :       m2pp_print (s, "RETURN");
    2586            0 :       m2pp_needspace (s);
    2587            0 :       m2pp_expression (s, TREE_OPERAND (e, 0));
    2588              :     }
    2589              :   else
    2590              :     {
    2591            0 :       m2pp_print (s, "RETURN");
    2592            0 :       m2pp_needspace (s);
    2593            0 :       m2pp_expression (s, e);
    2594              :     }
    2595            0 :   m2pp_needspace (s);
    2596            0 :   m2pp_print (s, ";\n");
    2597            0 : }
    2598              : 
    2599              : /* m2pp_try_block displays the try block.  */
    2600              : 
    2601              : static void
    2602            0 : m2pp_try_block (pretty *s, tree t)
    2603              : {
    2604            0 :   tree stmts = TRY_STMTS (t);
    2605            0 :   tree handlers = TRY_HANDLERS (t);
    2606              : 
    2607            0 :   m2pp_begin (s);
    2608            0 :   m2pp_print (s, "(* TRY *)\n");
    2609            0 :   m2pp_statement_sequence (s, stmts);
    2610            0 :   setindent (s, 0);
    2611            0 :   m2pp_print (s, "EXCEPT\n");
    2612            0 :   setindent (s, 3);
    2613            0 :   m2pp_statement_sequence (s, handlers);
    2614            0 :   m2pp_print (s, "(* END TRY *)\n");
    2615            0 : }
    2616              : 
    2617              : /* m2pp_try_block displays the handler block.  */
    2618              : 
    2619              : static void
    2620            0 : m2pp_handler (pretty *s, tree t)
    2621              : {
    2622            0 :   tree parms = HANDLER_PARMS (t);
    2623            0 :   tree body = HANDLER_BODY (t);
    2624            0 :   tree type = HANDLER_TYPE (t);
    2625              : 
    2626            0 :   m2pp_print (s, "(* handler *)\n");
    2627            0 :   if (parms != NULL_TREE)
    2628              :     {
    2629            0 :       m2pp_print (s, "(* handler parameter has a type (should be NULL_TREE) "
    2630              :                      "in Modula-2 *)\n");
    2631            0 :       m2pp_print (s, "CATCH (");
    2632            0 :       m2pp_expression (s, parms);
    2633            0 :       m2pp_print (s, ")\n");
    2634              :     }
    2635            0 :   if (type != NULL_TREE)
    2636            0 :     m2pp_print (s, "(* handler type (should be NULL_TREE) in Modula-2 *)\n");
    2637            0 :   m2pp_statement_sequence (s, body);
    2638            0 : }
    2639              : 
    2640              : /* m2pp_assignment prints out the assignment statement.  */
    2641              : 
    2642              : static void
    2643            0 : m2pp_assignment (pretty *s, tree t)
    2644              : {
    2645            0 :   int o;
    2646              : 
    2647            0 :   m2pp_begin (s);
    2648              : #ifdef VERBOSE_TYPE_DESC
    2649              :   /* Print the types of des and expr.  */
    2650              :   m2pp_print (s, "(*");
    2651              :   m2pp_needspace (s);
    2652              :   m2pp_type (s, TREE_TYPE (TREE_OPERAND (t, 0)));
    2653              :   m2pp_needspace (s);
    2654              :   m2pp_print (s, ":=");
    2655              :   m2pp_needspace (s);
    2656              :   m2pp_type (s, TREE_TYPE (TREE_OPERAND (t, 1)));
    2657              :   m2pp_needspace (s);
    2658              :   m2pp_print (s, ";");
    2659              :   m2pp_needspace (s);
    2660              :   m2pp_print (s, "*)\n");
    2661              : #endif
    2662              :   /* Print the assignment statement.  */
    2663            0 :   m2pp_designator (s, TREE_OPERAND (t, 0));
    2664            0 :   m2pp_needspace (s);
    2665            0 :   m2pp_print (s, ":=");
    2666            0 :   m2pp_needspace (s);
    2667            0 :   o = getindent (s);
    2668            0 :   setindent (s, getcurpos (s) + 1);
    2669            0 :   m2pp_expression (s, TREE_OPERAND (t, 1));
    2670            0 :   m2pp_needspace (s);
    2671            0 :   m2pp_print (s, ";\n");
    2672            0 :   setindent (s, o);
    2673            0 : }
    2674              : 
    2675              : /* m2pp_designator displays the lhs of an assignment.  */
    2676              : 
    2677              : static void
    2678            0 : m2pp_designator (pretty *s, tree t)
    2679              : {
    2680            0 :   m2pp_expression (s, t);
    2681            0 : }
    2682              : 
    2683              : /* m2pp_indirect_ref displays the indirect operator.  */
    2684              : 
    2685              : static void
    2686            0 : m2pp_indirect_ref (pretty *s, tree t)
    2687              : {
    2688            0 :   m2pp_print (s, "(");
    2689            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2690            0 :   m2pp_print (s, ")^");
    2691            0 : }
    2692              : 
    2693              : /* m2pp_conditional builds an IF THEN ELSE END.  With more work
    2694              :    this should be moved into statement sequence which could look for
    2695              :    repeat and while loops.  */
    2696              : 
    2697              : static void
    2698            0 : m2pp_conditional (pretty *s, tree t)
    2699              : {
    2700            0 :   int o;
    2701              : 
    2702            0 :   m2pp_begin (s);
    2703            0 :   m2pp_print (s, "IF");
    2704            0 :   m2pp_needspace (s);
    2705            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2706            0 :   m2pp_print (s, "\nTHEN\n");
    2707            0 :   o = getindent (s);
    2708            0 :   setindent (s, o + 3);
    2709            0 :   m2pp_statement_sequence (s, TREE_OPERAND (t, 1));
    2710            0 :   setindent (s, o);
    2711            0 :   if (TREE_OPERAND (t, 2) != NULL_TREE)
    2712              :     {
    2713            0 :       m2pp_print (s, "ELSE\n");
    2714            0 :       setindent (s, o + 3);
    2715            0 :       m2pp_statement_sequence (s, TREE_OPERAND (t, 2));
    2716            0 :       setindent (s, o);
    2717              :     }
    2718            0 :   m2pp_print (s, "END ;\n");
    2719            0 : }
    2720              : 
    2721              : /* m2pp_label_decl displays a label.  Again should be moved into
    2722              :    statement sequence to determine proper loop constructs.  */
    2723              : 
    2724              : static void
    2725            0 : m2pp_label_decl (pretty *s, tree t)
    2726              : {
    2727            0 :   m2pp_begin (s);
    2728            0 :   m2pp_print (s, "(* label  ");
    2729            0 :   m2pp_identifier (s, t);
    2730            0 :   m2pp_print (s, ": *)\n");
    2731            0 : }
    2732              : 
    2733              : /* m2pp_label_expr skips the LABEL_EXPR to find the LABEL_DECL.  */
    2734              : 
    2735              : static void
    2736            0 : m2pp_label_expr (pretty *s, tree t)
    2737              : {
    2738            0 :   m2pp_begin (s);
    2739            0 :   m2pp_statement (s, TREE_OPERAND (t, 0));
    2740            0 : }
    2741              : 
    2742              : /* m2pp_goto displays a goto statement.  Again should be moved into
    2743              :    statement sequence to determine proper loop constructs.  */
    2744              : 
    2745              : static void
    2746            0 : m2pp_goto (pretty *s, tree t)
    2747              : {
    2748            0 :   m2pp_begin (s);
    2749            0 :   m2pp_print (s, "(* goto ");
    2750            0 :   m2pp_identifier (s, TREE_OPERAND (t, 0));
    2751            0 :   m2pp_print (s, " *)\n");
    2752            0 : }
    2753              : 
    2754              : /* m2pp_list prints a TREE_CHAINed list.  */
    2755              : 
    2756              : static void
    2757            0 : m2pp_list (pretty *s, tree t)
    2758              : {
    2759            0 :   tree u = t;
    2760              : 
    2761            0 :   m2pp_print (s, "(");
    2762            0 :   m2pp_needspace (s);
    2763            0 :   while (t != NULL_TREE)
    2764              :     {
    2765            0 :       m2pp_expression (s, TREE_VALUE (t));
    2766            0 :       t = TREE_CHAIN (t);
    2767            0 :       if (t == u || t == NULL_TREE)
    2768              :         break;
    2769            0 :       m2pp_print (s, ",");
    2770            0 :       m2pp_needspace (s);
    2771              :     }
    2772            0 :   m2pp_needspace (s);
    2773            0 :   m2pp_print (s, ")");
    2774            0 : }
    2775              : 
    2776              : /* m2pp_offset displays the offset operator.  */
    2777              : 
    2778              : static void
    2779            0 : m2pp_offset (pretty *s, tree t)
    2780              : {
    2781            0 :   tree type = TREE_TYPE (t);
    2782            0 :   tree base = TYPE_OFFSET_BASETYPE (t);
    2783              : 
    2784            0 :   m2pp_print (s, "OFFSET (");
    2785            0 :   m2pp_type (s, base);
    2786            0 :   m2pp_print (s, ".");
    2787            0 :   m2pp_type (s, type);
    2788            0 :   m2pp_print (s, ")");
    2789            0 : }
    2790              : 
    2791              : /* m2pp_addr_expr create an ADR expression.  */
    2792              : 
    2793              : static void
    2794            0 : m2pp_addr_expr (pretty *s, tree t)
    2795              : {
    2796            0 :   m2pp_needspace (s);
    2797            0 :   m2pp_print (s, "ADR (");
    2798            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2799            0 :   m2pp_print (s, ")");
    2800            0 : }
    2801              : 
    2802              : /* m2pp_nop generate a CAST expression.  */
    2803              : 
    2804              : static void
    2805            0 : m2pp_nop (pretty *s, tree t)
    2806              : {
    2807            0 :   m2pp_needspace (s);
    2808            0 :   m2pp_print (s, "CAST (");
    2809            0 :   m2pp_simple_type (s, TREE_TYPE (t));
    2810            0 :   m2pp_print (s, ", ");
    2811            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2812            0 :   m2pp_print (s, ")");
    2813            0 : }
    2814              : 
    2815              : /* m2pp_convert generate a CONVERT expression.  */
    2816              : 
    2817              : static void
    2818            0 : m2pp_convert (pretty *s, tree t)
    2819              : {
    2820            0 :   m2pp_needspace (s);
    2821            0 :   m2pp_print (s, "CONVERT (");
    2822            0 :   m2pp_simple_type (s, TREE_TYPE (t));
    2823            0 :   m2pp_print (s, ", ");
    2824            0 :   m2pp_expression (s, TREE_OPERAND (t, 0));
    2825            0 :   m2pp_print (s, ")");
    2826            0 : }
    2827              : 
    2828              : /* m2pp_var_decl generate a variable.  */
    2829              : 
    2830              : static void
    2831            0 : m2pp_var_decl (pretty *s, tree t)
    2832              : {
    2833            0 :   m2pp_identifier (s, t);
    2834            0 : }
    2835              : 
    2836              : /* m2pp_result_decl generate a result declaration (variable).  */
    2837              : 
    2838              : static void
    2839            0 : m2pp_result_decl (pretty *s, tree t)
    2840              : {
    2841            0 :   m2pp_identifier (s, t);
    2842            0 : }
    2843              : 
    2844              : /* m2pp_component_ref generate a record field access.  */
    2845              : 
    2846              : static void
    2847            0 : m2pp_component_ref (pretty *s, tree t)
    2848              : {
    2849            0 :   m2pp_simple_expression (s, TREE_OPERAND (t, 0));
    2850            0 :   m2pp_print (s, ".");
    2851            0 :   m2pp_simple_expression (s, TREE_OPERAND (t, 1));
    2852            0 : }
    2853              : 
    2854              : }
    2855              : 
    2856              : /* Code interface to this module.  */
    2857              : 
    2858              : /* CreateDumpGimple creates the dump files using the template name.  */
    2859              : 
    2860              : void
    2861            0 : m2pp_CreateDumpGimple (char *template_name, int template_len)
    2862              : {
    2863            0 :   int kind = M2PP_DUMP_STDOUT;
    2864            0 :   modula2::m2pp_output_file[kind] = stdout;
    2865            0 :   kind++;
    2866            0 :   for (; kind < M2PP_DUMP_END; kind++)
    2867              :     {
    2868            0 :       if (kind == M2PP_DUMP_FD)
    2869            0 :         modula2::m2pp_output_file[kind] = NULL;
    2870              :       else
    2871              :         {
    2872            0 :           char *name = (char *)alloca (template_len);
    2873              : 
    2874            0 :           snprintf (name, template_len, template_name, kind);
    2875            0 :           modula2::m2pp_output_file[kind] = fopen (name, "w");
    2876            0 :           if (modula2::m2pp_output_file[kind] == NULL)
    2877              :             {
    2878            0 :               fprintf (stderr, "unable to create dump file %s: %s\n",
    2879            0 :                        name, xstrerror (errno));
    2880            0 :               exit (1);
    2881              :             }
    2882            0 :           fprintf (modula2::m2pp_output_file[kind], "%s\n\n",
    2883              :                    m2pp_dump_description[kind]);
    2884              :         }
    2885              :     }
    2886            0 : }
    2887              : 
    2888              : /* Close all dump files and fflush stdout.  */
    2889              : 
    2890              : void
    2891            0 : m2pp_CloseDumpGimple (void)
    2892              : {
    2893            0 :   int kind = M2PP_DUMP_STDOUT;
    2894            0 :   fflush (modula2::m2pp_output_file[kind]);
    2895            0 :   kind++;
    2896            0 :   for (; kind < M2PP_DUMP_END; kind++)
    2897            0 :     if (kind != M2PP_DUMP_FD)
    2898            0 :       fclose (modula2::m2pp_output_file[kind]);
    2899            0 : }
    2900              : 
    2901              : /* m2pp_dump_gimple_pretty create an initPretty object and print
    2902              :    fndecl to kind output.  */
    2903              : 
    2904              : void
    2905            0 : m2pp_dump_gimple_pretty (m2pp_dump_kind kind, tree fndecl)
    2906              : {
    2907            0 :   modula2::pretty *state = modula2::initPretty (kind, 0);
    2908              : 
    2909            0 :   modula2::m2pp_print (state, "\n");
    2910            0 :   if (TREE_CODE (fndecl) == TRANSLATION_UNIT_DECL)
    2911            0 :     modula2::m2pp_translation (state, fndecl);
    2912            0 :   else if (TREE_CODE (fndecl) == BLOCK)
    2913            0 :     modula2::m2pp_module_block (state, fndecl);
    2914            0 :   else if (TREE_CODE (fndecl) == FUNCTION_DECL)
    2915            0 :     modula2::m2pp_function (state, fndecl);
    2916              :   else
    2917            0 :     modula2::m2pp_statement_sequence (state, fndecl);
    2918            0 :   modula2::killPretty (state);
    2919            0 : }
    2920              : 
    2921              : 
    2922              : /* Generate modula-2 style gimple for fndecl.  */
    2923              : 
    2924              : void
    2925       211178 : m2pp_dump_gimple (m2pp_dump_kind kind, tree fndecl)
    2926              : {
    2927       211178 :   if (M2Options_GetDumpGimple ()
    2928       211178 :       && M2LangDump_IsDumpRequiredTree (fndecl, true))
    2929            0 :     m2pp_dump_gimple_pretty (kind, fndecl);
    2930       211178 : }
    2931              : 
    2932              : 
    2933              : /* Dump fndecl to a file descriptor.  */
    2934              : 
    2935              : void
    2936            0 : m2pp_DumpGimpleFd (int fd, tree fndecl)
    2937              : {
    2938            0 :   FILE *f = fdopen (fd, "a");
    2939            0 :   if (f != NULL)
    2940              :     {
    2941              : #if 0
    2942              :       modula2::m2pp_output_file[M2PP_DUMP_FD] = f;
    2943              :       m2pp_dump_gimple_pretty (M2PP_DUMP_FD, fndecl);
    2944              :       fprintf (f, "\n");
    2945              : #endif
    2946            0 :       print_node (f, "m2 tree", fndecl, 1);
    2947            0 :       fprintf (f, "\n\n");
    2948            0 :       fflush (f);
    2949              : #if 0
    2950              :       modula2::m2pp_output_file[M2PP_DUMP_FD] = NULL;
    2951              : #endif
    2952              :     }
    2953            0 : }
        

Generated by: LCOV version 2.4-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.