FreeBSD/contrib/gcc/cp/call.c
/* Make an expression which yields the address of the Java interface
   method FN.  This is achieved by generating a call to libjava's
   _Jv_LookupInterfaceMethodIdx().  */
Make an expression which yields the address of the Java interface
method FN.  This is achieved by generating a call to libjava's
_Jv_LookupInterfaceMethodIdx().
Make an expression which yields the address of the Java interface method FN . This is achieved by generating a call to libjava ' s _Jv_LookupInterfaceMethodIdx () .
static tree
build_java_interface_fn_ref (tree fn, tree instance)
{
  tree lookup_args, lookup_fn, method, idx;
  tree klass_ref, iface, iface_ref;
  int i;
  if (!java_iface_lookup_fn)
    {
      tree endlink = build_void_list_node ();
      tree t = tree_cons (NULL_TREE, ptr_type_node,
			  tree_cons (NULL_TREE, ptr_type_node,
				     tree_cons (NULL_TREE, java_int_type_node,
						endlink)));
      java_iface_lookup_fn
	= builtin_function ("_Jv_LookupInterfaceMethodIdx",
			    build_function_type (ptr_type_node, t),
			    0, NOT_BUILT_IN, NULL, NULL_TREE);
    }
  klass_ref = build_vtbl_ref (build_indirect_ref (instance, 0),
			      integer_zero_node);
  iface = DECL_CONTEXT (fn);
  iface_ref = lookup_field (iface, get_identifier ("class$"), 0, false);
  if (!iface_ref || TREE_CODE (iface_ref) != VAR_DECL
      || DECL_CONTEXT (iface_ref) != iface)
    {
      error ("could not find class$ field in java interface type %qT",
		iface);
      return error_mark_node;
    }
  iface_ref = build_address (iface_ref);
  iface_ref = convert (build_pointer_type (iface), iface_ref);
  i = 1;
  for (method = TYPE_METHODS (iface); method; method = TREE_CHAIN (method))
    {
      if (!DECL_VIRTUAL_P (method))
	continue;
      if (fn == method)
	break;
      i++;
    }
  idx = build_int_cst (NULL_TREE, i);
  lookup_args = tree_cons (NULL_TREE, klass_ref,
			   tree_cons (NULL_TREE, iface_ref,
				      build_tree_list (NULL_TREE, idx)));
  lookup_fn = build1 (ADDR_EXPR,
		      build_pointer_type (TREE_TYPE (java_iface_lookup_fn)),
		      java_iface_lookup_fn);
  return build3 (CALL_EXPR, ptr_type_node, lookup_fn, lookup_args, NULL_TREE);
}
static tree build_java_interface_fn_ref ( tree fn , tree instance ) { tree lookup_args , lookup_fn , method , idx ; tree klass_ref , iface , iface_ref ; int i ; if ( ! java_iface_lookup_fn ) { tree endlink = build_void_list_node ( ) ; tree t = tree_cons ( NULL_TREE , ptr_type_node , tree_cons ( NULL_TREE , ptr_type_node , tree_cons ( NULL_TREE , java_int_type_node , endlink ) ) ) ; java_iface_lookup_fn = builtin_function ( " " , build_function_type ( ptr_type_node , t ) , 0 , NOT_BUILT_IN , NULL , NULL_TREE ) ; } klass_ref = build_vtbl_ref ( build_indirect_ref ( instance , 0 ) , integer_zero_node ) ; iface = DECL_CONTEXT ( fn ) ; iface_ref = lookup_field ( iface , get_identifier ( " " ) , 0 , false ) ; if ( ! iface_ref || TREE_CODE ( iface_ref ) != VAR_DECL || DECL_CONTEXT ( iface_ref ) != iface ) { error ( " " , iface ) ; return error_mark_node ; } iface_ref = build_address ( iface_ref ) ; iface_ref = convert ( build_pointer_type ( iface ) , iface_ref ) ; i = 1 ; for ( method = TYPE_METHODS ( iface ) ; method ; method = TREE_CHAIN ( method ) ) { if ( ! DECL_VIRTUAL_P ( method ) ) continue ; if ( fn == method ) break ; i ++ ; } idx = build_int_cst ( NULL_TREE , i ) ; lookup_args = tree_cons ( NULL_TREE , klass_ref , tree_cons ( NULL_TREE , iface_ref , build_tree_list ( NULL_TREE , idx ) ) ) ; lookup_fn = build1 ( ADDR_EXPR , build_pointer_type ( TREE_TYPE ( java_iface_lookup_fn ) ) , java_iface_lookup_fn ) ; return build3 ( CALL_EXPR , ptr_type_node , lookup_fn , lookup_args , NULL_TREE ) ; }
Make an expression which yields the address of the Java interface
method FN.
Make an expression which yields the address of the Java interface method FN .
/* Look up the pointer to the runtime java.lang.Class object for `instance'.
     This is the first entry in the vtable.  */ /* Get the java.lang.Class pointer for the interface being called.  */ /* Determine the itable index of FN.  */