[gcjx] Patch: FYI: minor updates to method conversion
Tom Tromey
tromey@redhat.com
Fri Oct 21 21:40:00 GMT 2005
I'm checking this in on the gcjx branch.
This changes method invocation so that subclasses handle method
conversion. This lets us call the correct method on model_method when
there are explicit type arguments to an invocation.
This also adds the needed resolve() override to the generic method
invocation classes.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/invoke.hh (model_invocation_base::method_conversion_p):
Declare.
(model_generic_invocation::method_conversion_p): Likewise.
(model_generic_invocation::resolved_params): New field.
(model_generic_invocation::resolve): Declare.
* model/invoke.cc (method_conversion_p): New methods.
(try_method_conversion): Use it.
(model_generic_invocation): New method.
Index: model/invoke.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/invoke.cc,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 invoke.cc
--- model/invoke.cc 18 Oct 2005 22:16:55 -0000 1.1.2.9
+++ model/invoke.cc 21 Oct 2005 21:38:47 -0000
@@ -28,6 +28,14 @@
return meth->potentially_applicable_p (actual_types);
}
+model_method *
+model_invocation_base::method_conversion_p (model_method *meth,
+ const std::list<model_type *> &actual_types,
+ method_phase phase)
+{
+ return meth->method_conversion_p (actual_types, phase);
+}
+
void
model_invocation_base::try_method_conversion
(const std::set<model_method *> &accessible,
@@ -60,8 +68,8 @@
{
if (potentially_applicable_p (*i, actual_types))
{
- model_method *newmeth
- = (*i)->method_conversion_p (actual_types, phase);
+ model_method *newmeth = method_conversion_p (*i, actual_types,
+ phase);
if (newmeth)
applicable.insert (newmeth);
}
@@ -635,6 +643,35 @@
return meth->potentially_applicable_p (actual_types, actual_type_params);
}
+template<typename T>
+model_method *
+model_generic_invocation<T>::method_conversion_p (model_method *meth,
+ const std::list<model_type *> &actual_types,
+ method_phase phase)
+{
+ return meth->method_conversion_p (resolved_params, actual_types, phase);
+}
+
+template<typename T>
+void
+model_generic_invocation<T>::resolve (resolution_scope *scope)
+{
+ // Resolve our parameters.
+ for (std::list<ref_forwarding_type>::const_iterator i
+ = actual_type_params.begin ();
+ i != actual_type_params.end ();
+ ++i)
+ {
+ (*i)->resolve (scope);
+ if (! (*i)->type ()->reference_p ())
+ throw (*i)->error ("type argument must be reference type");
+ resolved_params.push_back (assert_cast<model_class *> ((*i)->type ()));
+ }
+
+ // Let the superclass finish.
+ T::resolve (scope);
+}
+
// Instantiations.
Index: model/invoke.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/invoke.hh,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 invoke.hh
--- model/invoke.hh 14 Oct 2005 22:04:40 -0000 1.1.2.4
+++ model/invoke.hh 21 Oct 2005 21:38:47 -0000
@@ -60,6 +60,9 @@
virtual bool potentially_applicable_p (model_method *,
const std::list<model_type *> &);
+ virtual model_method *method_conversion_p (model_method *,
+ const std::list<model_type *> &,
+ method_phase);
// This returns the class or interface we must search to find the
// method named NAME, as well as the qualifying class or interface.
@@ -277,14 +280,22 @@
/// The actual type parameters.
std::list<ref_forwarding_type> actual_type_params;
+ /// We keep a second list for convenience.
+ std::list<model_class *> resolved_params;
+
bool potentially_applicable_p (model_method *,
const std::list<model_type *> &);
+ model_method *method_conversion_p (model_method *,
+ const std::list<model_type *> &,
+ method_phase);
public:
model_generic_invocation (const location &,
const std::list<ref_forwarding_type> &);
+ void resolve (resolution_scope *);
+
void visit (visitor *);
};
More information about the Java-patches
mailing list