xref: /openbsd/gnu/usr.bin/gcc/gcc/java/xref.c (revision c87b03e5)
1*c87b03e5Sespie /* Write cross reference information extracted from Java(TM)
2*c87b03e5Sespie    source and bytecode files, in one of formats documented below.
3*c87b03e5Sespie    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4*c87b03e5Sespie    Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
5*c87b03e5Sespie 
6*c87b03e5Sespie This file is part of GNU CC.
7*c87b03e5Sespie 
8*c87b03e5Sespie GNU CC is free software; you can redistribute it and/or modify
9*c87b03e5Sespie it under the terms of the GNU General Public License as published by
10*c87b03e5Sespie the Free Software Foundation; either version 2, or (at your option)
11*c87b03e5Sespie any later version.
12*c87b03e5Sespie 
13*c87b03e5Sespie GNU CC is distributed in the hope that it will be useful,
14*c87b03e5Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
15*c87b03e5Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*c87b03e5Sespie GNU General Public License for more details.
17*c87b03e5Sespie 
18*c87b03e5Sespie You should have received a copy of the GNU General Public License
19*c87b03e5Sespie along with GNU CC; see the file COPYING.  If not, write to
20*c87b03e5Sespie the Free Software Foundation, 59 Temple Place - Suite 330,
21*c87b03e5Sespie Boston, MA 02111-1307, USA.
22*c87b03e5Sespie 
23*c87b03e5Sespie Java and all Java-based marks are trademarks or registered trademarks
24*c87b03e5Sespie of Sun Microsystems, Inc. in the United States and other countries.
25*c87b03e5Sespie The Free Software Foundation is independent of Sun Microsystems, Inc.  */
26*c87b03e5Sespie 
27*c87b03e5Sespie #include "config.h"
28*c87b03e5Sespie #include "system.h"
29*c87b03e5Sespie #include "tree.h"
30*c87b03e5Sespie #include "java-tree.h"
31*c87b03e5Sespie #include "xref.h"
32*c87b03e5Sespie #include "jcf.h"
33*c87b03e5Sespie #include "parse.h"
34*c87b03e5Sespie 
35*c87b03e5Sespie static xref_flag_table xref_table [] = {
36*c87b03e5Sespie   {NULL, NULL, NULL, NULL},
37*c87b03e5Sespie };
38*c87b03e5Sespie 
39*c87b03e5Sespie /* Decode an xref flag value. Return 0 if the flag wasn't found. */
40*c87b03e5Sespie 
41*c87b03e5Sespie int
xref_flag_value(flag)42*c87b03e5Sespie xref_flag_value (flag)
43*c87b03e5Sespie      const char *flag;
44*c87b03e5Sespie {
45*c87b03e5Sespie   int i;
46*c87b03e5Sespie   for (i = 0; xref_table [i].key; i++)
47*c87b03e5Sespie     if (!strcmp (flag, xref_table [i].key))
48*c87b03e5Sespie       return i+1;
49*c87b03e5Sespie   return 0;
50*c87b03e5Sespie }
51*c87b03e5Sespie 
52*c87b03e5Sespie void
xref_set_data(flag,data)53*c87b03e5Sespie xref_set_data (flag, data)
54*c87b03e5Sespie      int flag;
55*c87b03e5Sespie      void *data;
56*c87b03e5Sespie {
57*c87b03e5Sespie   xref_table [flag-1].data = data;
58*c87b03e5Sespie }
59*c87b03e5Sespie 
60*c87b03e5Sespie void *
xref_get_data(flag)61*c87b03e5Sespie xref_get_data (flag)
62*c87b03e5Sespie      int flag;
63*c87b03e5Sespie {
64*c87b03e5Sespie   return xref_table [flag-1].data;
65*c87b03e5Sespie }
66*c87b03e5Sespie 
67*c87b03e5Sespie void
xref_set_current_fp(fp)68*c87b03e5Sespie xref_set_current_fp (fp)
69*c87b03e5Sespie      FILE *fp;
70*c87b03e5Sespie {
71*c87b03e5Sespie   xref_table [flag_emit_xref-1].fp = fp;
72*c87b03e5Sespie }
73*c87b03e5Sespie 
74*c87b03e5Sespie /* Branch to the right xref "back-end".  */
75*c87b03e5Sespie 
76*c87b03e5Sespie void
expand_xref(node)77*c87b03e5Sespie expand_xref (node)
78*c87b03e5Sespie      tree node;
79*c87b03e5Sespie {
80*c87b03e5Sespie   /* Maintain these two cached. */
81*c87b03e5Sespie   static FILE *fp = NULL;
82*c87b03e5Sespie   static void (*current_expand) PARAMS ((FILE *, tree)) = NULL;
83*c87b03e5Sespie 
84*c87b03e5Sespie   if ( !flag_emit_xref )
85*c87b03e5Sespie     return;
86*c87b03e5Sespie 
87*c87b03e5Sespie   if (!fp)
88*c87b03e5Sespie     fp = xref_table [flag_emit_xref-1].fp;
89*c87b03e5Sespie   if (!current_expand)
90*c87b03e5Sespie     current_expand = xref_table [flag_emit_xref-1].expand;
91*c87b03e5Sespie 
92*c87b03e5Sespie   (*current_expand) (fp, node);
93*c87b03e5Sespie }
94*c87b03e5Sespie 
95*c87b03e5Sespie /* Implementation of the xref back-ends. */
96*c87b03e5Sespie 
97