[gcjx] Patch: FYI: rename output_constant_pool
Tom Tromey
tromey@redhat.com
Wed Apr 20 16:04:00 GMT 2005
I'm checking this in on the gcjx branch.
gcc has a function named output_constant_pool, which clashes with a
class in gcjx. In the past we had a hack to work around this, but it
turns out that we have to include "output.h" fairly early if we want
to build gcjx with gcc 4.0; otherwise we don't see a definition of
__gcc_host_wide_int__, resulting in a crash in the attribute
initialization code in g++.
This patch fixes the problem by renaming the class. Really we ought
to put gcjx into its own namespace, but I'm putting that off.
Tom
Index: gcjx/ChangeLog
from Tom Tromey <tromey@redhat.com>
* bytecode/outpool.hh (class outgoing_constant_pool): Renamed
from output_constant_pool.
* bytecode/attribute.cc, bytecode/attribute.hh,
bytecode/classwriter.cc, bytecode/classwriter.hh,
bytecode/generate.cc, bytecode/generate.hh, bytecode/locals.cc,
bytecode/locals.hh, bytecode/outpool.cc: Updated.
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
* builtins.cc (HACK_WANT_OUTPUT_H): Don't define.
* glue.hh: Include output.h earlier, and unconditionally.
Index: gcjx/bytecode/attribute.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/attribute.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 attribute.cc
--- gcjx/bytecode/attribute.cc 22 Jan 2005 07:56:24 -0000 1.1.2.4
+++ gcjx/bytecode/attribute.cc 20 Apr 2005 16:00:48 -0000
@@ -27,13 +27,13 @@
#include "bytecode/generate.hh"
static int emit_annotation_value (bytecode_stream *writer,
- output_constant_pool *pool,
+ outgoing_constant_pool *pool,
model_expression *expr);
static int emit_annotation (bytecode_stream *writer,
- output_constant_pool *pool,
+ outgoing_constant_pool *pool,
model_annotation *anno);
-bytecode_attribute::bytecode_attribute (output_constant_pool *p,
+bytecode_attribute::bytecode_attribute (outgoing_constant_pool *p,
const std::string &n)
: pool (p),
name (n)
@@ -63,7 +63,7 @@
-utf8_attribute::utf8_attribute (output_constant_pool *p,
+utf8_attribute::utf8_attribute (outgoing_constant_pool *p,
const std::string &n,
const std::string &v)
: bytecode_attribute (p, n),
@@ -82,7 +82,7 @@
-inner_classes_attribute::inner_classes_attribute (output_constant_pool *p)
+inner_classes_attribute::inner_classes_attribute (outgoing_constant_pool *p)
: bytecode_attribute (p, "InnerClasses")
{
assert (pool->inner_classes_p ());
@@ -103,7 +103,7 @@
-exceptions_attribute::exceptions_attribute (output_constant_pool *p,
+exceptions_attribute::exceptions_attribute (outgoing_constant_pool *p,
const std::set<model_type *> &e)
: bytecode_attribute (p, "Exceptions"),
excs (e)
@@ -128,7 +128,7 @@
-code_attribute::code_attribute (output_constant_pool *p, bytecode_generator *g)
+code_attribute::code_attribute (outgoing_constant_pool *p, bytecode_generator *g)
: bytecode_attribute (p, "Code"),
gen (g)
{
@@ -149,7 +149,7 @@
-field_value_attribute::field_value_attribute (output_constant_pool *p,
+field_value_attribute::field_value_attribute (outgoing_constant_pool *p,
model_field *field)
: bytecode_attribute (p, "ConstantValue"),
index (-1)
@@ -189,7 +189,7 @@
template<typename T>
static void
-emit_primitive (bytecode_stream *writer, output_constant_pool *pool,
+emit_primitive (bytecode_stream *writer, outgoing_constant_pool *pool,
model_type *type, T val)
{
int index = pool->add (val);
@@ -201,7 +201,7 @@
}
static int
-emit_annotation_value (bytecode_stream *writer, output_constant_pool *pool,
+emit_annotation_value (bytecode_stream *writer, outgoing_constant_pool *pool,
model_expression *expr)
{
int result = 0;
@@ -319,7 +319,7 @@
// Write an annotation and return the size. If WRITER is NULL, don't
// write, just compute the size and update the constant pool.
static int
-emit_annotation (bytecode_stream *writer, output_constant_pool *pool,
+emit_annotation (bytecode_stream *writer, outgoing_constant_pool *pool,
model_annotation *anno)
{
int result = 0;
@@ -349,7 +349,7 @@
return result;
}
-annotation_attribute::annotation_attribute (output_constant_pool *p,
+annotation_attribute::annotation_attribute (outgoing_constant_pool *p,
const std::string &n,
const std::list<model_annotation *> &as)
: bytecode_attribute (p, n),
@@ -374,7 +374,7 @@
emit_annotation (&writer, pool, *i);
}
-parameter_attribute::parameter_attribute (output_constant_pool *p,
+parameter_attribute::parameter_attribute (outgoing_constant_pool *p,
const std::string &n,
const std::list< std::list<model_annotation *> > &as)
: bytecode_attribute (p, n),
@@ -415,7 +415,7 @@
}
}
-annotation_default_attribute::annotation_default_attribute (output_constant_pool *p,
+annotation_default_attribute::annotation_default_attribute (outgoing_constant_pool *p,
model_expression *e)
: bytecode_attribute (p, "AnnotationDefault"),
len (0),
Index: gcjx/bytecode/attribute.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/attribute.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 attribute.hh
--- gcjx/bytecode/attribute.hh 16 Jan 2005 04:36:41 -0000 1.1.2.2
+++ gcjx/bytecode/attribute.hh 20 Apr 2005 16:00:48 -0000
@@ -31,12 +31,12 @@
protected:
/// Constant pool.
- output_constant_pool *pool;
+ outgoing_constant_pool *pool;
/// Name of attribute.
std::string name;
- bytecode_attribute (output_constant_pool *, const std::string &);
+ bytecode_attribute (outgoing_constant_pool *, const std::string &);
public:
@@ -57,7 +57,7 @@
{
public:
- simple_name_attribute (output_constant_pool *p, const std::string &n)
+ simple_name_attribute (outgoing_constant_pool *p, const std::string &n)
: bytecode_attribute (p, n)
{
}
@@ -78,7 +78,7 @@
public:
- utf8_attribute (output_constant_pool *, const std::string &,
+ utf8_attribute (outgoing_constant_pool *, const std::string &,
const std::string &);
void emit (bytecode_stream &);
@@ -95,7 +95,7 @@
{
public:
- inner_classes_attribute (output_constant_pool *);
+ inner_classes_attribute (outgoing_constant_pool *);
void emit (bytecode_stream &);
@@ -110,7 +110,7 @@
public:
- exceptions_attribute (output_constant_pool *,
+ exceptions_attribute (outgoing_constant_pool *,
const std::set<model_type *> &);
void emit (bytecode_stream &);
@@ -129,7 +129,7 @@
public:
- code_attribute (output_constant_pool *, bytecode_generator *);
+ code_attribute (outgoing_constant_pool *, bytecode_generator *);
void emit (bytecode_stream &);
@@ -144,7 +144,7 @@
public:
- field_value_attribute (output_constant_pool *, model_field *);
+ field_value_attribute (outgoing_constant_pool *, model_field *);
void emit (bytecode_stream &);
@@ -166,7 +166,7 @@
public:
- annotation_attribute (output_constant_pool *,
+ annotation_attribute (outgoing_constant_pool *,
const std::string &,
const std::list<model_annotation *> &);
@@ -189,7 +189,7 @@
public:
- parameter_attribute (output_constant_pool *,
+ parameter_attribute (outgoing_constant_pool *,
const std::string &,
const std::list< std::list<model_annotation *> > &);
@@ -212,7 +212,7 @@
public:
- annotation_default_attribute (output_constant_pool *, model_expression *);
+ annotation_default_attribute (outgoing_constant_pool *, model_expression *);
void emit (bytecode_stream &);
Index: gcjx/bytecode/classwriter.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/classwriter.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 classwriter.cc
--- gcjx/bytecode/classwriter.cc 26 Jan 2005 02:36:59 -0000 1.1.2.4
+++ gcjx/bytecode/classwriter.cc 20 Apr 2005 16:00:48 -0000
@@ -185,7 +185,7 @@
writer.put2 (MINOR_1_4);
writer.put2 (MAJOR_1_4);
- pool = new output_constant_pool (the_class, writer);
+ pool = new outgoing_constant_pool (the_class, writer);
int class_index = pool->add (the_class);
Index: gcjx/bytecode/classwriter.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/classwriter.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 classwriter.hh
--- gcjx/bytecode/classwriter.hh 26 Jan 2005 02:36:59 -0000 1.1.2.2
+++ gcjx/bytecode/classwriter.hh 20 Apr 2005 16:00:48 -0000
@@ -38,7 +38,7 @@
bytecode_stream writer;
// The constant pool for this class.
- output_constant_pool *pool;
+ outgoing_constant_pool *pool;
// True if we're targeting 1.5.
bool target_15;
Index: gcjx/bytecode/generate.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.cc,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 generate.cc
--- gcjx/bytecode/generate.cc 12 Mar 2005 20:51:07 -0000 1.1.2.10
+++ gcjx/bytecode/generate.cc 20 Apr 2005 16:00:48 -0000
@@ -36,7 +36,7 @@
}
bytecode_generator::bytecode_generator (model_method *m,
- output_constant_pool *cp)
+ outgoing_constant_pool *cp)
: method (m),
cpool (cp),
vars (this),
Index: gcjx/bytecode/generate.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/generate.hh,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 generate.hh
--- gcjx/bytecode/generate.hh 17 Apr 2005 18:36:05 -0000 1.1.2.6
+++ gcjx/bytecode/generate.hh 20 Apr 2005 16:00:48 -0000
@@ -84,7 +84,7 @@
model_method *method;
// Constant pool we're generating.
- output_constant_pool *cpool;
+ outgoing_constant_pool *cpool;
typedef std::map< const model_stmt *,
std::pair<bytecode_block *, bytecode_block *>
@@ -168,7 +168,7 @@
public:
- line_table_attribute (output_constant_pool *p, bytecode_generator *g)
+ line_table_attribute (outgoing_constant_pool *p, bytecode_generator *g)
: bytecode_attribute (p, "LineNumberTable"),
gen (g)
{
@@ -199,7 +199,7 @@
public:
- local_variable_table_attribute (output_constant_pool *p, locals *v,
+ local_variable_table_attribute (outgoing_constant_pool *p, locals *v,
bool types)
: bytecode_attribute (p, (types ? "LocalVariableTypeTable"
: "LocalVariableTable")),
@@ -362,7 +362,7 @@
public:
- bytecode_generator (model_method *, output_constant_pool *);
+ bytecode_generator (model_method *, outgoing_constant_pool *);
virtual ~bytecode_generator ();
Index: gcjx/bytecode/locals.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/locals.cc,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 locals.cc
--- gcjx/bytecode/locals.cc 17 Apr 2005 18:36:05 -0000 1.1.2.6
+++ gcjx/bytecode/locals.cc 20 Apr 2005 16:00:48 -0000
@@ -187,7 +187,7 @@
}
int
-locals::emit (output_constant_pool *pool, bytecode_stream *out, bool types)
+locals::emit (outgoing_constant_pool *pool, bytecode_stream *out, bool types)
{
int count = 0;
for (std::list<debug_info>::iterator i = var_descriptions.begin ();
Index: gcjx/bytecode/locals.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/locals.hh,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 locals.hh
--- gcjx/bytecode/locals.hh 20 Jan 2005 18:02:38 -0000 1.1.2.4
+++ gcjx/bytecode/locals.hh 20 Apr 2005 16:00:48 -0000
@@ -25,7 +25,7 @@
class bytecode_block;
class bytecode_generator;
class bytecode_stream;
-class output_constant_pool;
+class outgoing_constant_pool;
/// This class is used to keep track of the local variable slots while
/// generating code for a given method.
@@ -121,7 +121,7 @@
/// emitted. The final argument is true if we are emitting a
/// LocalVariableTypeTable, false if we are emitting a
/// LocalVariableTable.
- int emit (output_constant_pool *, bytecode_stream *, bool);
+ int emit (outgoing_constant_pool *, bytecode_stream *, bool);
/// Return true if any local variable has a parameterized type (and
/// thus a LocalVariableTypeTable is required).
Index: gcjx/bytecode/outpool.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/outpool.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 outpool.cc
--- gcjx/bytecode/outpool.cc 16 Jan 2005 04:36:41 -0000 1.1.2.2
+++ gcjx/bytecode/outpool.cc 20 Apr 2005 16:00:49 -0000
@@ -24,7 +24,7 @@
#include "bytecode/outpool.hh"
#include "bytecode/poolreader.hh"
-output_constant_pool::output_constant_pool (model_class *k, bytecode_stream &b)
+outgoing_constant_pool::outgoing_constant_pool (model_class *k, bytecode_stream &b)
: capacity (1),
offset (b.get_offset ()),
finished (false),
@@ -36,14 +36,14 @@
bytes.put2 (0);
}
-output_constant_pool::~output_constant_pool ()
+outgoing_constant_pool::~outgoing_constant_pool ()
{
if (fake_unit)
delete fake_unit;
}
void
-output_constant_pool::finish ()
+outgoing_constant_pool::finish ()
{
bytes.put2_at (offset, capacity);
finished = true;
@@ -51,7 +51,7 @@
template<typename T>
int
-output_constant_pool::check (std::map<T, int> &the_map, T the_value)
+outgoing_constant_pool::check (std::map<T, int> &the_map, T the_value)
{
typename std::map<T, int>::iterator iter = the_map.find (the_value);
if (iter != the_map.end ())
@@ -66,7 +66,7 @@
template<typename T>
int
-output_constant_pool::check_qual (std::map<T, type_map_type> &the_map,
+outgoing_constant_pool::check_qual (std::map<T, type_map_type> &the_map,
model_type *the_type, T the_value)
{
typename std::map<T, type_map_type>::iterator iter
@@ -78,7 +78,7 @@
}
void
-output_constant_pool::increase_capacity (size_t amount)
+outgoing_constant_pool::increase_capacity (size_t amount)
{
capacity += amount;
if (capacity > 65535)
@@ -86,7 +86,7 @@
}
int
-output_constant_pool::add_utf (const std::string &str)
+outgoing_constant_pool::add_utf (const std::string &str)
{
int index = check (utf_map, str);
if (index < 0)
@@ -107,7 +107,7 @@
}
int
-output_constant_pool::add_name_and_type (const std::string &name,
+outgoing_constant_pool::add_name_and_type (const std::string &name,
const std::string &type)
{
int nindex = add_utf (name);
@@ -128,7 +128,7 @@
}
int
-output_constant_pool::add (model_type *type)
+outgoing_constant_pool::add (model_type *type)
{
assert (type != null_type);
int index = check (type_map, type);
@@ -165,7 +165,7 @@
}
void
-output_constant_pool::add_if_inner (model_type *t)
+outgoing_constant_pool::add_if_inner (model_type *t)
{
if (t->reference_p ())
{
@@ -176,7 +176,7 @@
}
int
-output_constant_pool::add (model_type *qual, model_method *meth)
+outgoing_constant_pool::add (model_type *qual, model_method *meth)
{
int index = check_qual (method_map, qual, meth);
if (index < 0)
@@ -206,7 +206,7 @@
}
int
-output_constant_pool::add (model_type *qual, model_field *fld)
+outgoing_constant_pool::add (model_type *qual, model_field *fld)
{
int index = check_qual (field_map, qual, fld);
if (index < 0)
@@ -231,7 +231,7 @@
}
int
-output_constant_pool::add (jint val)
+outgoing_constant_pool::add (jint val)
{
int index = check (int_map, val);
if (index < 0)
@@ -247,7 +247,7 @@
}
int
-output_constant_pool::add (jlong val)
+outgoing_constant_pool::add (jlong val)
{
int index = check (long_map, val);
if (index < 0)
@@ -266,7 +266,7 @@
}
int
-output_constant_pool::add (jfloat val)
+outgoing_constant_pool::add (jfloat val)
{
jint w = float_to_word (val);
int index = check (float_map, w);
@@ -283,7 +283,7 @@
}
int
-output_constant_pool::add (jdouble val)
+outgoing_constant_pool::add (jdouble val)
{
jint words[2];
double_to_words (words, val);
@@ -306,7 +306,7 @@
}
int
-output_constant_pool::add (const std::string &str)
+outgoing_constant_pool::add (const std::string &str)
{
int index = check (string_map, str);
if (index < 0)
@@ -323,13 +323,13 @@
}
bool
-output_constant_pool::inner_classes_p ()
+outgoing_constant_pool::inner_classes_p ()
{
return ! nested_classes.empty ();
}
void
-output_constant_pool::write_inner_classes ()
+outgoing_constant_pool::write_inner_classes ()
{
// Here we freely use 'add', assuming that the entries have all been
// added already.
@@ -356,13 +356,13 @@
}
int
-output_constant_pool::size ()
+outgoing_constant_pool::size ()
{
return 2 + 8 * nested_classes.size ();
}
void
-output_constant_pool::update_descriptor (std::map<std::string, model_class *> &desc_map,
+outgoing_constant_pool::update_descriptor (std::map<std::string, model_class *> &desc_map,
model_type *t)
{
if (dynamic_cast<model_class *> (t) != NULL)
@@ -380,7 +380,7 @@
}
void
-output_constant_pool::update_descriptor (std::map<std::string, model_class *> &desc_map,
+outgoing_constant_pool::update_descriptor (std::map<std::string, model_class *> &desc_map,
model_method *meth)
{
@@ -393,7 +393,7 @@
}
model_unit_class *
-output_constant_pool::get_fake_compilation_unit (const location &where,
+outgoing_constant_pool::get_fake_compilation_unit (const location &where,
model_class *declarer)
{
assert (finished);
@@ -444,7 +444,7 @@
}
std::string
-output_constant_pool::get_descriptor (model_type *type)
+outgoing_constant_pool::get_descriptor (model_type *type)
{
if (type->array_p () || type->primitive_p ()
|| type == primitive_void_type)
Index: gcjx/bytecode/outpool.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/outpool.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 outpool.hh
--- gcjx/bytecode/outpool.hh 16 Jan 2005 04:36:41 -0000 1.1.2.2
+++ gcjx/bytecode/outpool.hh 20 Apr 2005 16:00:49 -0000
@@ -30,7 +30,7 @@
/// values that are added and will only add a given item once. It
/// automatically handles all the processing associated with inner
/// classes. When finished it can write itself to the output stream.
-class output_constant_pool
+class outgoing_constant_pool
{
// Number of elements in the pool.
int capacity;
@@ -87,8 +87,8 @@
public:
- output_constant_pool (model_class *, bytecode_stream &);
- ~output_constant_pool ();
+ outgoing_constant_pool (model_class *, bytecode_stream &);
+ ~outgoing_constant_pool ();
int add_utf (const std::string &);
int add (model_type *);
Index: gcc/java/builtins.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.cc,v
retrieving revision 1.1.2.33
diff -u -r1.1.2.33 builtins.cc
--- gcc/java/builtins.cc 17 Apr 2005 21:37:17 -0000 1.1.2.33
+++ gcc/java/builtins.cc 20 Apr 2005 16:00:59 -0000
@@ -19,9 +19,6 @@
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-// FIXME: see glue.hh for why this is lame.
-#define HACK_WANT_OUTPUT_H
-
// This include must come first.
#include "java/glue.hh"
#include "aot/mangle.hh"
Index: gcc/java/glue.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/glue.hh,v
retrieving revision 1.1.2.11
diff -u -r1.1.2.11 glue.hh
--- gcc/java/glue.hh 4 Apr 2005 04:30:32 -0000 1.1.2.11
+++ gcc/java/glue.hh 20 Apr 2005 16:00:59 -0000
@@ -59,15 +59,8 @@
#include "langhooks.h"
#include "langhooks-def.h"
#include "options.h"
-#include "toplev.h"
- // FIXME: This is just plain ugly. GCC defines output_constant_pool
- // as a function, but it is also a class in gcjx. So we only
- // include this conditionally. The real fix is to wrap everything
- // in gcjx in a namespace, and rename our local "gcjx" namespace to
- // something else, probably "gcj".
-#ifdef HACK_WANT_OUTPUT_H
#include "output.h"
-#endif
+#include "toplev.h"
#include "except.h"
#include "flags.h"
#include "tree-inline.h"
More information about the Java-patches
mailing list