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 fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
411 TYPE_FIELDS (t) = fld;
412 DECL_CONTEXT (fld) = t;
413 FIELD_PUBLIC (fld) = 1;
414 FIELD_FINAL (fld) = 1;
418 tree atype = build_prim_array_type (element_type, length);
419 tree arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
421 DECL_CONTEXT (arfld) = t;
422 TREE_CHAIN (fld) = arfld;
424 /* We need to force the data field to begin at an alignment at
425 least equal to the biggest alignment in an object type node
426 in order to be compatible with the way that JArray is defined
427 in CNI. However, we can't exceed BIGGEST_FIELD_ALIGNMENT. */
429 unsigned desired_align = TYPE_ALIGN (object_type_node);
430 desired_align = MAX (desired_align, TYPE_ALIGN (element_type));
431 #ifdef BIGGEST_FIELD_ALIGNMENT
432 desired_align = MIN (desired_align,
433 (unsigned) BIGGEST_FIELD_ALIGNMENT);
435 #ifdef ADJUST_FIELD_ALIGN
436 desired_align = ADJUST_FIELD_ALIGN (fld, desired_align);
438 DECL_ALIGN (arfld) = desired_align;
443 unsigned desired_align = TYPE_ALIGN (element_type);
444 #ifdef BIGGEST_FIELD_ALIGNMENT
445 desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
447 TYPE_ALIGN (t) = desired_align;
450 /* We could layout_class, but that loads java.lang.Object prematurely.
451 * This is called by the parser, and it is a bad idea to do load_class
452 * in the middle of parsing, because of possible circularity problems. */
453 push_super_field (t, object_type_node);
459 /* Promote TYPE to the type actually used for fields and parameters. */
465 switch (TREE_CODE (type))
468 return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
470 if (type == boolean_type_node)
471 return promoted_boolean_type_node;
474 if (type == char_type_node)
475 return promoted_char_type_node;
479 if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node))
481 if (type == short_type_node)
482 return promoted_short_type_node;
483 if (type == byte_type_node)
484 return promoted_byte_type_node;
485 return int_type_node;
487 /* ... else fall through ... */
493 /* Parse a signature string, starting at *PTR and ending at LIMIT.
494 Return the seen TREE_TYPE, updating *PTR. */
497 parse_signature_type (ptr, limit)
498 const unsigned char **ptr, *limit;
502 fatal ("bad signature string");
505 case 'B': (*ptr)++; return byte_type_node;
506 case 'C': (*ptr)++; return char_type_node;
507 case 'D': (*ptr)++; return double_type_node;
508 case 'F': (*ptr)++; return float_type_node;
509 case 'S': (*ptr)++; return short_type_node;
510 case 'I': (*ptr)++; return int_type_node;
511 case 'J': (*ptr)++; return long_type_node;
512 case 'Z': (*ptr)++; return boolean_type_node;
513 case 'V': (*ptr)++; return void_type_node;
515 for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); ) (*ptr)++;
516 type = parse_signature_type (ptr, limit);
517 type = build_java_array_type (type, -1);
521 const unsigned char *start = ++(*ptr);
522 register const unsigned char *str = start;
526 fatal ("bad signature string");
531 type = lookup_class (unmangle_classname (start, str - start));
535 fatal ("unrecognized signature string");
537 return promote_type (type);
540 /* Parse a Java "mangled" signature string, starting at SIG_STRING,
541 and SIG_LENGTH bytes long.
542 Return a gcc type node. */
545 parse_signature_string (sig_string, sig_length)
546 const unsigned char *sig_string;
550 const unsigned char *str = sig_string;
551 const unsigned char *limit = str + sig_length;
553 if (str < limit && str[0] == '(')
555 tree argtype_list = NULL_TREE;
557 while (str < limit && str[0] != ')')
559 tree argtype = parse_signature_type (&str, limit);
560 argtype_list = tree_cons (NULL_TREE, argtype, argtype_list);
562 if (str++, str >= limit)
563 fatal ("bad signature string");
564 result_type = parse_signature_type (&str, limit);
565 argtype_list = chainon (nreverse (argtype_list), end_params_node);
566 result_type = build_function_type (result_type, argtype_list);
569 result_type = parse_signature_type (&str, limit);
571 error ("junk at end of signature string");
575 /* Convert a signature to its type.
576 * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types).
580 get_type_from_signature (tree signature)
582 const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature);
583 int len = IDENTIFIER_LENGTH (signature);
585 /* Primitive types aren't cached. */
587 return parse_signature_string (sig, len);
588 type = IDENTIFIER_SIGNATURE_TYPE (signature);
589 if (type == NULL_TREE)
591 type = parse_signature_string (sig, len);
592 IDENTIFIER_SIGNATURE_TYPE (signature) = type;
597 /* Return the signature string for the arguments of method type TYPE. */
600 build_java_argument_signature (type)
603 extern struct obstack temporary_obstack;
604 tree sig = TYPE_ARGUMENT_SIGNATURE (type);
605 if (sig == NULL_TREE)
607 tree args = TYPE_ARG_TYPES (type);
608 if (TREE_CODE (type) == METHOD_TYPE)
609 args = TREE_CHAIN (args); /* Skip "this" argument. */
610 for (; args != end_params_node; args = TREE_CHAIN (args))
612 tree t = build_java_signature (TREE_VALUE (args));
613 obstack_grow (&temporary_obstack,
614 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
616 obstack_1grow (&temporary_obstack, '\0');
618 sig = get_identifier (obstack_base (&temporary_obstack));
619 TYPE_ARGUMENT_SIGNATURE (type) = sig;
620 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
625 /* Return the signature of the given TYPE. */
628 build_java_signature (type)
632 while (TREE_CODE (type) == POINTER_TYPE)
633 type = TREE_TYPE (type);
634 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
635 sig = TYPE_SIGNATURE (type);
636 if (sig == NULL_TREE)
639 switch (TREE_CODE (type))
641 case BOOLEAN_TYPE: sg[0] = 'Z'; goto native;
642 case CHAR_TYPE: sg[0] = 'C'; goto native;
643 case VOID_TYPE: sg[0] = 'V'; goto native;
645 switch (TYPE_PRECISION (type))
647 case 8: sg[0] = 'B'; goto native;
648 case 16: sg[0] = 'S'; goto native;
649 case 32: sg[0] = 'I'; goto native;
650 case 64: sg[0] = 'J'; goto native;
651 default: goto bad_type;
654 switch (TYPE_PRECISION (type))
656 case 32: sg[0] = 'F'; goto native;
657 case 64: sg[0] = 'D'; goto native;
658 default: goto bad_type;
662 sig = get_identifier (sg);
665 if (TYPE_ARRAY_P (type))
667 t = build_java_signature (TYPE_ARRAY_ELEMENT (type));
668 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
673 t = DECL_NAME (TYPE_NAME (type));
674 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
681 extern struct obstack temporary_obstack;
682 sig = build_java_argument_signature (type);
683 obstack_1grow (&temporary_obstack, '(');
684 obstack_grow (&temporary_obstack,
685 IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig));
686 obstack_1grow (&temporary_obstack, ')');
688 t = build_java_signature (TREE_TYPE (type));
689 obstack_grow0 (&temporary_obstack,
690 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
692 sig = get_identifier (obstack_base (&temporary_obstack));
693 obstack_free (&temporary_obstack,
694 obstack_base (&temporary_obstack));
699 fatal ("internal error - build_java_signature passed invalid type");
701 TYPE_SIGNATURE (type) = sig;
706 /* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */
709 set_java_signature (type, sig)
714 while (TREE_CODE (type) == POINTER_TYPE)
715 type = TREE_TYPE (type);
716 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
717 old_sig = TYPE_SIGNATURE (type);
718 if (old_sig != NULL_TREE && old_sig != sig)
719 fatal ("internal error - set_java_signature");
720 TYPE_SIGNATURE (type) = sig;
721 #if 0 /* careful about METHOD_TYPE */
722 if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type))
723 IDENTIFIER_SIGNATURE_TYPE (sig) = type;
727 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
728 matching METHOD_NAME and signature SIGNATURE. If SEARCHED_INTERFACE is
729 not NULL_TREE then first search its superinterfaces for a similar match.
730 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
731 used on method candidates to build their (sometimes partial)
735 lookup_argument_method (searched_class, method_name, method_signature)
736 tree searched_class, method_name, method_signature;
738 return lookup_do (searched_class, NULL_TREE, method_name, method_signature,
739 build_java_argument_signature);
742 /* Search in class SEARCHED_CLASS (and its superclasses and
743 implemented interfaces) for a method matching METHOD_NAME and
744 argument signature METHOD_SIGNATURE. Return a FUNCTION_DECL on
745 success, or NULL_TREE if none found. (Contrast lookup_java_method,
746 which takes into account return type.) */
749 lookup_argument_method2 (searched_class, method_name, method_signature)
750 tree searched_class, method_name, method_signature;
752 return lookup_do (CLASSTYPE_SUPER (searched_class), searched_class,
753 method_name, method_signature,
754 build_java_argument_signature);
757 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
758 matching METHOD_NAME and signature METHOD_SIGNATURE. Return a
759 FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast
760 lookup_argument_method, which ignores return type.) If
761 SEARCHED_CLASS is an interface, search it too. */
764 lookup_java_method (searched_class, method_name, method_signature)
765 tree searched_class, method_name, method_signature;
767 tree searched_interface;
769 /* If this class is an interface class, search its superinterfaces
770 * first. A superinterface is not an interface's superclass: a super
771 * interface is implemented by the interface. */
773 searched_interface = (CLASS_INTERFACE (TYPE_NAME (searched_class)) ?
774 searched_class : NULL_TREE);
775 return lookup_do (searched_class, searched_interface, method_name,
776 method_signature, build_java_signature);
779 /* Search in class SEARCHED_CLASS (an its superclasses) for a method
780 matching METHOD_NAME and signature SIGNATURE. Also search in
781 SEARCHED_INTERFACE (an its superinterfaces) for a similar match.
782 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
783 used on method candidates to build their (sometimes partial)
787 lookup_do (searched_class, searched_interface, method_name, signature, signature_builder)
788 tree searched_class, searched_interface, method_name, signature;
789 tree (*signature_builder) PARAMS ((tree));
793 if (searched_interface)
797 TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (searched_interface)) - 1;
799 for (i = interface_len; i > 0; i--)
802 TREE_VEC_ELT (TYPE_BINFO_BASETYPES (searched_interface), i);
803 tree iclass = BINFO_TYPE (child);
805 /* If the superinterface hasn't been loaded yet, do so now. */
806 if (CLASS_FROM_SOURCE_P (iclass))
807 safe_layout_class (iclass);
808 else if (!CLASS_LOADED_P (iclass))
809 load_class (iclass, 1);
811 for (method = TYPE_METHODS (iclass);
812 method != NULL_TREE; method = TREE_CHAIN (method))
814 tree method_sig = (*signature_builder) (TREE_TYPE (method));
815 tree name = DECL_NAME (method);
817 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
818 EXPR_WFL_NODE (name) : name) == method_name
819 && method_sig == signature)
823 /* it could be defined in a supersuperinterface */
824 if (CLASS_INTERFACE (TYPE_NAME (iclass)))
826 method = lookup_do (iclass, iclass, method_name,
827 signature, signature_builder);
828 if (method != NULL_TREE)
834 while (searched_class != NULL_TREE)
836 for (method = TYPE_METHODS (searched_class);
837 method != NULL_TREE; method = TREE_CHAIN (method))
839 tree method_sig = (*signature_builder) (TREE_TYPE (method));
840 tree name = DECL_NAME (method);
842 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
843 EXPR_WFL_NODE (name) : name) == method_name
844 && method_sig == signature)
847 searched_class = CLASSTYPE_SUPER (searched_class);
853 /* Search in class CLAS for a constructor matching METHOD_SIGNATURE.
854 Return a FUNCTION_DECL on success, or NULL_TREE if none found. */
857 lookup_java_constructor (clas, method_signature)
858 tree clas, method_signature;
860 tree method = TYPE_METHODS (clas);
861 for ( ; method != NULL_TREE; method = TREE_CHAIN (method))
863 tree method_sig = build_java_signature (TREE_TYPE (method));
864 if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature)
870 /* Return a type which is the Binary Numeric Promotion of the pair T1,
871 T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric
872 Promotion. It assumes that both T1 and T2 are eligible to BNP. */
875 binary_numeric_promotion (t1, t2, exp1, exp2)
881 if (t1 == double_type_node || t2 == double_type_node)
883 if (t1 != double_type_node)
884 *exp1 = convert (double_type_node, *exp1);
885 if (t2 != double_type_node)
886 *exp2 = convert (double_type_node, *exp2);
887 return double_type_node;
889 if (t1 == float_type_node || t2 == float_type_node)
891 if (t1 != float_type_node)
892 *exp1 = convert (float_type_node, *exp1);
893 if (t2 != float_type_node)
894 *exp2 = convert (float_type_node, *exp2);
895 return float_type_node;
897 if (t1 == long_type_node || t2 == long_type_node)
899 if (t1 != long_type_node)
900 *exp1 = convert (long_type_node, *exp1);
901 if (t2 != long_type_node)
902 *exp2 = convert (long_type_node, *exp2);
903 return long_type_node;
906 if (t1 != int_type_node)
907 *exp1 = convert (int_type_node, *exp1);
908 if (t2 != int_type_node)
909 *exp2 = convert (int_type_node, *exp2);
910 return int_type_node;