⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dump-parse-tree.c

📁 gcc-fortran,linux使用fortran的编译软件。很好用的。
💻 C
📖 第 1 页 / 共 3 页
字号:
/* Parse tree dumper   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.   Contributed by Steven BosscherThis file is part of GCC.GCC is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the FreeSoftware Foundation; either version 2, or (at your option) any laterversion.GCC is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with GCC; see the file COPYING.  If not, write to the FreeSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA02110-1301, USA.  *//* Actually this is just a collection of routines that used to be   scattered around the sources.  Now that they are all in a single   file, almost all of them can be static, and the other files don't   have this mess in them.   As a nice side-effect, this file can act as documentation of the   gfc_code and gfc_expr structures and all their friends and   relatives.   TODO: Dump DATA.  */#include "config.h"#include "gfortran.h"/* Keep track of indentation for symbol tree dumps.  */static int show_level = 0;/* Forward declaration because this one needs all, and all need   this one.  */static void gfc_show_expr (gfc_expr *);/* Do indentation for a specific level.  */static inline voidcode_indent (int level, gfc_st_label * label){  int i;  if (label != NULL)    gfc_status ("%-5d ", label->value);  else    gfc_status ("      ");  for (i = 0; i < 2 * level; i++)    gfc_status_char (' ');}/* Simple indentation at the current level.  This one   is used to show symbols.  */static inline voidshow_indent (void){  gfc_status ("\n");  code_indent (show_level, NULL);}/* Show type-specific information.  */static voidgfc_show_typespec (gfc_typespec * ts){  gfc_status ("(%s ", gfc_basic_typename (ts->type));  switch (ts->type)    {    case BT_DERIVED:      gfc_status ("%s", ts->derived->name);      break;    case BT_CHARACTER:      gfc_show_expr (ts->cl->length);      break;    default:      gfc_status ("%d", ts->kind);      break;    }  gfc_status (")");}/* Show an actual argument list.  */static voidgfc_show_actual_arglist (gfc_actual_arglist * a){  gfc_status ("(");  for (; a; a = a->next)    {      gfc_status_char ('(');      if (a->name != NULL)	gfc_status ("%s = ", a->name);      if (a->expr != NULL)	gfc_show_expr (a->expr);      else	gfc_status ("(arg not-present)");      gfc_status_char (')');      if (a->next != NULL)	gfc_status (" ");    }  gfc_status (")");}/* Show a gfc_array_spec array specification structure.  */static voidgfc_show_array_spec (gfc_array_spec * as){  const char *c;  int i;  if (as == NULL)    {      gfc_status ("()");      return;    }  gfc_status ("(%d", as->rank);  if (as->rank != 0)    {      switch (as->type)      {	case AS_EXPLICIT:      c = "AS_EXPLICIT";      break;	case AS_DEFERRED:      c = "AS_DEFERRED";      break;	case AS_ASSUMED_SIZE:  c = "AS_ASSUMED_SIZE";  break;	case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;	default:	  gfc_internal_error		("gfc_show_array_spec(): Unhandled array shape type.");      }      gfc_status (" %s ", c);      for (i = 0; i < as->rank; i++)	{	  gfc_show_expr (as->lower[i]);	  gfc_status_char (' ');	  gfc_show_expr (as->upper[i]);	  gfc_status_char (' ');	}    }  gfc_status (")");}/* Show a gfc_array_ref array reference structure.  */static voidgfc_show_array_ref (gfc_array_ref * ar){  int i;  gfc_status_char ('(');  switch (ar->type)    {    case AR_FULL:      gfc_status ("FULL");      break;    case AR_SECTION:      for (i = 0; i < ar->dimen; i++)	{	  /* There are two types of array sections: either the	     elements are identified by an integer array ('vector'),	     or by an index range. In the former case we only have to	     print the start expression which contains the vector, in	     the latter case we have to print any of lower and upper	     bound and the stride, if they're present.  */  	  if (ar->start[i] != NULL)	    gfc_show_expr (ar->start[i]);	  if (ar->dimen_type[i] == DIMEN_RANGE)	    {	      gfc_status_char (':');	      if (ar->end[i] != NULL)		gfc_show_expr (ar->end[i]);	      if (ar->stride[i] != NULL)		{		  gfc_status_char (':');		  gfc_show_expr (ar->stride[i]);		}	    }	  if (i != ar->dimen - 1)	    gfc_status (" , ");	}      break;    case AR_ELEMENT:      for (i = 0; i < ar->dimen; i++)	{	  gfc_show_expr (ar->start[i]);	  if (i != ar->dimen - 1)	    gfc_status (" , ");	}      break;    case AR_UNKNOWN:      gfc_status ("UNKNOWN");      break;    default:      gfc_internal_error ("gfc_show_array_ref(): Unknown array reference");    }  gfc_status_char (')');}/* Show a list of gfc_ref structures.  */static voidgfc_show_ref (gfc_ref * p){  for (; p; p = p->next)    switch (p->type)      {      case REF_ARRAY:	gfc_show_array_ref (&p->u.ar);	break;      case REF_COMPONENT:	gfc_status (" %% %s", p->u.c.component->name);	break;      case REF_SUBSTRING:	gfc_status_char ('(');	gfc_show_expr (p->u.ss.start);	gfc_status_char (':');	gfc_show_expr (p->u.ss.end);	gfc_status_char (')');	break;      default:	gfc_internal_error ("gfc_show_ref(): Bad component code");      }}/* Display a constructor.  Works recursively for array constructors.  */static voidgfc_show_constructor (gfc_constructor * c){  for (; c; c = c->next)    {      if (c->iterator == NULL)	gfc_show_expr (c->expr);      else	{	  gfc_status_char ('(');	  gfc_show_expr (c->expr);	  gfc_status_char (' ');	  gfc_show_expr (c->iterator->var);	  gfc_status_char ('=');	  gfc_show_expr (c->iterator->start);	  gfc_status_char (',');	  gfc_show_expr (c->iterator->end);	  gfc_status_char (',');	  gfc_show_expr (c->iterator->step);	  gfc_status_char (')');	}      if (c->next != NULL)	gfc_status (" , ");    }}/* Show an expression.  */static voidgfc_show_expr (gfc_expr * p){  const char *c;  int i;  if (p == NULL)    {      gfc_status ("()");      return;    }  switch (p->expr_type)    {    case EXPR_SUBSTRING:      c = p->value.character.string;      for (i = 0; i < p->value.character.length; i++, c++)	{	  if (*c == '\'')	    gfc_status ("''");	  else	    gfc_status ("%c", *c);	}      gfc_show_ref (p->ref);      break;    case EXPR_STRUCTURE:      gfc_status ("%s(", p->ts.derived->name);      gfc_show_constructor (p->value.constructor);      gfc_status_char (')');      break;    case EXPR_ARRAY:      gfc_status ("(/ ");      gfc_show_constructor (p->value.constructor);      gfc_status (" /)");      gfc_show_ref (p->ref);      break;    case EXPR_NULL:      gfc_status ("NULL()");      break;    case EXPR_CONSTANT:      switch (p->ts.type)	{	case BT_INTEGER:	  mpz_out_str (stdout, 10, p->value.integer);	  if (p->ts.kind != gfc_default_integer_kind)	    gfc_status ("_%d", p->ts.kind);	  break;	case BT_LOGICAL:	  if (p->value.logical)	    gfc_status (".true.");	  else	    gfc_status (".false.");	  break;	case BT_REAL:	  mpfr_out_str (stdout, 10, 0, p->value.real, GFC_RND_MODE);	  if (p->ts.kind != gfc_default_real_kind)	    gfc_status ("_%d", p->ts.kind);	  break;	case BT_CHARACTER:	  c = p->value.character.string;	  gfc_status_char ('\'');	  for (i = 0; i < p->value.character.length; i++, c++)	    {	      if (*c == '\'')		gfc_status ("''");	      else		gfc_status_char (*c);	    }	  gfc_status_char ('\'');	  break;	case BT_COMPLEX:	  gfc_status ("(complex ");	  mpfr_out_str (stdout, 10, 0, p->value.complex.r, GFC_RND_MODE);	  if (p->ts.kind != gfc_default_complex_kind)	    gfc_status ("_%d", p->ts.kind);	  gfc_status (" ");	  mpfr_out_str (stdout, 10, 0, p->value.complex.i, GFC_RND_MODE);	  if (p->ts.kind != gfc_default_complex_kind)	    gfc_status ("_%d", p->ts.kind);	  gfc_status (")");	  break;	default:	  gfc_status ("???");	  break;	}      break;    case EXPR_VARIABLE:      if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)	gfc_status ("%s:", p->symtree->n.sym->ns->proc_name->name);      gfc_status ("%s", p->symtree->n.sym->name);      gfc_show_ref (p->ref);      break;    case EXPR_OP:      gfc_status ("(");      switch (p->value.op.operator)	{	case INTRINSIC_UPLUS:	  gfc_status ("U+ ");	  break;	case INTRINSIC_UMINUS:	  gfc_status ("U- ");	  break;	case INTRINSIC_PLUS:	  gfc_status ("+ ");	  break;	case INTRINSIC_MINUS:	  gfc_status ("- ");	  break;	case INTRINSIC_TIMES:	  gfc_status ("* ");	  break;	case INTRINSIC_DIVIDE:	  gfc_status ("/ ");	  break;	case INTRINSIC_POWER:	  gfc_status ("** ");	  break;	case INTRINSIC_CONCAT:	  gfc_status ("// ");	  break;	case INTRINSIC_AND:	  gfc_status ("AND ");	  break;	case INTRINSIC_OR:	  gfc_status ("OR ");	  break;	case INTRINSIC_EQV:	  gfc_status ("EQV ");	  break;	case INTRINSIC_NEQV:	  gfc_status ("NEQV ");	  break;	case INTRINSIC_EQ:	  gfc_status ("= ");	  break;	case INTRINSIC_NE:	  gfc_status ("<> ");	  break;	case INTRINSIC_GT:	  gfc_status ("> ");	  break;	case INTRINSIC_GE:	  gfc_status (">= ");	  break;	case INTRINSIC_LT:	  gfc_status ("< ");	  break;	case INTRINSIC_LE:	  gfc_status ("<= ");	  break;	case INTRINSIC_NOT:	  gfc_status ("NOT ");	  break;	case INTRINSIC_PARENTHESES:	  gfc_status ("parens");	  break;	default:	  gfc_internal_error	    ("gfc_show_expr(): Bad intrinsic in expression!");	}      gfc_show_expr (p->value.op.op1);      if (p->value.op.op2)	{	  gfc_status (" ");	  gfc_show_expr (p->value.op.op2);	}      gfc_status (")");      break;    case EXPR_FUNCTION:      if (p->value.function.name == NULL)	{	  gfc_status ("%s[", p->symtree->n.sym->name);	  gfc_show_actual_arglist (p->value.function.actual);	  gfc_status_char (']');	}      else	{	  gfc_status ("%s[[", p->value.function.name);	  gfc_show_actual_arglist (p->value.function.actual);	  gfc_status_char (']');	  gfc_status_char (']');	}      break;    default:      gfc_internal_error ("gfc_show_expr(): Don't know how to show expr");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -