Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / fortran / dump-parse-tree.c
blobef5c88a94b4a7a783f7dcd33050d85ac0e70ca86
1 /* Parse tree dumper
2 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Steven Bosscher
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA. */
23 /* Actually this is just a collection of routines that used to be
24 scattered around the sources. Now that they are all in a single
25 file, almost all of them can be static, and the other files don't
26 have this mess in them.
28 As a nice side-effect, this file can act as documentation of the
29 gfc_code and gfc_expr structures and all their friends and
30 relatives.
32 TODO: Dump DATA. */
34 #include "config.h"
35 #include "gfortran.h"
37 /* Keep track of indentation for symbol tree dumps. */
38 static int show_level = 0;
41 /* Forward declaration because this one needs all, and all need
42 this one. */
43 static void gfc_show_expr (gfc_expr *);
45 /* Do indentation for a specific level. */
47 static inline void
48 code_indent (int level, gfc_st_label * label)
50 int i;
52 if (label != NULL)
53 gfc_status ("%-5d ", label->value);
54 else
55 gfc_status (" ");
57 for (i = 0; i < 2 * level; i++)
58 gfc_status_char (' ');
62 /* Simple indentation at the current level. This one
63 is used to show symbols. */
65 static inline void
66 show_indent (void)
68 gfc_status ("\n");
69 code_indent (show_level, NULL);
73 /* Show type-specific information. */
75 static void
76 gfc_show_typespec (gfc_typespec * ts)
79 gfc_status ("(%s ", gfc_basic_typename (ts->type));
81 switch (ts->type)
83 case BT_DERIVED:
84 gfc_status ("%s", ts->derived->name);
85 break;
87 case BT_CHARACTER:
88 gfc_show_expr (ts->cl->length);
89 break;
91 default:
92 gfc_status ("%d", ts->kind);
93 break;
96 gfc_status (")");
100 /* Show an actual argument list. */
102 static void
103 gfc_show_actual_arglist (gfc_actual_arglist * a)
106 gfc_status ("(");
108 for (; a; a = a->next)
110 gfc_status_char ('(');
111 if (a->name != NULL)
112 gfc_status ("%s = ", a->name);
113 if (a->expr != NULL)
114 gfc_show_expr (a->expr);
115 else
116 gfc_status ("(arg not-present)");
118 gfc_status_char (')');
119 if (a->next != NULL)
120 gfc_status (" ");
123 gfc_status (")");
127 /* Show a gfc_array_spec array specification structure. */
129 static void
130 gfc_show_array_spec (gfc_array_spec * as)
132 const char *c;
133 int i;
135 if (as == NULL)
137 gfc_status ("()");
138 return;
141 gfc_status ("(%d", as->rank);
143 if (as->rank != 0)
145 switch (as->type)
147 case AS_EXPLICIT: c = "AS_EXPLICIT"; break;
148 case AS_DEFERRED: c = "AS_DEFERRED"; break;
149 case AS_ASSUMED_SIZE: c = "AS_ASSUMED_SIZE"; break;
150 case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;
151 default:
152 gfc_internal_error
153 ("gfc_show_array_spec(): Unhandled array shape type.");
155 gfc_status (" %s ", c);
157 for (i = 0; i < as->rank; i++)
159 gfc_show_expr (as->lower[i]);
160 gfc_status_char (' ');
161 gfc_show_expr (as->upper[i]);
162 gfc_status_char (' ');
166 gfc_status (")");
170 /* Show a gfc_array_ref array reference structure. */
172 static void
173 gfc_show_array_ref (gfc_array_ref * ar)
175 int i;
177 gfc_status_char ('(');
179 switch (ar->type)
181 case AR_FULL:
182 gfc_status ("FULL");
183 break;
185 case AR_SECTION:
186 for (i = 0; i < ar->dimen; i++)
188 /* There are two types of array sections: either the
189 elements are identified by an integer array ('vector'),
190 or by an index range. In the former case we only have to
191 print the start expression which contains the vector, in
192 the latter case we have to print any of lower and upper
193 bound and the stride, if they're present. */
195 if (ar->start[i] != NULL)
196 gfc_show_expr (ar->start[i]);
198 if (ar->dimen_type[i] == DIMEN_RANGE)
200 gfc_status_char (':');
202 if (ar->end[i] != NULL)
203 gfc_show_expr (ar->end[i]);
205 if (ar->stride[i] != NULL)
207 gfc_status_char (':');
208 gfc_show_expr (ar->stride[i]);
212 if (i != ar->dimen - 1)
213 gfc_status (" , ");
215 break;
217 case AR_ELEMENT:
218 for (i = 0; i < ar->dimen; i++)
220 gfc_show_expr (ar->start[i]);
221 if (i != ar->dimen - 1)
222 gfc_status (" , ");
224 break;
226 case AR_UNKNOWN:
227 gfc_status ("UNKNOWN");
228 break;
230 default:
231 gfc_internal_error ("gfc_show_array_ref(): Unknown array reference");
234 gfc_status_char (')');
238 /* Show a list of gfc_ref structures. */
240 static void
241 gfc_show_ref (gfc_ref * p)
244 for (; p; p = p->next)
245 switch (p->type)
247 case REF_ARRAY:
248 gfc_show_array_ref (&p->u.ar);
249 break;
251 case REF_COMPONENT:
252 gfc_status (" %% %s", p->u.c.component->name);
253 break;
255 case REF_SUBSTRING:
256 gfc_status_char ('(');
257 gfc_show_expr (p->u.ss.start);
258 gfc_status_char (':');
259 gfc_show_expr (p->u.ss.end);
260 gfc_status_char (')');
261 break;
263 default:
264 gfc_internal_error ("gfc_show_ref(): Bad component code");
269 /* Display a constructor. Works recursively for array constructors. */
271 static void
272 gfc_show_constructor (gfc_constructor * c)
275 for (; c; c = c->next)
277 if (c->iterator == NULL)
278 gfc_show_expr (c->expr);
279 else
281 gfc_status_char ('(');
282 gfc_show_expr (c->expr);
284 gfc_status_char (' ');
285 gfc_show_expr (c->iterator->var);
286 gfc_status_char ('=');
287 gfc_show_expr (c->iterator->start);
288 gfc_status_char (',');
289 gfc_show_expr (c->iterator->end);
290 gfc_status_char (',');
291 gfc_show_expr (c->iterator->step);
293 gfc_status_char (')');
296 if (c->next != NULL)
297 gfc_status (" , ");
302 /* Show an expression. */
304 static void
305 gfc_show_expr (gfc_expr * p)
307 const char *c;
308 int i;
310 if (p == NULL)
312 gfc_status ("()");
313 return;
316 switch (p->expr_type)
318 case EXPR_SUBSTRING:
319 c = p->value.character.string;
321 for (i = 0; i < p->value.character.length; i++, c++)
323 if (*c == '\'')
324 gfc_status ("''");
325 else
326 gfc_status ("%c", *c);
329 gfc_show_ref (p->ref);
330 break;
332 case EXPR_STRUCTURE:
333 gfc_status ("%s(", p->ts.derived->name);
334 gfc_show_constructor (p->value.constructor);
335 gfc_status_char (')');
336 break;
338 case EXPR_ARRAY:
339 gfc_status ("(/ ");
340 gfc_show_constructor (p->value.constructor);
341 gfc_status (" /)");
343 gfc_show_ref (p->ref);
344 break;
346 case EXPR_NULL:
347 gfc_status ("NULL()");
348 break;
350 case EXPR_CONSTANT:
351 switch (p->ts.type)
353 case BT_INTEGER:
354 mpz_out_str (stdout, 10, p->value.integer);
356 if (p->ts.kind != gfc_default_integer_kind)
357 gfc_status ("_%d", p->ts.kind);
358 break;
360 case BT_LOGICAL:
361 if (p->value.logical)
362 gfc_status (".true.");
363 else
364 gfc_status (".false.");
365 break;
367 case BT_REAL:
368 mpfr_out_str (stdout, 10, 0, p->value.real, GFC_RND_MODE);
369 if (p->ts.kind != gfc_default_real_kind)
370 gfc_status ("_%d", p->ts.kind);
371 break;
373 case BT_CHARACTER:
374 c = p->value.character.string;
376 gfc_status_char ('\'');
378 for (i = 0; i < p->value.character.length; i++, c++)
380 if (*c == '\'')
381 gfc_status ("''");
382 else
383 gfc_status_char (*c);
386 gfc_status_char ('\'');
388 break;
390 case BT_COMPLEX:
391 gfc_status ("(complex ");
393 mpfr_out_str (stdout, 10, 0, p->value.complex.r, GFC_RND_MODE);
394 if (p->ts.kind != gfc_default_complex_kind)
395 gfc_status ("_%d", p->ts.kind);
397 gfc_status (" ");
399 mpfr_out_str (stdout, 10, 0, p->value.complex.i, GFC_RND_MODE);
400 if (p->ts.kind != gfc_default_complex_kind)
401 gfc_status ("_%d", p->ts.kind);
403 gfc_status (")");
404 break;
406 default:
407 gfc_status ("???");
408 break;
411 break;
413 case EXPR_VARIABLE:
414 if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)
415 gfc_status ("%s:", p->symtree->n.sym->ns->proc_name->name);
416 gfc_status ("%s", p->symtree->n.sym->name);
417 gfc_show_ref (p->ref);
418 break;
420 case EXPR_OP:
421 gfc_status ("(");
422 switch (p->value.op.operator)
424 case INTRINSIC_UPLUS:
425 gfc_status ("U+ ");
426 break;
427 case INTRINSIC_UMINUS:
428 gfc_status ("U- ");
429 break;
430 case INTRINSIC_PLUS:
431 gfc_status ("+ ");
432 break;
433 case INTRINSIC_MINUS:
434 gfc_status ("- ");
435 break;
436 case INTRINSIC_TIMES:
437 gfc_status ("* ");
438 break;
439 case INTRINSIC_DIVIDE:
440 gfc_status ("/ ");
441 break;
442 case INTRINSIC_POWER:
443 gfc_status ("** ");
444 break;
445 case INTRINSIC_CONCAT:
446 gfc_status ("// ");
447 break;
448 case INTRINSIC_AND:
449 gfc_status ("AND ");
450 break;
451 case INTRINSIC_OR:
452 gfc_status ("OR ");
453 break;
454 case INTRINSIC_EQV:
455 gfc_status ("EQV ");
456 break;
457 case INTRINSIC_NEQV:
458 gfc_status ("NEQV ");
459 break;
460 case INTRINSIC_EQ:
461 gfc_status ("= ");
462 break;
463 case INTRINSIC_NE:
464 gfc_status ("<> ");
465 break;
466 case INTRINSIC_GT:
467 gfc_status ("> ");
468 break;
469 case INTRINSIC_GE:
470 gfc_status (">= ");
471 break;
472 case INTRINSIC_LT:
473 gfc_status ("< ");
474 break;
475 case INTRINSIC_LE:
476 gfc_status ("<= ");
477 break;
478 case INTRINSIC_NOT:
479 gfc_status ("NOT ");
480 break;
482 default:
483 gfc_internal_error
484 ("gfc_show_expr(): Bad intrinsic in expression!");
487 gfc_show_expr (p->value.op.op1);
489 if (p->value.op.op2)
491 gfc_status (" ");
492 gfc_show_expr (p->value.op.op2);
495 gfc_status (")");
496 break;
498 case EXPR_FUNCTION:
499 if (p->value.function.name == NULL)
501 gfc_status ("%s[", p->symtree->n.sym->name);
502 gfc_show_actual_arglist (p->value.function.actual);
503 gfc_status_char (']');
505 else
507 gfc_status ("%s[[", p->value.function.name);
508 gfc_show_actual_arglist (p->value.function.actual);
509 gfc_status_char (']');
510 gfc_status_char (']');
513 break;
515 default:
516 gfc_internal_error ("gfc_show_expr(): Don't know how to show expr");
521 /* Show symbol attributes. The flavor and intent are followed by
522 whatever single bit attributes are present. */
524 static void
525 gfc_show_attr (symbol_attribute * attr)
528 gfc_status ("(%s %s %s %s", gfc_code2string (flavors, attr->flavor),
529 gfc_intent_string (attr->intent),
530 gfc_code2string (access_types, attr->access),
531 gfc_code2string (procedures, attr->proc));
533 if (attr->allocatable)
534 gfc_status (" ALLOCATABLE");
535 if (attr->dimension)
536 gfc_status (" DIMENSION");
537 if (attr->external)
538 gfc_status (" EXTERNAL");
539 if (attr->intrinsic)
540 gfc_status (" INTRINSIC");
541 if (attr->optional)
542 gfc_status (" OPTIONAL");
543 if (attr->pointer)
544 gfc_status (" POINTER");
545 if (attr->save)
546 gfc_status (" SAVE");
547 if (attr->target)
548 gfc_status (" TARGET");
549 if (attr->dummy)
550 gfc_status (" DUMMY");
551 if (attr->result)
552 gfc_status (" RESULT");
553 if (attr->entry)
554 gfc_status (" ENTRY");
556 if (attr->data)
557 gfc_status (" DATA");
558 if (attr->use_assoc)
559 gfc_status (" USE-ASSOC");
560 if (attr->in_namelist)
561 gfc_status (" IN-NAMELIST");
562 if (attr->in_common)
563 gfc_status (" IN-COMMON");
565 if (attr->function)
566 gfc_status (" FUNCTION");
567 if (attr->subroutine)
568 gfc_status (" SUBROUTINE");
569 if (attr->implicit_type)
570 gfc_status (" IMPLICIT-TYPE");
572 if (attr->sequence)
573 gfc_status (" SEQUENCE");
574 if (attr->elemental)
575 gfc_status (" ELEMENTAL");
576 if (attr->pure)
577 gfc_status (" PURE");
578 if (attr->recursive)
579 gfc_status (" RECURSIVE");
581 gfc_status (")");
585 /* Show components of a derived type. */
587 static void
588 gfc_show_components (gfc_symbol * sym)
590 gfc_component *c;
592 for (c = sym->components; c; c = c->next)
594 gfc_status ("(%s ", c->name);
595 gfc_show_typespec (&c->ts);
596 if (c->pointer)
597 gfc_status (" POINTER");
598 if (c->dimension)
599 gfc_status (" DIMENSION");
600 gfc_status_char (' ');
601 gfc_show_array_spec (c->as);
602 gfc_status (")");
603 if (c->next != NULL)
604 gfc_status_char (' ');
609 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
610 show the interface. Information needed to reconstruct the list of
611 specific interfaces associated with a generic symbol is done within
612 that symbol. */
614 static void
615 gfc_show_symbol (gfc_symbol * sym)
617 gfc_formal_arglist *formal;
618 gfc_interface *intr;
620 if (sym == NULL)
621 return;
623 show_indent ();
625 gfc_status ("symbol %s ", sym->name);
626 gfc_show_typespec (&sym->ts);
627 gfc_show_attr (&sym->attr);
629 if (sym->value)
631 show_indent ();
632 gfc_status ("value: ");
633 gfc_show_expr (sym->value);
636 if (sym->as)
638 show_indent ();
639 gfc_status ("Array spec:");
640 gfc_show_array_spec (sym->as);
643 if (sym->generic)
645 show_indent ();
646 gfc_status ("Generic interfaces:");
647 for (intr = sym->generic; intr; intr = intr->next)
648 gfc_status (" %s", intr->sym->name);
651 if (sym->result)
653 show_indent ();
654 gfc_status ("result: %s", sym->result->name);
657 if (sym->components)
659 show_indent ();
660 gfc_status ("components: ");
661 gfc_show_components (sym);
664 if (sym->formal)
666 show_indent ();
667 gfc_status ("Formal arglist:");
669 for (formal = sym->formal; formal; formal = formal->next)
671 if (formal->sym != NULL)
672 gfc_status (" %s", formal->sym->name);
673 else
674 gfc_status (" [Alt Return]");
678 if (sym->formal_ns)
680 show_indent ();
681 gfc_status ("Formal namespace");
682 gfc_show_namespace (sym->formal_ns);
685 gfc_status_char ('\n');
689 /* Show a user-defined operator. Just prints an operator
690 and the name of the associated subroutine, really. */
692 static void
693 show_uop (gfc_user_op * uop)
695 gfc_interface *intr;
697 show_indent ();
698 gfc_status ("%s:", uop->name);
700 for (intr = uop->operator; intr; intr = intr->next)
701 gfc_status (" %s", intr->sym->name);
705 /* Workhorse function for traversing the user operator symtree. */
707 static void
708 traverse_uop (gfc_symtree * st, void (*func) (gfc_user_op *))
711 if (st == NULL)
712 return;
714 (*func) (st->n.uop);
716 traverse_uop (st->left, func);
717 traverse_uop (st->right, func);
721 /* Traverse the tree of user operator nodes. */
723 void
724 gfc_traverse_user_op (gfc_namespace * ns, void (*func) (gfc_user_op *))
727 traverse_uop (ns->uop_root, func);
731 /* Function to display a common block. */
733 static void
734 show_common (gfc_symtree * st)
736 gfc_symbol *s;
738 show_indent ();
739 gfc_status ("common: /%s/ ", st->name);
741 s = st->n.common->head;
742 while (s)
744 gfc_status ("%s", s->name);
745 s = s->common_next;
746 if (s)
747 gfc_status (", ");
749 gfc_status_char ('\n');
753 /* Worker function to display the symbol tree. */
755 static void
756 show_symtree (gfc_symtree * st)
759 show_indent ();
760 gfc_status ("symtree: %s Ambig %d", st->name, st->ambiguous);
762 if (st->n.sym->ns != gfc_current_ns)
763 gfc_status (" from namespace %s", st->n.sym->ns->proc_name->name);
764 else
765 gfc_show_symbol (st->n.sym);
769 /******************* Show gfc_code structures **************/
773 static void gfc_show_code_node (int level, gfc_code * c);
775 /* Show a list of code structures. Mutually recursive with
776 gfc_show_code_node(). */
778 static void
779 gfc_show_code (int level, gfc_code * c)
782 for (; c; c = c->next)
783 gfc_show_code_node (level, c);
787 /* Show a single code node and everything underneath it if necessary. */
789 static void
790 gfc_show_code_node (int level, gfc_code * c)
792 gfc_forall_iterator *fa;
793 gfc_open *open;
794 gfc_case *cp;
795 gfc_alloc *a;
796 gfc_code *d;
797 gfc_close *close;
798 gfc_filepos *fp;
799 gfc_inquire *i;
800 gfc_dt *dt;
802 code_indent (level, c->here);
804 switch (c->op)
806 case EXEC_NOP:
807 gfc_status ("NOP");
808 break;
810 case EXEC_CONTINUE:
811 gfc_status ("CONTINUE");
812 break;
814 case EXEC_ENTRY:
815 gfc_status ("ENTRY %s", c->ext.entry->sym->name);
816 break;
818 case EXEC_ASSIGN:
819 gfc_status ("ASSIGN ");
820 gfc_show_expr (c->expr);
821 gfc_status_char (' ');
822 gfc_show_expr (c->expr2);
823 break;
825 case EXEC_LABEL_ASSIGN:
826 gfc_status ("LABEL ASSIGN ");
827 gfc_show_expr (c->expr);
828 gfc_status (" %d", c->label->value);
829 break;
831 case EXEC_POINTER_ASSIGN:
832 gfc_status ("POINTER ASSIGN ");
833 gfc_show_expr (c->expr);
834 gfc_status_char (' ');
835 gfc_show_expr (c->expr2);
836 break;
838 case EXEC_GOTO:
839 gfc_status ("GOTO ");
840 if (c->label)
841 gfc_status ("%d", c->label->value);
842 else
844 gfc_show_expr (c->expr);
845 d = c->block;
846 if (d != NULL)
848 gfc_status (", (");
849 for (; d; d = d ->block)
851 code_indent (level, d->label);
852 if (d->block != NULL)
853 gfc_status_char (',');
854 else
855 gfc_status_char (')');
859 break;
861 case EXEC_CALL:
862 gfc_status ("CALL %s ", c->resolved_sym->name);
863 gfc_show_actual_arglist (c->ext.actual);
864 break;
866 case EXEC_RETURN:
867 gfc_status ("RETURN ");
868 if (c->expr)
869 gfc_show_expr (c->expr);
870 break;
872 case EXEC_PAUSE:
873 gfc_status ("PAUSE ");
875 if (c->expr != NULL)
876 gfc_show_expr (c->expr);
877 else
878 gfc_status ("%d", c->ext.stop_code);
880 break;
882 case EXEC_STOP:
883 gfc_status ("STOP ");
885 if (c->expr != NULL)
886 gfc_show_expr (c->expr);
887 else
888 gfc_status ("%d", c->ext.stop_code);
890 break;
892 case EXEC_ARITHMETIC_IF:
893 gfc_status ("IF ");
894 gfc_show_expr (c->expr);
895 gfc_status (" %d, %d, %d",
896 c->label->value, c->label2->value, c->label3->value);
897 break;
899 case EXEC_IF:
900 d = c->block;
901 gfc_status ("IF ");
902 gfc_show_expr (d->expr);
903 gfc_status_char ('\n');
904 gfc_show_code (level + 1, d->next);
906 d = d->block;
907 for (; d; d = d->block)
909 code_indent (level, 0);
911 if (d->expr == NULL)
912 gfc_status ("ELSE\n");
913 else
915 gfc_status ("ELSE IF ");
916 gfc_show_expr (d->expr);
917 gfc_status_char ('\n');
920 gfc_show_code (level + 1, d->next);
923 code_indent (level, c->label);
925 gfc_status ("ENDIF");
926 break;
928 case EXEC_SELECT:
929 d = c->block;
930 gfc_status ("SELECT CASE ");
931 gfc_show_expr (c->expr);
932 gfc_status_char ('\n');
934 for (; d; d = d->block)
936 code_indent (level, 0);
938 gfc_status ("CASE ");
939 for (cp = d->ext.case_list; cp; cp = cp->next)
941 gfc_status_char ('(');
942 gfc_show_expr (cp->low);
943 gfc_status_char (' ');
944 gfc_show_expr (cp->high);
945 gfc_status_char (')');
946 gfc_status_char (' ');
948 gfc_status_char ('\n');
950 gfc_show_code (level + 1, d->next);
953 code_indent (level, c->label);
954 gfc_status ("END SELECT");
955 break;
957 case EXEC_WHERE:
958 gfc_status ("WHERE ");
960 d = c->block;
961 gfc_show_expr (d->expr);
962 gfc_status_char ('\n');
964 gfc_show_code (level + 1, d->next);
966 for (d = d->block; d; d = d->block)
968 code_indent (level, 0);
969 gfc_status ("ELSE WHERE ");
970 gfc_show_expr (d->expr);
971 gfc_status_char ('\n');
972 gfc_show_code (level + 1, d->next);
975 code_indent (level, 0);
976 gfc_status ("END WHERE");
977 break;
980 case EXEC_FORALL:
981 gfc_status ("FORALL ");
982 for (fa = c->ext.forall_iterator; fa; fa = fa->next)
984 gfc_show_expr (fa->var);
985 gfc_status_char (' ');
986 gfc_show_expr (fa->start);
987 gfc_status_char (':');
988 gfc_show_expr (fa->end);
989 gfc_status_char (':');
990 gfc_show_expr (fa->stride);
992 if (fa->next != NULL)
993 gfc_status_char (',');
996 if (c->expr != NULL)
998 gfc_status_char (',');
999 gfc_show_expr (c->expr);
1001 gfc_status_char ('\n');
1003 gfc_show_code (level + 1, c->block->next);
1005 code_indent (level, 0);
1006 gfc_status ("END FORALL");
1007 break;
1009 case EXEC_DO:
1010 gfc_status ("DO ");
1012 gfc_show_expr (c->ext.iterator->var);
1013 gfc_status_char ('=');
1014 gfc_show_expr (c->ext.iterator->start);
1015 gfc_status_char (' ');
1016 gfc_show_expr (c->ext.iterator->end);
1017 gfc_status_char (' ');
1018 gfc_show_expr (c->ext.iterator->step);
1019 gfc_status_char ('\n');
1021 gfc_show_code (level + 1, c->block->next);
1023 code_indent (level, 0);
1024 gfc_status ("END DO");
1025 break;
1027 case EXEC_DO_WHILE:
1028 gfc_status ("DO WHILE ");
1029 gfc_show_expr (c->expr);
1030 gfc_status_char ('\n');
1032 gfc_show_code (level + 1, c->block->next);
1034 code_indent (level, c->label);
1035 gfc_status ("END DO");
1036 break;
1038 case EXEC_CYCLE:
1039 gfc_status ("CYCLE");
1040 if (c->symtree)
1041 gfc_status (" %s", c->symtree->n.sym->name);
1042 break;
1044 case EXEC_EXIT:
1045 gfc_status ("EXIT");
1046 if (c->symtree)
1047 gfc_status (" %s", c->symtree->n.sym->name);
1048 break;
1050 case EXEC_ALLOCATE:
1051 gfc_status ("ALLOCATE ");
1052 if (c->expr)
1054 gfc_status (" STAT=");
1055 gfc_show_expr (c->expr);
1058 for (a = c->ext.alloc_list; a; a = a->next)
1060 gfc_status_char (' ');
1061 gfc_show_expr (a->expr);
1064 break;
1066 case EXEC_DEALLOCATE:
1067 gfc_status ("DEALLOCATE ");
1068 if (c->expr)
1070 gfc_status (" STAT=");
1071 gfc_show_expr (c->expr);
1074 for (a = c->ext.alloc_list; a; a = a->next)
1076 gfc_status_char (' ');
1077 gfc_show_expr (a->expr);
1080 break;
1082 case EXEC_OPEN:
1083 gfc_status ("OPEN");
1084 open = c->ext.open;
1086 if (open->unit)
1088 gfc_status (" UNIT=");
1089 gfc_show_expr (open->unit);
1091 if (open->iomsg)
1093 gfc_status (" IOMSG=");
1094 gfc_show_expr (open->iomsg);
1096 if (open->iostat)
1098 gfc_status (" IOSTAT=");
1099 gfc_show_expr (open->iostat);
1101 if (open->file)
1103 gfc_status (" FILE=");
1104 gfc_show_expr (open->file);
1106 if (open->status)
1108 gfc_status (" STATUS=");
1109 gfc_show_expr (open->status);
1111 if (open->access)
1113 gfc_status (" ACCESS=");
1114 gfc_show_expr (open->access);
1116 if (open->form)
1118 gfc_status (" FORM=");
1119 gfc_show_expr (open->form);
1121 if (open->recl)
1123 gfc_status (" RECL=");
1124 gfc_show_expr (open->recl);
1126 if (open->blank)
1128 gfc_status (" BLANK=");
1129 gfc_show_expr (open->blank);
1131 if (open->position)
1133 gfc_status (" POSITION=");
1134 gfc_show_expr (open->position);
1136 if (open->action)
1138 gfc_status (" ACTION=");
1139 gfc_show_expr (open->action);
1141 if (open->delim)
1143 gfc_status (" DELIM=");
1144 gfc_show_expr (open->delim);
1146 if (open->pad)
1148 gfc_status (" PAD=");
1149 gfc_show_expr (open->pad);
1151 if (open->convert)
1153 gfc_status (" CONVERT=");
1154 gfc_show_expr (open->convert);
1156 if (open->err != NULL)
1157 gfc_status (" ERR=%d", open->err->value);
1159 break;
1161 case EXEC_CLOSE:
1162 gfc_status ("CLOSE");
1163 close = c->ext.close;
1165 if (close->unit)
1167 gfc_status (" UNIT=");
1168 gfc_show_expr (close->unit);
1170 if (close->iomsg)
1172 gfc_status (" IOMSG=");
1173 gfc_show_expr (close->iomsg);
1175 if (close->iostat)
1177 gfc_status (" IOSTAT=");
1178 gfc_show_expr (close->iostat);
1180 if (close->status)
1182 gfc_status (" STATUS=");
1183 gfc_show_expr (close->status);
1185 if (close->err != NULL)
1186 gfc_status (" ERR=%d", close->err->value);
1187 break;
1189 case EXEC_BACKSPACE:
1190 gfc_status ("BACKSPACE");
1191 goto show_filepos;
1193 case EXEC_ENDFILE:
1194 gfc_status ("ENDFILE");
1195 goto show_filepos;
1197 case EXEC_REWIND:
1198 gfc_status ("REWIND");
1199 goto show_filepos;
1201 case EXEC_FLUSH:
1202 gfc_status ("FLUSH");
1204 show_filepos:
1205 fp = c->ext.filepos;
1207 if (fp->unit)
1209 gfc_status (" UNIT=");
1210 gfc_show_expr (fp->unit);
1212 if (fp->iomsg)
1214 gfc_status (" IOMSG=");
1215 gfc_show_expr (fp->iomsg);
1217 if (fp->iostat)
1219 gfc_status (" IOSTAT=");
1220 gfc_show_expr (fp->iostat);
1222 if (fp->err != NULL)
1223 gfc_status (" ERR=%d", fp->err->value);
1224 break;
1226 case EXEC_INQUIRE:
1227 gfc_status ("INQUIRE");
1228 i = c->ext.inquire;
1230 if (i->unit)
1232 gfc_status (" UNIT=");
1233 gfc_show_expr (i->unit);
1235 if (i->file)
1237 gfc_status (" FILE=");
1238 gfc_show_expr (i->file);
1241 if (i->iomsg)
1243 gfc_status (" IOMSG=");
1244 gfc_show_expr (i->iomsg);
1246 if (i->iostat)
1248 gfc_status (" IOSTAT=");
1249 gfc_show_expr (i->iostat);
1251 if (i->exist)
1253 gfc_status (" EXIST=");
1254 gfc_show_expr (i->exist);
1256 if (i->opened)
1258 gfc_status (" OPENED=");
1259 gfc_show_expr (i->opened);
1261 if (i->number)
1263 gfc_status (" NUMBER=");
1264 gfc_show_expr (i->number);
1266 if (i->named)
1268 gfc_status (" NAMED=");
1269 gfc_show_expr (i->named);
1271 if (i->name)
1273 gfc_status (" NAME=");
1274 gfc_show_expr (i->name);
1276 if (i->access)
1278 gfc_status (" ACCESS=");
1279 gfc_show_expr (i->access);
1281 if (i->sequential)
1283 gfc_status (" SEQUENTIAL=");
1284 gfc_show_expr (i->sequential);
1287 if (i->direct)
1289 gfc_status (" DIRECT=");
1290 gfc_show_expr (i->direct);
1292 if (i->form)
1294 gfc_status (" FORM=");
1295 gfc_show_expr (i->form);
1297 if (i->formatted)
1299 gfc_status (" FORMATTED");
1300 gfc_show_expr (i->formatted);
1302 if (i->unformatted)
1304 gfc_status (" UNFORMATTED=");
1305 gfc_show_expr (i->unformatted);
1307 if (i->recl)
1309 gfc_status (" RECL=");
1310 gfc_show_expr (i->recl);
1312 if (i->nextrec)
1314 gfc_status (" NEXTREC=");
1315 gfc_show_expr (i->nextrec);
1317 if (i->blank)
1319 gfc_status (" BLANK=");
1320 gfc_show_expr (i->blank);
1322 if (i->position)
1324 gfc_status (" POSITION=");
1325 gfc_show_expr (i->position);
1327 if (i->action)
1329 gfc_status (" ACTION=");
1330 gfc_show_expr (i->action);
1332 if (i->read)
1334 gfc_status (" READ=");
1335 gfc_show_expr (i->read);
1337 if (i->write)
1339 gfc_status (" WRITE=");
1340 gfc_show_expr (i->write);
1342 if (i->readwrite)
1344 gfc_status (" READWRITE=");
1345 gfc_show_expr (i->readwrite);
1347 if (i->delim)
1349 gfc_status (" DELIM=");
1350 gfc_show_expr (i->delim);
1352 if (i->pad)
1354 gfc_status (" PAD=");
1355 gfc_show_expr (i->pad);
1357 if (i->convert)
1359 gfc_status (" CONVERT=");
1360 gfc_show_expr (i->convert);
1363 if (i->err != NULL)
1364 gfc_status (" ERR=%d", i->err->value);
1365 break;
1367 case EXEC_IOLENGTH:
1368 gfc_status ("IOLENGTH ");
1369 gfc_show_expr (c->expr);
1370 goto show_dt_code;
1371 break;
1373 case EXEC_READ:
1374 gfc_status ("READ");
1375 goto show_dt;
1377 case EXEC_WRITE:
1378 gfc_status ("WRITE");
1380 show_dt:
1381 dt = c->ext.dt;
1382 if (dt->io_unit)
1384 gfc_status (" UNIT=");
1385 gfc_show_expr (dt->io_unit);
1388 if (dt->format_expr)
1390 gfc_status (" FMT=");
1391 gfc_show_expr (dt->format_expr);
1394 if (dt->format_label != NULL)
1395 gfc_status (" FMT=%d", dt->format_label->value);
1396 if (dt->namelist)
1397 gfc_status (" NML=%s", dt->namelist->name);
1399 if (dt->iomsg)
1401 gfc_status (" IOMSG=");
1402 gfc_show_expr (dt->iomsg);
1404 if (dt->iostat)
1406 gfc_status (" IOSTAT=");
1407 gfc_show_expr (dt->iostat);
1409 if (dt->size)
1411 gfc_status (" SIZE=");
1412 gfc_show_expr (dt->size);
1414 if (dt->rec)
1416 gfc_status (" REC=");
1417 gfc_show_expr (dt->rec);
1419 if (dt->advance)
1421 gfc_status (" ADVANCE=");
1422 gfc_show_expr (dt->advance);
1425 show_dt_code:
1426 gfc_status_char ('\n');
1427 for (c = c->block->next; c; c = c->next)
1428 gfc_show_code_node (level + (c->next != NULL), c);
1429 return;
1431 case EXEC_TRANSFER:
1432 gfc_status ("TRANSFER ");
1433 gfc_show_expr (c->expr);
1434 break;
1436 case EXEC_DT_END:
1437 gfc_status ("DT_END");
1438 dt = c->ext.dt;
1440 if (dt->err != NULL)
1441 gfc_status (" ERR=%d", dt->err->value);
1442 if (dt->end != NULL)
1443 gfc_status (" END=%d", dt->end->value);
1444 if (dt->eor != NULL)
1445 gfc_status (" EOR=%d", dt->eor->value);
1446 break;
1448 default:
1449 gfc_internal_error ("gfc_show_code_node(): Bad statement code");
1452 gfc_status_char ('\n');
1456 /* Show an equivalence chain. */
1458 static void
1459 gfc_show_equiv (gfc_equiv *eq)
1461 show_indent ();
1462 gfc_status ("Equivalence: ");
1463 while (eq)
1465 gfc_show_expr (eq->expr);
1466 eq = eq->eq;
1467 if (eq)
1468 gfc_status (", ");
1473 /* Show a freakin' whole namespace. */
1475 void
1476 gfc_show_namespace (gfc_namespace * ns)
1478 gfc_interface *intr;
1479 gfc_namespace *save;
1480 gfc_intrinsic_op op;
1481 gfc_equiv *eq;
1482 int i;
1484 save = gfc_current_ns;
1485 show_level++;
1487 show_indent ();
1488 gfc_status ("Namespace:");
1490 if (ns != NULL)
1492 i = 0;
1495 int l = i;
1496 while (i < GFC_LETTERS - 1
1497 && gfc_compare_types(&ns->default_type[i+1],
1498 &ns->default_type[l]))
1499 i++;
1501 if (i > l)
1502 gfc_status(" %c-%c: ", l+'A', i+'A');
1503 else
1504 gfc_status(" %c: ", l+'A');
1506 gfc_show_typespec(&ns->default_type[l]);
1507 i++;
1508 } while (i < GFC_LETTERS);
1510 if (ns->proc_name != NULL)
1512 show_indent ();
1513 gfc_status ("procedure name = %s", ns->proc_name->name);
1516 gfc_current_ns = ns;
1517 gfc_traverse_symtree (ns->common_root, show_common);
1519 gfc_traverse_symtree (ns->sym_root, show_symtree);
1521 for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
1523 /* User operator interfaces */
1524 intr = ns->operator[op];
1525 if (intr == NULL)
1526 continue;
1528 show_indent ();
1529 gfc_status ("Operator interfaces for %s:", gfc_op2string (op));
1531 for (; intr; intr = intr->next)
1532 gfc_status (" %s", intr->sym->name);
1535 if (ns->uop_root != NULL)
1537 show_indent ();
1538 gfc_status ("User operators:\n");
1539 gfc_traverse_user_op (ns, show_uop);
1543 for (eq = ns->equiv; eq; eq = eq->next)
1544 gfc_show_equiv (eq);
1546 gfc_status_char ('\n');
1547 gfc_status_char ('\n');
1549 gfc_show_code (0, ns->code);
1551 for (ns = ns->contained; ns; ns = ns->sibling)
1553 show_indent ();
1554 gfc_status ("CONTAINS\n");
1555 gfc_show_namespace (ns);
1558 show_level--;
1559 gfc_status_char ('\n');
1560 gfc_current_ns = save;