Commit 8cf8ca52 by Thomas Koenig

dump-parse-tree.c (code_indent): Take label into acount when calculating indent.

2010-11-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
	    Paul Thomas  <pault@gcc.gnu.org>

	* dump-parse-tree.c (code_indent):  Take label into acount
	when calculating indent.
	(show_typespec):  Also display class.
	(show_attr):  Add module name to argument.
	Don't show UNKNOWN for flavor, access and save. Don't show
	SAVE_NONE.  Don't show INTENT_UNKNOWN.  Show module for use
	association.  Show intent only for dummy arguments.
	Set length of shown symbol names to minimum of 12.
	Show attributes header.
	(show_symbol):  Adjust show_level.
	(show_symtree):  Clear up display for ambiguous.  Show if symbol
	was imported from namespace.
	(show_code_node):  Clear up indenting.  Traverse symtree and
	show code directly instead of calling show_namespace.


Co-Authored-By: Paul Thomas <pault@gcc.gnu.org>

From-SVN: r166262
parent dd60dacd
2010-11-03 Thomas Koenig <tkoenig@gcc.gnu.org>
Paul Thomas <pault@gcc.gnu.org>
* dump-parse-tree.c (code_indent): Take label into acount
when calculating indent.
(show_typespec): Also display class.
(show_attr): Add module name to argument.
Don't show UNKNOWN for flavor, access and save. Don't show
SAVE_NONE. Don't show INTENT_UNKNOWN. Show module for use
association. Show intent only for dummy arguments.
Set length of shown symbol names to minimum of 12.
Show attributes header.
(show_symbol): Adjust show_level.
(show_symtree): Clear up display for ambiguous. Show if symbol
was imported from namespace.
(show_code_node): Clear up indenting. Traverse symtree and
show code directly instead of calling show_namespace.
2010-11-02 Nathan Froyd <froydnj@codesourcery.com> 2010-11-02 Nathan Froyd <froydnj@codesourcery.com>
* trans-decl.c (add_argument_checking): Use build_zero_cst instead of * trans-decl.c (add_argument_checking): Use build_zero_cst instead of
......
...@@ -72,10 +72,8 @@ code_indent (int level, gfc_st_label *label) ...@@ -72,10 +72,8 @@ code_indent (int level, gfc_st_label *label)
if (label != NULL) if (label != NULL)
fprintf (dumpfile, "%-5d ", label->value); fprintf (dumpfile, "%-5d ", label->value);
else
fputs (" ", dumpfile);
for (i = 0; i < 2 * level; i++) for (i = 0; i < (2 * level - (label ? 6 : 0)); i++)
fputc (' ', dumpfile); fputc (' ', dumpfile);
} }
...@@ -101,6 +99,7 @@ show_typespec (gfc_typespec *ts) ...@@ -101,6 +99,7 @@ show_typespec (gfc_typespec *ts)
switch (ts->type) switch (ts->type)
{ {
case BT_DERIVED: case BT_DERIVED:
case BT_CLASS:
fprintf (dumpfile, "%s", ts->u.derived->name); fprintf (dumpfile, "%s", ts->u.derived->name);
break; break;
...@@ -594,15 +593,16 @@ show_expr (gfc_expr *p) ...@@ -594,15 +593,16 @@ show_expr (gfc_expr *p)
whatever single bit attributes are present. */ whatever single bit attributes are present. */
static void static void
show_attr (symbol_attribute *attr) show_attr (symbol_attribute *attr, const char * module)
{ {
if (attr->flavor != FL_UNKNOWN)
fprintf (dumpfile, "(%s %s %s %s %s", fprintf (dumpfile, "(%s ", gfc_code2string (flavors, attr->flavor));
gfc_code2string (flavors, attr->flavor), if (attr->access != ACCESS_UNKNOWN)
gfc_intent_string (attr->intent), fprintf (dumpfile, "%s ", gfc_code2string (access_types, attr->access));
gfc_code2string (access_types, attr->access), if (attr->proc != PROC_UNKNOWN)
gfc_code2string (procedures, attr->proc), fprintf (dumpfile, "%s ", gfc_code2string (procedures, attr->proc));
gfc_code2string (save_status, attr->save)); if (attr->save != SAVE_NONE)
fprintf (dumpfile, "%s", gfc_code2string (save_status, attr->save));
if (attr->allocatable) if (attr->allocatable)
fputs (" ALLOCATABLE", dumpfile); fputs (" ALLOCATABLE", dumpfile);
...@@ -633,7 +633,12 @@ show_attr (symbol_attribute *attr) ...@@ -633,7 +633,12 @@ show_attr (symbol_attribute *attr)
if (attr->target) if (attr->target)
fputs (" TARGET", dumpfile); fputs (" TARGET", dumpfile);
if (attr->dummy) if (attr->dummy)
{
fputs (" DUMMY", dumpfile); fputs (" DUMMY", dumpfile);
if (attr->intent != INTENT_UNKNOWN)
fprintf (dumpfile, "(%s)", gfc_intent_string (attr->intent));
}
if (attr->result) if (attr->result)
fputs (" RESULT", dumpfile); fputs (" RESULT", dumpfile);
if (attr->entry) if (attr->entry)
...@@ -644,7 +649,12 @@ show_attr (symbol_attribute *attr) ...@@ -644,7 +649,12 @@ show_attr (symbol_attribute *attr)
if (attr->data) if (attr->data)
fputs (" DATA", dumpfile); fputs (" DATA", dumpfile);
if (attr->use_assoc) if (attr->use_assoc)
{
fputs (" USE-ASSOC", dumpfile); fputs (" USE-ASSOC", dumpfile);
if (module != NULL)
fprintf (dumpfile, "(%s)", module);
}
if (attr->in_namelist) if (attr->in_namelist)
fputs (" IN-NAMELIST", dumpfile); fputs (" IN-NAMELIST", dumpfile);
if (attr->in_common) if (attr->in_common)
...@@ -802,24 +812,25 @@ show_symbol (gfc_symbol *sym) ...@@ -802,24 +812,25 @@ show_symbol (gfc_symbol *sym)
{ {
gfc_formal_arglist *formal; gfc_formal_arglist *formal;
gfc_interface *intr; gfc_interface *intr;
int i,len;
if (sym == NULL) if (sym == NULL)
return; return;
show_indent (); fprintf (dumpfile, "|| symbol: '%s' ", sym->name);
len = strlen (sym->name);
for (i=len; i<12; i++)
fputc(' ', dumpfile);
fprintf (dumpfile, "symbol %s ", sym->name); ++show_level;
show_typespec (&sym->ts);
/* If this symbol is an associate-name, show its target expression. */ show_indent ();
if (sym->assoc) fputs ("type spec : ", dumpfile);
{ show_typespec (&sym->ts);
fputs (" => ", dumpfile);
show_expr (sym->assoc->target);
fputs (" ", dumpfile);
}
show_attr (&sym->attr); show_indent ();
fputs ("attributes: ", dumpfile);
show_attr (&sym->attr, sym->module);
if (sym->value) if (sym->value)
{ {
...@@ -884,8 +895,7 @@ show_symbol (gfc_symbol *sym) ...@@ -884,8 +895,7 @@ show_symbol (gfc_symbol *sym)
fputs ("Formal namespace", dumpfile); fputs ("Formal namespace", dumpfile);
show_namespace (sym->formal_ns); show_namespace (sym->formal_ns);
} }
--show_level;
fputc ('\n', dumpfile);
} }
...@@ -956,11 +966,22 @@ show_common (gfc_symtree *st) ...@@ -956,11 +966,22 @@ show_common (gfc_symtree *st)
static void static void
show_symtree (gfc_symtree *st) show_symtree (gfc_symtree *st)
{ {
int len, i;
show_indent (); show_indent ();
fprintf (dumpfile, "symtree: %s Ambig %d", st->name, st->ambiguous);
len = strlen(st->name);
fprintf (dumpfile, "symtree: '%s'", st->name);
for (i=len; i<12; i++)
fputc(' ', dumpfile);
if (st->ambiguous)
fputs( " Ambiguous", dumpfile);
if (st->n.sym->ns != gfc_current_ns) if (st->n.sym->ns != gfc_current_ns)
fprintf (dumpfile, " from namespace %s", st->n.sym->ns->proc_name->name); fprintf (dumpfile, "|| symbol: '%s' from namespace '%s'", st->n.sym->name,
st->n.sym->ns->proc_name->name);
else else
show_symbol (st->n.sym); show_symbol (st->n.sym);
} }
...@@ -1202,7 +1223,13 @@ show_code_node (int level, gfc_code *c) ...@@ -1202,7 +1223,13 @@ show_code_node (int level, gfc_code *c)
gfc_dt *dt; gfc_dt *dt;
gfc_namespace *ns; gfc_namespace *ns;
if (c->here)
{
fputc ('\n', dumpfile);
code_indent (level, c->here); code_indent (level, c->here);
}
else
show_indent ();
switch (c->op) switch (c->op)
{ {
...@@ -1375,8 +1402,10 @@ show_code_node (int level, gfc_code *c) ...@@ -1375,8 +1402,10 @@ show_code_node (int level, gfc_code *c)
d = c->block; d = c->block;
fputs ("IF ", dumpfile); fputs ("IF ", dumpfile);
show_expr (d->expr1); show_expr (d->expr1);
fputc ('\n', dumpfile);
++show_level;
show_code (level + 1, d->next); show_code (level + 1, d->next);
--show_level;
d = d->block; d = d->block;
for (; d; d = d->block) for (; d; d = d->block)
...@@ -1384,18 +1413,22 @@ show_code_node (int level, gfc_code *c) ...@@ -1384,18 +1413,22 @@ show_code_node (int level, gfc_code *c)
code_indent (level, 0); code_indent (level, 0);
if (d->expr1 == NULL) if (d->expr1 == NULL)
fputs ("ELSE\n", dumpfile); fputs ("ELSE", dumpfile);
else else
{ {
fputs ("ELSE IF ", dumpfile); fputs ("ELSE IF ", dumpfile);
show_expr (d->expr1); show_expr (d->expr1);
fputc ('\n', dumpfile);
} }
++show_level;
show_code (level + 1, d->next); show_code (level + 1, d->next);
--show_level;
} }
if (c->label1)
code_indent (level, c->label1); code_indent (level, c->label1);
else
show_indent ();
fputs ("ENDIF", dumpfile); fputs ("ENDIF", dumpfile);
break; break;
...@@ -1409,8 +1442,11 @@ show_code_node (int level, gfc_code *c) ...@@ -1409,8 +1442,11 @@ show_code_node (int level, gfc_code *c)
blocktype = "BLOCK"; blocktype = "BLOCK";
show_indent (); show_indent ();
fprintf (dumpfile, "%s ", blocktype); fprintf (dumpfile, "%s ", blocktype);
++show_level;
ns = c->ext.block.ns; ns = c->ext.block.ns;
show_namespace (ns); gfc_traverse_symtree (ns->sym_root, show_symtree);
show_code (show_level, ns->code);
--show_level;
show_indent (); show_indent ();
fprintf (dumpfile, "END %s ", blocktype); fprintf (dumpfile, "END %s ", blocktype);
break; break;
...@@ -1506,6 +1542,8 @@ show_code_node (int level, gfc_code *c) ...@@ -1506,6 +1542,8 @@ show_code_node (int level, gfc_code *c)
case EXEC_DO: case EXEC_DO:
fputs ("DO ", dumpfile); fputs ("DO ", dumpfile);
if (c->label1)
fprintf (dumpfile, " %-5d ", c->label1->value);
show_expr (c->ext.iterator->var); show_expr (c->ext.iterator->var);
fputc ('=', dumpfile); fputc ('=', dumpfile);
...@@ -1514,11 +1552,15 @@ show_code_node (int level, gfc_code *c) ...@@ -1514,11 +1552,15 @@ show_code_node (int level, gfc_code *c)
show_expr (c->ext.iterator->end); show_expr (c->ext.iterator->end);
fputc (' ', dumpfile); fputc (' ', dumpfile);
show_expr (c->ext.iterator->step); show_expr (c->ext.iterator->step);
fputc ('\n', dumpfile);
++show_level;
show_code (level + 1, c->block->next); show_code (level + 1, c->block->next);
--show_level;
code_indent (level, 0); if (c->label1)
break;
show_indent ();
fputs ("END DO", dumpfile); fputs ("END DO", dumpfile);
break; break;
...@@ -2043,7 +2085,6 @@ show_code_node (int level, gfc_code *c) ...@@ -2043,7 +2085,6 @@ show_code_node (int level, gfc_code *c)
} }
show_dt_code: show_dt_code:
fputc ('\n', dumpfile);
for (c = c->block->next; c; c = c->next) for (c = c->block->next; c; c = c->next)
show_code_node (level + (c->next != NULL), c); show_code_node (level + (c->next != NULL), c);
return; return;
...@@ -2087,8 +2128,6 @@ show_code_node (int level, gfc_code *c) ...@@ -2087,8 +2128,6 @@ show_code_node (int level, gfc_code *c)
default: default:
gfc_internal_error ("show_code_node(): Bad statement code"); gfc_internal_error ("show_code_node(): Bad statement code");
} }
fputc ('\n', dumpfile);
} }
...@@ -2121,7 +2160,6 @@ show_namespace (gfc_namespace *ns) ...@@ -2121,7 +2160,6 @@ show_namespace (gfc_namespace *ns)
int i; int i;
save = gfc_current_ns; save = gfc_current_ns;
show_level++;
show_indent (); show_indent ();
fputs ("Namespace:", dumpfile); fputs ("Namespace:", dumpfile);
...@@ -2152,6 +2190,7 @@ show_namespace (gfc_namespace *ns) ...@@ -2152,6 +2190,7 @@ show_namespace (gfc_namespace *ns)
fprintf (dumpfile, "procedure name = %s", ns->proc_name->name); fprintf (dumpfile, "procedure name = %s", ns->proc_name->name);
} }
++show_level;
gfc_current_ns = ns; gfc_current_ns = ns;
gfc_traverse_symtree (ns->common_root, show_common); gfc_traverse_symtree (ns->common_root, show_common);
...@@ -2179,23 +2218,26 @@ show_namespace (gfc_namespace *ns) ...@@ -2179,23 +2218,26 @@ show_namespace (gfc_namespace *ns)
gfc_traverse_user_op (ns, show_uop); gfc_traverse_user_op (ns, show_uop);
} }
} }
else
++show_level;
for (eq = ns->equiv; eq; eq = eq->next) for (eq = ns->equiv; eq; eq = eq->next)
show_equiv (eq); show_equiv (eq);
fputc ('\n', dumpfile); fputc ('\n', dumpfile);
fputc ('\n', dumpfile); show_indent ();
fputs ("code:", dumpfile);
show_code (show_level, ns->code); show_code (show_level, ns->code);
--show_level;
for (ns = ns->contained; ns; ns = ns->sibling) for (ns = ns->contained; ns; ns = ns->sibling)
{ {
show_indent (); fputs ("\nCONTAINS\n", dumpfile);
fputs ("CONTAINS\n", dumpfile); ++show_level;
show_namespace (ns); show_namespace (ns);
--show_level;
} }
show_level--;
fputc ('\n', dumpfile); fputc ('\n', dumpfile);
gfc_current_ns = save; gfc_current_ns = save;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment