1 /* Handle types for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
21 Java and all Java-based marks are trademarks or registered trademarks
22 of Sun Microsystems, Inc. in the United States and other countries.
23 The Free Software Foundation is independent of Sun Microsystems, Inc. */
25 /* Written by Per Bothner <bothner@cygnus.com> */
32 #include "java-tree.h"
38 static tree convert_ieee_real_to_integer PARAMS ((tree, tree));
39 static tree parse_signature_type PARAMS ((const unsigned char **,
40 const unsigned char *));
41 static tree lookup_do PARAMS ((tree, tree, tree, tree, tree (*)(tree)));
44 extern struct obstack permanent_obstack;
46 /* Set the type of the local variable with index SLOT to TYPE. */
49 set_local_type (slot, type)
53 int max_locals = DECL_MAX_LOCALS(current_function_decl);
54 int nslots = TYPE_IS_WIDE (type) ? 2 : 1;
55 if (slot < 0 || slot + nslots - 1 >= max_locals)
56 fatal ("invalid local variable index");
57 type_map[slot] = type;
59 type_map[++slot] = void_type_node;
62 /* Convert an IEEE real to an integer type. The result of such a
63 conversion when the source operand is a NaN isn't defined by
64 IEEE754, but by the Java language standard: it must be zero. Also,
65 overflows must be clipped to within range. This conversion
66 produces something like:
68 ((expr >= (float)MAX_INT)
70 : ((expr <= (float)MIN_INT)
77 convert_ieee_real_to_integer (type, expr)
81 expr = save_expr (expr);
83 result = build (COND_EXPR, type,
84 build (NE_EXPR, boolean_type_node, expr, expr),
85 convert (type, integer_zero_node),
86 convert_to_integer (type, expr));
88 result = build (COND_EXPR, type,
89 build (LE_EXPR, boolean_type_node, expr,
90 convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
91 TYPE_MIN_VALUE (type),
94 result = build (COND_EXPR, type,
95 build (GE_EXPR, boolean_type_node, expr,
96 convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
97 TYPE_MAX_VALUE (type),
103 /* Create an expression whose value is that of EXPR,
104 converted to type TYPE. The TREE_TYPE of the value
105 is always TYPE. This function implements all reasonable
106 conversions; callers should filter out those that are
107 not permitted by the language being compiled. */
113 register enum tree_code code = TREE_CODE (type);
116 return error_mark_node;
119 return build1 (NOP_EXPR, type, expr);
121 if (type == TREE_TYPE (expr)
122 || TREE_CODE (expr) == ERROR_MARK)
124 if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
125 return error_mark_node;
126 if (code == VOID_TYPE)
127 return build1 (CONVERT_EXPR, type, expr);
128 if (code == BOOLEAN_TYPE)
129 return fold (convert_to_boolean (type, expr));
130 if (code == INTEGER_TYPE)
133 && ! flag_emit_class_files
134 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
135 && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
136 return fold (convert_ieee_real_to_integer (type, expr));
138 return fold (convert_to_integer (type, expr));
140 if (code == REAL_TYPE)
141 return fold (convert_to_real (type, expr));
142 if (code == CHAR_TYPE)
143 return fold (convert_to_char (type, expr));
144 if (code == POINTER_TYPE)
145 return fold (convert_to_pointer (type, expr));
146 error ("conversion to non-scalar type requested");
147 return error_mark_node;
152 convert_to_char (type, expr)
155 return build1 (NOP_EXPR, type, expr);
159 convert_to_boolean (type, expr)
162 return build1 (NOP_EXPR, type, expr);
165 /* Print an error message for invalid use of an incomplete type.
166 VALUE is the expression that was used (or 0 if that isn't known)
167 and TYPE is the type that was invalid. */
170 incomplete_type_error (value, type)
171 tree value ATTRIBUTE_UNUSED;
172 tree type ATTRIBUTE_UNUSED;
174 error ("internal error - use of undefined type");
177 /* Return a data type that has machine mode MODE.
178 If the mode is an integer,
179 then UNSIGNEDP selects between signed and unsigned types. */
182 type_for_mode (mode, unsignedp)
183 enum machine_mode mode;
186 if (mode == TYPE_MODE (int_type_node))
187 return unsignedp ? unsigned_int_type_node : int_type_node;
188 if (mode == TYPE_MODE (long_type_node))
189 return unsignedp ? unsigned_long_type_node : long_type_node;
190 if (mode == TYPE_MODE (short_type_node))
191 return unsignedp ? unsigned_short_type_node : short_type_node;
192 if (mode == TYPE_MODE (byte_type_node))
193 return unsignedp ? unsigned_byte_type_node : byte_type_node;
194 if (mode == TYPE_MODE (float_type_node))
195 return float_type_node;
196 if (mode == TYPE_MODE (double_type_node))
197 return double_type_node;
202 /* Return an integer type with BITS bits of precision,
203 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
206 type_for_size (bits, unsignedp)
210 if (bits <= TYPE_PRECISION (byte_type_node))
211 return unsignedp ? unsigned_byte_type_node : byte_type_node;
212 if (bits <= TYPE_PRECISION (short_type_node))
213 return unsignedp ? unsigned_short_type_node : short_type_node;
214 if (bits <= TYPE_PRECISION (int_type_node))
215 return unsignedp ? unsigned_int_type_node : int_type_node;
216 if (bits <= TYPE_PRECISION (long_type_node))
217 return unsignedp ? unsigned_long_type_node : long_type_node;
221 /* Return a type the same as TYPE except unsigned or
222 signed according to UNSIGNEDP. */
225 signed_or_unsigned_type (unsignedp, type)
229 if (! INTEGRAL_TYPE_P (type))
231 if (TYPE_PRECISION (type) == TYPE_PRECISION (int_type_node))
232 return unsignedp ? unsigned_int_type_node : int_type_node;
233 if (TYPE_PRECISION (type) == TYPE_PRECISION (byte_type_node))
234 return unsignedp ? unsigned_byte_type_node : byte_type_node;
235 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_type_node))
236 return unsignedp ? unsigned_short_type_node : short_type_node;
237 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_type_node))
238 return unsignedp ? unsigned_long_type_node : long_type_node;
242 /* Return a signed type the same as TYPE in other respects. */
248 return signed_or_unsigned_type (0, type);
251 /* Return an unsigned type the same as TYPE in other respects. */
257 return signed_or_unsigned_type (1, type);
261 /* Mark EXP saying that we need to be able to take the
262 address of it; it should not be allocated in a register.
263 Value is 1 if successful. */
266 mark_addressable (exp)
269 register tree x = exp;
271 switch (TREE_CODE (x))
278 x = TREE_OPERAND (x, 0);
281 case TRUTH_ANDIF_EXPR:
282 case TRUTH_ORIF_EXPR:
284 x = TREE_OPERAND (x, 1);
288 return mark_addressable (TREE_OPERAND (x, 1))
289 & mark_addressable (TREE_OPERAND (x, 2));
292 TREE_ADDRESSABLE (x) = 1;
296 /* We sometimes add a cast *(TYPE*)&FOO to handle type and mode
297 incompatibility problems. Handle this case by marking FOO. */
298 if (TREE_CODE (TREE_OPERAND (x, 0)) == NOP_EXPR
299 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (x, 0), 0)) == ADDR_EXPR)
301 x = TREE_OPERAND (TREE_OPERAND (x, 0), 0);
304 if (TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR)
306 x = TREE_OPERAND (x, 0);
316 TREE_ADDRESSABLE (x) = 1;
317 #if 0 /* poplevel deals with this now. */
318 if (DECL_CONTEXT (x) == 0)
319 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
327 /* Thorough checking of the arrayness of TYPE. */
330 is_array_type_p (type)
333 return TREE_CODE (type) == POINTER_TYPE
334 && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
335 && TYPE_ARRAY_P (TREE_TYPE (type));
338 /* Return the length of a Java array type.
339 Return -1 if the length is unknown or non-constant. */
342 java_array_type_length (array_type)
346 if (TREE_CODE (array_type) == POINTER_TYPE)
347 array_type = TREE_TYPE (array_type);
348 arfld = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type)));
349 if (arfld != NULL_TREE)
351 tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld));
352 tree high = TYPE_MAX_VALUE (index_type);
353 if (TREE_CODE (high) == INTEGER_CST)
354 return TREE_INT_CST_LOW (high) + 1;
360 build_prim_array_type (element_type, length)
362 HOST_WIDE_INT length;
364 tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
365 TREE_TYPE (max_index) = sizetype;
366 return build_array_type (element_type, build_index_type (max_index));
369 /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.
370 These are hashed (shared) using IDENTIFIER_SIGNATURE_TYPE.
371 The LENGTH is -1 if the length is unknown. */
374 build_java_array_type (element_type, length)
376 HOST_WIDE_INT length;
380 tree elsig = build_java_signature (element_type);
381 tree el_name = element_type;
384 sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length);
387 sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
389 t = IDENTIFIER_SIGNATURE_TYPE (sig);
391 return TREE_TYPE (t);
393 IDENTIFIER_SIGNATURE_TYPE (sig) = build_pointer_type (t);
394 TYPE_ARRAY_P (t) = 1;
396 if (TREE_CODE (el_name) == POINTER_TYPE)
397 el_name = TREE_TYPE (el_name);
398 el_name = TYPE_NAME (el_name);
399 if (TREE_CODE (el_name) == TYPE_DECL)
400 el_name = DECL_NAME (el_name);
401 TYPE_NAME (t) = identifier_subst (el_name, "", '.', '.', "[]");
403 set_java_signature (t, sig);
404 set_super_info (0, t, object_type_node, 0);
405 if (TREE_CODE (element_type) == RECORD_TYPE)
406 element_type = promote_type (element_type);
407 TYPE_ARRAY_ELEMENT (t) = element_type;
409 /* Add length pseudo-field. */
410 push_obstacks (&permanent_obstack, &permanent_obstack);
411 fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
412 TYPE_FIELDS (t) = fld;
413 DECL_CONTEXT (fld) = t;
414 FIELD_PUBLIC (fld) = 1;
415 FIELD_FINAL (fld) = 1;
419 tree atype = build_prim_array_type (element_type, length);
420 tree arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
422 DECL_CONTEXT (arfld) = t;
423 TREE_CHAIN (fld) = arfld;
425 /* We need to force the data field to begin at an alignment at
426 least equal to the biggest alignment in an object type node
427 in order to be compatible with the way that JArray is defined
428 in CNI. However, we can't exceed BIGGEST_FIELD_ALIGNMENT. */
430 unsigned desired_align = TYPE_ALIGN (object_type_node);
431 desired_align = MAX (desired_align, TYPE_ALIGN (element_type));
432 #ifdef BIGGEST_FIELD_ALIGNMENT
433 desired_align = MIN (desired_align,
434 (unsigned) BIGGEST_FIELD_ALIGNMENT);
436 #ifdef ADJUST_FIELD_ALIGN
437 desired_align = ADJUST_FIELD_ALIGN (fld, desired_align);
439 DECL_ALIGN (arfld) = desired_align;
444 unsigned desired_align = TYPE_ALIGN (element_type);
445 #ifdef BIGGEST_FIELD_ALIGNMENT
446 desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
448 TYPE_ALIGN (t) = desired_align;
452 /* We could layout_class, but that loads java.lang.Object prematurely.
453 * This is called by the parser, and it is a bad idea to do load_class
454 * in the middle of parsing, because of possible circularity problems. */
455 push_super_field (t, object_type_node);
461 /* Promote TYPE to the type actually used for fields and parameters. */
467 switch (TREE_CODE (type))
470 return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
472 if (type == boolean_type_node)
473 return promoted_boolean_type_node;
476 if (type == char_type_node)
477 return promoted_char_type_node;
481 if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node))
483 if (type == short_type_node)
484 return promoted_short_type_node;
485 if (type == byte_type_node)
486 return promoted_byte_type_node;
487 return int_type_node;
489 /* ... else fall through ... */
495 /* Parse a signature string, starting at *PTR and ending at LIMIT.
496 Return the seen TREE_TYPE, updating *PTR. */
499 parse_signature_type (ptr, limit)
500 const unsigned char **ptr, *limit;
504 fatal ("bad signature string");
507 case 'B': (*ptr)++; return byte_type_node;
508 case 'C': (*ptr)++; return char_type_node;
509 case 'D': (*ptr)++; return double_type_node;
510 case 'F': (*ptr)++; return float_type_node;
511 case 'S': (*ptr)++; return short_type_node;
512 case 'I': (*ptr)++; return int_type_node;
513 case 'J': (*ptr)++; return long_type_node;
514 case 'Z': (*ptr)++; return boolean_type_node;
515 case 'V': (*ptr)++; return void_type_node;
517 for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); ) (*ptr)++;
518 type = parse_signature_type (ptr, limit);
519 type = build_java_array_type (type, -1);
523 const unsigned char *start = ++(*ptr);
524 register const unsigned char *str = start;
528 fatal ("bad signature string");
533 type = lookup_class (unmangle_classname (start, str - start));
537 fatal ("unrecognized signature string");
539 return promote_type (type);
542 /* Parse a Java "mangled" signature string, starting at SIG_STRING,
543 and SIG_LENGTH bytes long.
544 Return a gcc type node. */
547 parse_signature_string (sig_string, sig_length)
548 const unsigned char *sig_string;
552 const unsigned char *str = sig_string;
553 const unsigned char *limit = str + sig_length;
555 push_obstacks (&permanent_obstack, &permanent_obstack);
556 if (str < limit && str[0] == '(')
558 tree argtype_list = NULL_TREE;
560 while (str < limit && str[0] != ')')
562 tree argtype = parse_signature_type (&str, limit);
563 argtype_list = tree_cons (NULL_TREE, argtype, argtype_list);
565 if (str++, str >= limit)
566 fatal ("bad signature string");
567 result_type = parse_signature_type (&str, limit);
568 argtype_list = chainon (nreverse (argtype_list), end_params_node);
569 result_type = build_function_type (result_type, argtype_list);
572 result_type = parse_signature_type (&str, limit);
574 error ("junk at end of signature string");
579 /* Convert a signature to its type.
580 * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types).
584 get_type_from_signature (tree signature)
586 const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature);
587 int len = IDENTIFIER_LENGTH (signature);
589 /* Primitive types aren't cached. */
591 return parse_signature_string (sig, len);
592 type = IDENTIFIER_SIGNATURE_TYPE (signature);
593 if (type == NULL_TREE)
595 type = parse_signature_string (sig, len);
596 IDENTIFIER_SIGNATURE_TYPE (signature) = type;
601 /* Return the signature string for the arguments of method type TYPE. */
604 build_java_argument_signature (type)
607 extern struct obstack temporary_obstack;
608 tree sig = TYPE_ARGUMENT_SIGNATURE (type);
609 if (sig == NULL_TREE)
611 tree args = TYPE_ARG_TYPES (type);
612 if (TREE_CODE (type) == METHOD_TYPE)
613 args = TREE_CHAIN (args); /* Skip "this" argument. */
614 for (; args != end_params_node; args = TREE_CHAIN (args))
616 tree t = build_java_signature (TREE_VALUE (args));
617 obstack_grow (&temporary_obstack,
618 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
620 obstack_1grow (&temporary_obstack, '\0');
622 sig = get_identifier (obstack_base (&temporary_obstack));
623 TYPE_ARGUMENT_SIGNATURE (type) = sig;
624 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
629 /* Return the signature of the given TYPE. */
632 build_java_signature (type)
636 push_obstacks (&permanent_obstack, &permanent_obstack);
637 while (TREE_CODE (type) == POINTER_TYPE)
638 type = TREE_TYPE (type);
639 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
640 sig = TYPE_SIGNATURE (type);
641 if (sig == NULL_TREE)
644 switch (TREE_CODE (type))
646 case BOOLEAN_TYPE: sg[0] = 'Z'; goto native;
647 case CHAR_TYPE: sg[0] = 'C'; goto native;
648 case VOID_TYPE: sg[0] = 'V'; goto native;
650 switch (TYPE_PRECISION (type))
652 case 8: sg[0] = 'B'; goto native;
653 case 16: sg[0] = 'S'; goto native;
654 case 32: sg[0] = 'I'; goto native;
655 case 64: sg[0] = 'J'; goto native;
656 default: goto bad_type;
659 switch (TYPE_PRECISION (type))
661 case 32: sg[0] = 'F'; goto native;
662 case 64: sg[0] = 'D'; goto native;
663 default: goto bad_type;
667 sig = get_identifier (sg);
670 if (TYPE_ARRAY_P (type))
672 t = build_java_signature (TYPE_ARRAY_ELEMENT (type));
673 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
678 t = DECL_NAME (TYPE_NAME (type));
679 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
686 extern struct obstack temporary_obstack;
687 sig = build_java_argument_signature (type);
688 obstack_1grow (&temporary_obstack, '(');
689 obstack_grow (&temporary_obstack,
690 IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig));
691 obstack_1grow (&temporary_obstack, ')');
693 t = build_java_signature (TREE_TYPE (type));
694 obstack_grow0 (&temporary_obstack,
695 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
697 sig = get_identifier (obstack_base (&temporary_obstack));
698 obstack_free (&temporary_obstack,
699 obstack_base (&temporary_obstack));
704 fatal ("internal error - build_java_signature passed invalid type");
706 TYPE_SIGNATURE (type) = sig;
712 /* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */
715 set_java_signature (type, sig)
720 while (TREE_CODE (type) == POINTER_TYPE)
721 type = TREE_TYPE (type);
722 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
723 old_sig = TYPE_SIGNATURE (type);
724 if (old_sig != NULL_TREE && old_sig != sig)
725 fatal ("internal error - set_java_signature");
726 TYPE_SIGNATURE (type) = sig;
727 #if 0 /* careful about METHOD_TYPE */
728 if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type))
729 IDENTIFIER_SIGNATURE_TYPE (sig) = type;
733 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
734 matching METHOD_NAME and signature SIGNATURE. If SEARCHED_INTERFACE is
735 not NULL_TREE then first search its superinterfaces for a similar match.
736 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
737 used on method candidates to build their (sometimes partial)
741 lookup_argument_method (searched_class, method_name, method_signature)
742 tree searched_class, method_name, method_signature;
744 return lookup_do (searched_class, NULL_TREE, method_name, method_signature,
745 build_java_argument_signature);
748 /* Search in class SEARCHED_CLASS (and its superclasses and
749 implemented interfaces) for a method matching METHOD_NAME and
750 argument signature METHOD_SIGNATURE. Return a FUNCTION_DECL on
751 success, or NULL_TREE if none found. (Contrast lookup_java_method,
752 which takes into account return type.) */
755 lookup_argument_method2 (searched_class, method_name, method_signature)
756 tree searched_class, method_name, method_signature;
758 return lookup_do (CLASSTYPE_SUPER (searched_class), searched_class,
759 method_name, method_signature,
760 build_java_argument_signature);
763 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
764 matching METHOD_NAME and signature METHOD_SIGNATURE. Return a
765 FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast
766 lookup_argument_method, which ignores return type.) If
767 SEARCHED_CLASS is an interface, search it too. */
770 lookup_java_method (searched_class, method_name, method_signature)
771 tree searched_class, method_name, method_signature;
773 tree searched_interface;
775 /* If this class is an interface class, search its superinterfaces
776 * first. A superinterface is not an interface's superclass: a super
777 * interface is implemented by the interface. */
779 searched_interface = (CLASS_INTERFACE (TYPE_NAME (searched_class)) ?
780 searched_class : NULL_TREE);
781 return lookup_do (searched_class, searched_interface, method_name,
782 method_signature, build_java_signature);
785 /* Search in class SEARCHED_CLASS (an its superclasses) for a method
786 matching METHOD_NAME and signature SIGNATURE. Also search in
787 SEARCHED_INTERFACE (an its superinterfaces) for a similar match.
788 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
789 used on method candidates to build their (sometimes partial)
793 lookup_do (searched_class, searched_interface, method_name, signature, signature_builder)
794 tree searched_class, searched_interface, method_name, signature;
795 tree (*signature_builder) PARAMS ((tree));
799 if (searched_interface)
803 TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (searched_interface)) - 1;
805 for (i = interface_len; i > 0; i--)
808 TREE_VEC_ELT (TYPE_BINFO_BASETYPES (searched_interface), i);
809 tree iclass = BINFO_TYPE (child);
811 /* If the superinterface hasn't been loaded yet, do so now. */
812 if (CLASS_FROM_SOURCE_P (iclass))
813 safe_layout_class (iclass);
814 else if (!CLASS_LOADED_P (iclass))
815 load_class (iclass, 1);
817 for (method = TYPE_METHODS (iclass);
818 method != NULL_TREE; method = TREE_CHAIN (method))
820 tree method_sig = (*signature_builder) (TREE_TYPE (method));
821 tree name = DECL_NAME (method);
823 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
824 EXPR_WFL_NODE (name) : name) == method_name
825 && method_sig == signature)
829 /* it could be defined in a supersuperinterface */
830 if (CLASS_INTERFACE (TYPE_NAME (iclass)))
832 method = lookup_do (iclass, iclass, method_name,
833 signature, signature_builder);
834 if (method != NULL_TREE)
840 while (searched_class != NULL_TREE)
842 for (method = TYPE_METHODS (searched_class);
843 method != NULL_TREE; method = TREE_CHAIN (method))
845 tree method_sig = (*signature_builder) (TREE_TYPE (method));
846 tree name = DECL_NAME (method);
848 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
849 EXPR_WFL_NODE (name) : name) == method_name
850 && method_sig == signature)
853 searched_class = CLASSTYPE_SUPER (searched_class);
859 /* Search in class CLAS for a constructor matching METHOD_SIGNATURE.
860 Return a FUNCTION_DECL on success, or NULL_TREE if none found. */
863 lookup_java_constructor (clas, method_signature)
864 tree clas, method_signature;
866 tree method = TYPE_METHODS (clas);
867 for ( ; method != NULL_TREE; method = TREE_CHAIN (method))
869 tree method_sig = build_java_signature (TREE_TYPE (method));
870 if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature)
876 /* Return a type which is the Binary Numeric Promotion of the pair T1,
877 T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric
878 Promotion. It assumes that both T1 and T2 are eligible to BNP. */
881 binary_numeric_promotion (t1, t2, exp1, exp2)
887 if (t1 == double_type_node || t2 == double_type_node)
889 if (t1 != double_type_node)
890 *exp1 = convert (double_type_node, *exp1);
891 if (t2 != double_type_node)
892 *exp2 = convert (double_type_node, *exp2);
893 return double_type_node;
895 if (t1 == float_type_node || t2 == float_type_node)
897 if (t1 != float_type_node)
898 *exp1 = convert (float_type_node, *exp1);
899 if (t2 != float_type_node)
900 *exp2 = convert (float_type_node, *exp2);
901 return float_type_node;
903 if (t1 == long_type_node || t2 == long_type_node)
905 if (t1 != long_type_node)
906 *exp1 = convert (long_type_node, *exp1);
907 if (t2 != long_type_node)
908 *exp2 = convert (long_type_node, *exp2);
909 return long_type_node;
912 if (t1 != int_type_node)
913 *exp1 = convert (int_type_node, *exp1);
914 if (t2 != int_type_node)
915 *exp2 = convert (int_type_node, *exp2);
916 return int_type_node;