summaryrefslogtreecommitdiff
path: root/gcc/java/constants.c
diff options
context:
space:
mode:
authorjsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-25 17:32:54 +0000
committerjsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-25 17:32:54 +0000
commitce1d036cda78d167143fb5797c8d4c4b3f0327ad (patch)
tree658c8162441bcbc5b5ac3ccf09f08949ff878437 /gcc/java/constants.c
parent0f45d3be2de0b1e23eac3452e8420309a67ed56b (diff)
downloadgcc-ce1d036cda78d167143fb5797c8d4c4b3f0327ad.tar.gz
Fix PR java/13183.
* constants.c (cpool_for_class): New function. (outgoing_cpool): Remove global variable. (alloc_name_constant): Use cpool_for_class. (build_constants_constructor): Likewise. * decl.c (java_expand_body): Set current_class. * java-tree.h (outgoing_cpool) Remove declaration. (init_outgoing_cpool): Likewise. * jcf-parse.c (init_outgoing_cpool): Remove function. (parse_class_file): Don't call init_outgoing_cpool. * parse.y (java_complete_expand_methods): Don't call init_outgoing_cpool. Don't save outgoing_cpool. (java_expand_classes): Don't restore outgoing_cpool. (java_finish_classes): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73926 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/constants.c')
-rw-r--r--gcc/java/constants.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/java/constants.c b/gcc/java/constants.c
index 274a8bfd91b..8a1fe1bb4ea 100644
--- a/gcc/java/constants.c
+++ b/gcc/java/constants.c
@@ -37,6 +37,7 @@ static int find_class_or_string_constant (CPool *, int, tree);
static int find_name_and_type_constant (CPool *, tree, tree);
static tree get_tag_node (int);
static tree build_constant_data_ref (void);
+static CPool *cpool_for_class (tree);
/* Set the INDEX'th constant in CPOOL to have the given TAG and VALUE. */
@@ -315,8 +316,6 @@ write_constant_pool (CPool *cpool, unsigned char *buffer, int length)
abort ();
}
-CPool *outgoing_cpool;
-
static GTY(()) tree tag_nodes[13];
static tree
get_tag_node (int tag)
@@ -328,6 +327,21 @@ get_tag_node (int tag)
return tag_nodes[tag];
}
+/* Given a class, return its constant pool, creating one if necessary. */
+
+static CPool *
+cpool_for_class (tree class)
+{
+ CPool *cpool = TYPE_CPOOL (class);
+
+ if (cpool == NULL)
+ {
+ cpool = ggc_alloc_cleared (sizeof (struct CPool));
+ TYPE_CPOOL (class) = cpool;
+ }
+ return cpool;
+}
+
/* Look for a constant pool entry that matches TAG and NAME.
Creates a new entry if not found.
TAG is one of CONSTANT_Utf8, CONSTANT_String or CONSTANT_Class.
@@ -337,6 +351,7 @@ get_tag_node (int tag)
int
alloc_name_constant (int tag, tree name)
{
+ CPool *outgoing_cpool = cpool_for_class (current_class);
return find_tree_constant (outgoing_cpool, tag, name);
}
@@ -414,6 +429,7 @@ build_ref_from_constant_pool (int index)
tree
build_constants_constructor (void)
{
+ CPool *outgoing_cpool = cpool_for_class (current_class);
tree tags_value, data_value;
tree cons;
tree tags_list = NULL_TREE;