This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: fix class instance "pretty name"
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 28 Oct 2005 14:14:32 -0600
- Subject: [gcjx] Patch: FYI: fix class instance "pretty name"
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This adds a "get_pretty_name" overload to model_class_instance.
This makes error messages nicer, as they now print the actual
instantiation instead of the generic declaration.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/classinst.cc (apply_type_map): Updated for new
model_parameters iterator methods.
(get_signature_map_fragment): Likewise.
(get_pretty_name): New method.
* model/classinst.hh (model_class_instance::get_pretty_name):
Declare.
* model/class.hh (model_class::get_pretty_name): Now virtual.
Index: model/classinst.cc
===================================================================
--- model/classinst.cc (revision 105944)
+++ model/classinst.cc (working copy)
@@ -82,8 +82,8 @@
bool any_changed = false;
std::list<model_class *> new_params;
for (std::list<ref_type_variable>::const_iterator i
- = type_parameters.type_parameters.begin ();
- i != type_parameters.type_parameters.end ();
+ = type_parameters.begin ();
+ i != type_parameters.end ();
++i)
{
model_class *mapping = type_map.find ((*i).get ());
@@ -104,10 +104,9 @@
assert (! type_map.empty_p ());
std::string result = "<";
- std::list<ref_type_variable> ¶ms
- = parent->type_parameters.type_parameters;
- for (std::list<ref_type_variable>::const_iterator i = params.begin ();
- i != params.end ();
+ for (std::list<ref_type_variable>::const_iterator i
+ = type_parameters.begin ();
+ i != type_parameters.end ();
++i)
{
model_type_variable *var = (*i).get ();
@@ -120,6 +119,38 @@
return result;
}
+std::string
+model_class_instance::get_pretty_name () const
+{
+ // FIXME: should share some code with superclass.
+ std::string result;
+ if (declaring_class)
+ result = declaring_class->get_pretty_name () + "$" + get_assigned_name ();
+ else
+ {
+ std::string cu
+ = compilation_unit->get_package ()->get_fully_qualified_name ();
+ result = (cu.empty ()) ? name : cu + "." + name;
+ }
+
+ result += "<";
+ bool first = true;
+ for (std::list<ref_type_variable>::const_iterator i
+ = type_parameters.begin ();
+ i != type_parameters.end ();
+ ++i)
+ {
+ model_class *arg = type_map.find ((*i).get ());
+ if (! first)
+ result += ", ";
+ first = false;
+ result += arg->get_pretty_name ();
+ }
+ result += ">";
+
+ return result;
+}
+
void
model_class_instance::visit (visitor *v)
{
Index: model/class.hh
===================================================================
--- model/class.hh (revision 105957)
+++ model/class.hh (working copy)
@@ -567,7 +567,7 @@
IContext *request,
model_class *qualifier);
- std::string get_pretty_name () const;
+ virtual std::string get_pretty_name () const;
/// Add the class members needed for 'assert' support. This will
/// add a new '$assertionsDisabled' field, and will also add the
Index: model/classinst.hh
===================================================================
--- model/classinst.hh (revision 105944)
+++ model/classinst.hh (working copy)
@@ -74,6 +74,8 @@
return parent;
}
+ std::string get_pretty_name () const;
+
void visit (visitor *);
};