diff options
| author | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-03-07 08:58:26 +0000 |
|---|---|---|
| committer | apbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-03-07 08:58:26 +0000 |
| commit | 4095293c7d50d2367f6f60a3d9f8feaa1a932d6d (patch) | |
| tree | 7f5247f181780723c8e8790acc8c5afc9d20e754 /gcc/java/expr.c | |
| parent | 261d09344519e41ec72466548567b1460fd2db0c (diff) | |
| download | ppe42-gcc-4095293c7d50d2367f6f60a3d9f8feaa1a932d6d.tar.gz ppe42-gcc-4095293c7d50d2367f6f60a3d9f8feaa1a932d6d.zip | |
2000-03-06 Bryce McKinlay <bryce@albatross.co.nz>
* decl.c (init_decl_processing): Added new class fields `depth',
`ancestors', and `idt' to class_type_node. Use
_Jv_LookupInterfaceMethodIdx for soft_lookupinterfacemthod_node.
* class.c (make_class_data): Push initial values for new fields.
* java-tree.h: Updated prototype for `build_invokeinterface'.
* expr.c (build_invokeinterface): Changed parameters to accept
`method' tree. Calculate index of `method' in its declaring
interface. Build call to _Jv_LookupInterfaceMethodIdx.
(expand_invoke): Call `build_invokeinterface' with new parameters.
* parse.y (patch_invoke): Call `build_invokeinterface' with new
parameters.
(This is Bryce McKinlay's implementation of the interfaces
constant-time dispatch and type checking techniques designed by Per
Bothner.)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32381 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/expr.c')
| -rw-r--r-- | gcc/java/expr.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c index e32b6a9644e..832e662b3e9 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1648,11 +1648,15 @@ build_invokevirtual (dtable, method) } tree -build_invokeinterface (dtable, method_name, method_signature) - tree dtable, method_name, method_signature; +build_invokeinterface (dtable, method) + tree dtable, method; { static tree class_ident = NULL_TREE; tree lookup_arg; + tree interface; + tree idx; + tree meth; + int i; /* We expand invokeinterface here. _Jv_LookupInterfaceMethod() will ensure that the selected method exists, is public and not @@ -1664,14 +1668,25 @@ build_invokeinterface (dtable, method_name, method_signature) dtable = build1 (INDIRECT_REF, dtable_type, dtable); dtable = build (COMPONENT_REF, class_ptr_type, dtable, lookup_field (&dtable_type, class_ident)); - lookup_arg = build_tree_list (NULL_TREE, - (build_utf8_ref - (unmangle_classname - (IDENTIFIER_POINTER(method_signature), - IDENTIFIER_LENGTH(method_signature))))); + + interface = DECL_CONTEXT (method); + + i = 1; + for (meth = TYPE_METHODS (interface); ; meth = TREE_CHAIN (meth), i++) + { + if (meth == method) + { + idx = build_int_2 (i, 0); + break; + } + if (meth == NULL_TREE) + fatal ("internal error in build_invokeinterface"); + } + lookup_arg = tree_cons (NULL_TREE, dtable, - tree_cons (NULL_TREE, build_utf8_ref (method_name), - lookup_arg)); + tree_cons (NULL_TREE, build_class_ref (interface), + build_tree_list (NULL_TREE, idx))); + return build (CALL_EXPR, ptr_type_node, build_address_of (soft_lookupinterfacemethod_node), lookup_arg, NULL_TREE); @@ -1770,7 +1785,7 @@ expand_invoke (opcode, method_ref_index, nargs) if (opcode == OPCODE_invokevirtual) func = build_invokevirtual (dtable, method); else - func = build_invokeinterface (dtable, method_name, method_signature); + func = build_invokeinterface (dtable, method); } func = build1 (NOP_EXPR, build_pointer_type (method_type), func); call = build (CALL_EXPR, TREE_TYPE (method_type), func, arg_list, NULL_TREE); |

