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