xref.c 2.27 KB
Newer Older
1 2
/* Write cross reference information extracted from Java(TM)
   source and bytecode files, in one of formats documented below.
3
   Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
4 5
   Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)

6
This file is part of GCC.
7

8
GCC is free software; you can redistribute it and/or modify
9 10 11 12
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

13
GCC is distributed in the hope that it will be useful,
14 15 16 17 18
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING.  If not, write to
20 21 22 23 24 25 26 27
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

Java and all Java-based marks are trademarks or registered trademarks
of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc.  */

#include "config.h"
28
#include "system.h"
29 30
#include "coretypes.h"
#include "tm.h"
31 32 33
#include "tree.h"
#include "java-tree.h"
#include "xref.h"
34 35
#include "jcf.h"
#include "parse.h"
36 37

static xref_flag_table xref_table [] = {
Kaveh R. Ghazi committed
38
  {NULL, NULL, NULL, NULL},
39 40 41 42
};

/* Decode an xref flag value. Return 0 if the flag wasn't found. */

43
int
44
xref_flag_value (const char *flag)
45 46 47 48 49 50 51 52
{
  int i;
  for (i = 0; xref_table [i].key; i++)
    if (!strcmp (flag, xref_table [i].key))
      return i+1;
  return 0;
}

53
void
54
xref_set_data (int flag, void *data)
55 56 57 58
{
  xref_table [flag-1].data = data;
}

59
void *
60
xref_get_data (int flag)
61 62 63 64
{
  return xref_table [flag-1].data;
}

65
void
66
xref_set_current_fp (FILE *fp)
67 68 69 70
{
  xref_table [flag_emit_xref-1].fp = fp;
}

71 72 73
/* Branch to the right xref "back-end".  */

void
74
expand_xref (tree node)
75 76 77
{
  /* Maintain these two cached. */
  static FILE *fp = NULL;
78
  static void (*current_expand) (FILE *, tree) = NULL;
79 80 81 82 83 84 85 86 87 88 89 90 91 92

  if ( !flag_emit_xref )
    return;

  if (!fp)
    fp = xref_table [flag_emit_xref-1].fp;
  if (!current_expand)
    current_expand = xref_table [flag_emit_xref-1].expand;

  (*current_expand) (fp, node);
}

/* Implementation of the xref back-ends. */