1 /* Handle types for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007, 2008
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>.
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> */
29 #include "coretypes.h"
33 #include "java-tree.h"
39 static tree
convert_ieee_real_to_integer (tree
, tree
);
40 static tree
parse_signature_type (const unsigned char **,
41 const unsigned char *);
42 static tree
lookup_do (tree
, int, tree
, tree
, tree (*)(tree
));
43 static tree
build_null_signature (tree
);
47 /* Set the type of the local variable with index SLOT to TYPE. */
50 set_local_type (int slot
, tree type
)
52 int max_locals
= DECL_MAX_LOCALS(current_function_decl
);
53 int nslots
= TYPE_IS_WIDE (type
) ? 2 : 1;
55 gcc_assert (slot
>= 0 && (slot
+ nslots
- 1 < max_locals
));
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 (tree type
, tree expr
)
80 expr
= save_expr (expr
);
82 result
= fold_build3 (COND_EXPR
, type
,
83 fold_build2 (NE_EXPR
, boolean_type_node
, expr
, expr
),
84 convert (type
, integer_zero_node
),
85 convert_to_integer (type
, expr
));
87 result
= fold_build3 (COND_EXPR
, type
,
88 fold_build2 (LE_EXPR
, boolean_type_node
, expr
,
89 convert (TREE_TYPE (expr
),
90 TYPE_MIN_VALUE (type
))),
91 TYPE_MIN_VALUE (type
),
94 result
= fold_build3 (COND_EXPR
, type
,
95 fold_build2 (GE_EXPR
, boolean_type_node
, expr
,
96 convert (TREE_TYPE (expr
),
97 TYPE_MAX_VALUE (type
))),
98 TYPE_MAX_VALUE (type
),
104 /* Create an expression whose value is that of EXPR,
105 converted to type TYPE. The TREE_TYPE of the value
106 is always TYPE. This function implements all reasonable
107 conversions; callers should filter out those that are
108 not permitted by the language being compiled. */
111 convert (tree type
, tree expr
)
113 enum tree_code code
= TREE_CODE (type
);
116 return error_mark_node
;
118 if (type
== TREE_TYPE (expr
)
119 || TREE_CODE (expr
) == ERROR_MARK
)
121 if (TREE_CODE (TREE_TYPE (expr
)) == ERROR_MARK
)
122 return error_mark_node
;
123 if (code
== VOID_TYPE
)
124 return build1 (CONVERT_EXPR
, type
, expr
);
125 if (code
== BOOLEAN_TYPE
)
126 return fold_convert (type
, expr
);
127 if (code
== INTEGER_TYPE
)
129 if (type
== char_type_node
|| type
== promoted_char_type_node
)
130 return fold_convert (type
, expr
);
131 if ((really_constant_p (expr
) || ! flag_unsafe_math_optimizations
)
132 && TREE_CODE (TREE_TYPE (expr
)) == REAL_TYPE
)
133 return convert_ieee_real_to_integer (type
, expr
);
136 /* fold very helpfully sets the overflow status if a type
137 overflows in a narrowing integer conversion, but Java
139 tree tmp
= fold (convert_to_integer (type
, expr
));
140 if (TREE_CODE (tmp
) == INTEGER_CST
)
141 TREE_OVERFLOW (tmp
) = 0;
145 if (code
== REAL_TYPE
)
146 return fold (convert_to_real (type
, expr
));
147 if (code
== POINTER_TYPE
)
148 return fold (convert_to_pointer (type
, expr
));
149 error ("conversion to non-scalar type requested");
150 return error_mark_node
;
154 /* Return a data type that has machine mode MODE.
155 If the mode is an integer,
156 then UNSIGNEDP selects between signed and unsigned types. */
159 java_type_for_mode (enum machine_mode mode
, int unsignedp
)
161 if (mode
== TYPE_MODE (int_type_node
))
162 return unsignedp
? unsigned_int_type_node
: int_type_node
;
163 if (mode
== TYPE_MODE (long_type_node
))
164 return unsignedp
? unsigned_long_type_node
: long_type_node
;
165 if (mode
== TYPE_MODE (short_type_node
))
166 return unsignedp
? unsigned_short_type_node
: short_type_node
;
167 if (mode
== TYPE_MODE (byte_type_node
))
168 return unsignedp
? unsigned_byte_type_node
: byte_type_node
;
169 if (mode
== TYPE_MODE (float_type_node
))
170 return float_type_node
;
171 if (mode
== TYPE_MODE (double_type_node
))
172 return double_type_node
;
177 /* Return an integer type with BITS bits of precision,
178 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
181 java_type_for_size (unsigned bits
, int unsignedp
)
183 if (bits
<= TYPE_PRECISION (byte_type_node
))
184 return unsignedp
? unsigned_byte_type_node
: byte_type_node
;
185 if (bits
<= TYPE_PRECISION (short_type_node
))
186 return unsignedp
? unsigned_short_type_node
: short_type_node
;
187 if (bits
<= TYPE_PRECISION (int_type_node
))
188 return unsignedp
? unsigned_int_type_node
: int_type_node
;
189 if (bits
<= TYPE_PRECISION (long_type_node
))
190 return unsignedp
? unsigned_long_type_node
: long_type_node
;
194 /* Thorough checking of the arrayness of TYPE. */
197 is_array_type_p (tree type
)
199 return TREE_CODE (type
) == POINTER_TYPE
200 && TREE_CODE (TREE_TYPE (type
)) == RECORD_TYPE
201 && TYPE_ARRAY_P (TREE_TYPE (type
));
204 /* Return the length of a Java array type.
205 Return -1 if the length is unknown or non-constant. */
208 java_array_type_length (tree array_type
)
211 if (TREE_CODE (array_type
) == POINTER_TYPE
)
212 array_type
= TREE_TYPE (array_type
);
213 arfld
= TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type
)));
214 if (arfld
!= NULL_TREE
)
216 tree index_type
= TYPE_DOMAIN (TREE_TYPE (arfld
));
217 if (index_type
!= NULL_TREE
)
219 tree high
= TYPE_MAX_VALUE (index_type
);
220 if (TREE_CODE (high
) == INTEGER_CST
)
221 return TREE_INT_CST_LOW (high
) + 1;
227 /* An array of unknown length will be ultimately given a length of
228 -2, so that we can still have `length' producing a negative value
229 even if found. This was part of an optimization aiming at removing
230 `length' from static arrays. We could restore it, FIXME. */
233 build_prim_array_type (tree element_type
, HOST_WIDE_INT length
)
239 tree max_index
= build_int_cst (sizetype
, length
- 1);
240 index
= build_index_type (max_index
);
242 return build_array_type (element_type
, index
);
245 /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.
246 These are hashed (shared) using IDENTIFIER_SIGNATURE_TYPE.
247 The LENGTH is -1 if the length is unknown. */
250 build_java_array_type (tree element_type
, HOST_WIDE_INT length
)
252 tree sig
, t
, fld
, atype
, arfld
;
254 tree elsig
= build_java_signature (element_type
);
255 tree el_name
= element_type
;
258 sprintf (buf
+1, HOST_WIDE_INT_PRINT_DEC
, length
);
261 sig
= ident_subst (IDENTIFIER_POINTER (elsig
), IDENTIFIER_LENGTH (elsig
),
263 t
= IDENTIFIER_SIGNATURE_TYPE (sig
);
265 return TREE_TYPE (t
);
267 IDENTIFIER_SIGNATURE_TYPE (sig
) = build_pointer_type (t
);
268 TYPE_ARRAY_P (t
) = 1;
270 if (TREE_CODE (el_name
) == POINTER_TYPE
)
271 el_name
= TREE_TYPE (el_name
);
272 el_name
= TYPE_NAME (el_name
);
273 if (TREE_CODE (el_name
) == TYPE_DECL
)
274 el_name
= DECL_NAME (el_name
);
278 sprintf (suffix
, "[%d]", (int)length
);
280 strcpy (suffix
, "[]");
283 = build_decl (input_location
, TYPE_DECL
,
284 identifier_subst (el_name
, "", '.', '.', suffix
),
286 TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t
)) = true;
289 set_java_signature (t
, sig
);
290 set_super_info (0, t
, object_type_node
, 0);
291 if (TREE_CODE (element_type
) == RECORD_TYPE
)
292 element_type
= promote_type (element_type
);
293 TYPE_ARRAY_ELEMENT (t
) = element_type
;
295 /* Add length pseudo-field. */
296 fld
= build_decl (input_location
,
297 FIELD_DECL
, get_identifier ("length"), int_type_node
);
298 TYPE_FIELDS (t
) = fld
;
299 DECL_CONTEXT (fld
) = t
;
300 FIELD_PUBLIC (fld
) = 1;
301 FIELD_FINAL (fld
) = 1;
302 TREE_READONLY (fld
) = 1;
304 atype
= build_prim_array_type (element_type
, length
);
305 arfld
= build_decl (input_location
,
306 FIELD_DECL
, get_identifier ("data"), atype
);
307 DECL_CONTEXT (arfld
) = t
;
308 TREE_CHAIN (fld
) = arfld
;
309 DECL_ALIGN (arfld
) = TYPE_ALIGN (element_type
);
311 /* We could layout_class, but that loads java.lang.Object prematurely.
312 * This is called by the parser, and it is a bad idea to do load_class
313 * in the middle of parsing, because of possible circularity problems. */
314 push_super_field (t
, object_type_node
);
320 /* Promote TYPE to the type actually used for fields and parameters. */
323 promote_type (tree type
)
325 switch (TREE_CODE (type
))
328 return build_pointer_type (type
);
330 if (type
== boolean_type_node
)
331 return promoted_boolean_type_node
;
334 if (type
== char_type_node
)
335 return promoted_char_type_node
;
337 if (TYPE_PRECISION (type
) < TYPE_PRECISION (int_type_node
))
339 if (type
== short_type_node
)
340 return promoted_short_type_node
;
341 if (type
== byte_type_node
)
342 return promoted_byte_type_node
;
343 return int_type_node
;
345 /* ... else fall through ... */
351 /* Parse a signature string, starting at *PTR and ending at LIMIT.
352 Return the seen TREE_TYPE, updating *PTR. */
355 parse_signature_type (const unsigned char **ptr
, const unsigned char *limit
)
358 gcc_assert (*ptr
< limit
);
362 case 'B': (*ptr
)++; return byte_type_node
;
363 case 'C': (*ptr
)++; return char_type_node
;
364 case 'D': (*ptr
)++; return double_type_node
;
365 case 'F': (*ptr
)++; return float_type_node
;
366 case 'S': (*ptr
)++; return short_type_node
;
367 case 'I': (*ptr
)++; return int_type_node
;
368 case 'J': (*ptr
)++; return long_type_node
;
369 case 'Z': (*ptr
)++; return boolean_type_node
;
370 case 'V': (*ptr
)++; return void_type_node
;
372 for ((*ptr
)++; (*ptr
) < limit
&& ISDIGIT (**ptr
); ) (*ptr
)++;
373 type
= parse_signature_type (ptr
, limit
);
374 type
= build_java_array_type (type
, -1);
378 const unsigned char *start
= ++(*ptr
);
379 const unsigned char *str
= start
;
382 gcc_assert (str
< limit
);
387 type
= lookup_class (unmangle_classname ((const char *) start
, str
- start
));
393 return promote_type (type
);
396 /* Parse a Java "mangled" signature string, starting at SIG_STRING,
397 and SIG_LENGTH bytes long.
398 Return a gcc type node. */
401 parse_signature_string (const unsigned char *sig_string
, int sig_length
)
404 const unsigned char *str
= sig_string
;
405 const unsigned char *limit
= str
+ sig_length
;
407 if (str
< limit
&& str
[0] == '(')
409 tree argtype_list
= NULL_TREE
;
411 while (str
< limit
&& str
[0] != ')')
413 tree argtype
= parse_signature_type (&str
, limit
);
414 argtype_list
= tree_cons (NULL_TREE
, argtype
, argtype_list
);
416 if (str
++, str
>= limit
)
418 result_type
= parse_signature_type (&str
, limit
);
419 argtype_list
= chainon (nreverse (argtype_list
), end_params_node
);
420 result_type
= build_function_type (result_type
, argtype_list
);
423 result_type
= parse_signature_type (&str
, limit
);
425 error ("junk at end of signature string");
429 /* Convert a signature to its type.
430 * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types).
434 get_type_from_signature (tree signature
)
436 const unsigned char *sig
= (const unsigned char *) IDENTIFIER_POINTER (signature
);
437 int len
= IDENTIFIER_LENGTH (signature
);
439 /* Primitive types aren't cached. */
441 return parse_signature_string (sig
, len
);
442 type
= IDENTIFIER_SIGNATURE_TYPE (signature
);
443 if (type
== NULL_TREE
)
445 type
= parse_signature_string (sig
, len
);
446 IDENTIFIER_SIGNATURE_TYPE (signature
) = type
;
451 /* Ignore signature and always return null. Used by has_method. */
454 build_null_signature (tree type ATTRIBUTE_UNUSED
)
459 /* Return the signature string for the arguments of method type TYPE. */
462 build_java_argument_signature (tree type
)
464 extern struct obstack temporary_obstack
;
465 tree sig
= TYPE_ARGUMENT_SIGNATURE (type
);
466 if (sig
== NULL_TREE
)
468 tree args
= TYPE_ARG_TYPES (type
);
469 if (TREE_CODE (type
) == METHOD_TYPE
)
470 args
= TREE_CHAIN (args
); /* Skip "this" argument. */
471 for (; args
!= end_params_node
; args
= TREE_CHAIN (args
))
473 tree t
= build_java_signature (TREE_VALUE (args
));
474 obstack_grow (&temporary_obstack
,
475 IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
));
477 obstack_1grow (&temporary_obstack
, '\0');
479 sig
= get_identifier (obstack_base (&temporary_obstack
));
480 TYPE_ARGUMENT_SIGNATURE (type
) = sig
;
481 obstack_free (&temporary_obstack
, obstack_base (&temporary_obstack
));
486 /* Return the signature of the given TYPE. */
489 build_java_signature (tree type
)
492 while (TREE_CODE (type
) == POINTER_TYPE
)
493 type
= TREE_TYPE (type
);
494 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type
);
495 sig
= TYPE_SIGNATURE (type
);
496 if (sig
== NULL_TREE
)
499 switch (TREE_CODE (type
))
501 case BOOLEAN_TYPE
: sg
[0] = 'Z'; goto native
;
502 case VOID_TYPE
: sg
[0] = 'V'; goto native
;
504 if (type
== char_type_node
|| type
== promoted_char_type_node
)
509 switch (TYPE_PRECISION (type
))
511 case 8: sg
[0] = 'B'; goto native
;
512 case 16: sg
[0] = 'S'; goto native
;
513 case 32: sg
[0] = 'I'; goto native
;
514 case 64: sg
[0] = 'J'; goto native
;
515 default: goto bad_type
;
518 switch (TYPE_PRECISION (type
))
520 case 32: sg
[0] = 'F'; goto native
;
521 case 64: sg
[0] = 'D'; goto native
;
522 default: goto bad_type
;
526 sig
= get_identifier (sg
);
529 if (TYPE_ARRAY_P (type
))
531 t
= build_java_signature (TYPE_ARRAY_ELEMENT (type
));
532 sig
= ident_subst (IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
),
537 t
= DECL_NAME (TYPE_NAME (type
));
538 sig
= ident_subst (IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
),
545 extern struct obstack temporary_obstack
;
546 sig
= build_java_argument_signature (type
);
547 obstack_1grow (&temporary_obstack
, '(');
548 obstack_grow (&temporary_obstack
,
549 IDENTIFIER_POINTER (sig
), IDENTIFIER_LENGTH (sig
));
550 obstack_1grow (&temporary_obstack
, ')');
552 t
= build_java_signature (TREE_TYPE (type
));
553 obstack_grow0 (&temporary_obstack
,
554 IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
));
556 sig
= get_identifier (obstack_base (&temporary_obstack
));
557 obstack_free (&temporary_obstack
,
558 obstack_base (&temporary_obstack
));
565 TYPE_SIGNATURE (type
) = sig
;
570 /* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */
573 set_java_signature (tree type
, tree sig
)
576 while (TREE_CODE (type
) == POINTER_TYPE
)
577 type
= TREE_TYPE (type
);
578 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type
);
579 old_sig
= TYPE_SIGNATURE (type
);
580 if (old_sig
!= NULL_TREE
&& old_sig
!= sig
)
582 TYPE_SIGNATURE (type
) = sig
;
583 #if 0 /* careful about METHOD_TYPE */
584 if (IDENTIFIER_SIGNATURE_TYPE (sig
) == NULL_TREE
&& TREE_PERMANENT (type
))
585 IDENTIFIER_SIGNATURE_TYPE (sig
) = type
;
589 /* Search in SEARCHED_CLASS and its superclasses for a method matching
590 METHOD_NAME and signature METHOD_SIGNATURE. This function will
591 only search for methods declared in the class hierarchy; interfaces
592 will not be considered. Returns NULL_TREE if the method is not
595 lookup_argument_method (tree searched_class
, tree method_name
,
596 tree method_signature
)
598 return lookup_do (searched_class
, 0,
599 method_name
, method_signature
,
600 build_java_argument_signature
);
603 /* Like lookup_argument_method, but lets the caller set any flags
606 lookup_argument_method_generic (tree searched_class
, tree method_name
,
607 tree method_signature
, int flags
)
609 return lookup_do (searched_class
, flags
,
610 method_name
, method_signature
,
611 build_java_argument_signature
);
615 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
616 matching METHOD_NAME and signature METHOD_SIGNATURE. Return a
617 FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast
618 lookup_argument_method, which ignores return type.) If
619 SEARCHED_CLASS is an interface, search it too. */
621 lookup_java_method (tree searched_class
, tree method_name
,
622 tree method_signature
)
624 return lookup_do (searched_class
, SEARCH_INTERFACE
, method_name
,
625 method_signature
, build_java_signature
);
628 /* Return true iff KLASS (or its ancestors) has a method METHOD_NAME. */
630 has_method (tree klass
, tree method_name
)
632 return lookup_do (klass
, SEARCH_INTERFACE
,
633 method_name
, NULL_TREE
,
634 build_null_signature
) != NULL_TREE
;
637 /* Search in class SEARCHED_CLASS, but not its superclasses, for a
638 method matching METHOD_NAME and signature SIGNATURE. A private
639 helper for lookup_do. */
641 shallow_find_method (tree searched_class
, int flags
, tree method_name
,
642 tree signature
, tree (*signature_builder
) (tree
))
645 for (method
= TYPE_METHODS (searched_class
);
646 method
!= NULL_TREE
; method
= TREE_CHAIN (method
))
648 tree method_sig
= (*signature_builder
) (TREE_TYPE (method
));
649 if (DECL_NAME (method
) == method_name
&& method_sig
== signature
)
651 /* If the caller requires a visible method, then we
652 skip invisible methods here. */
653 if (! (flags
& SEARCH_VISIBLE
)
654 || ! METHOD_INVISIBLE (method
))
661 /* Search in the superclasses of SEARCHED_CLASS for a method matching
662 METHOD_NAME and signature SIGNATURE. A private helper for
665 find_method_in_superclasses (tree searched_class
, int flags
,
666 tree method_name
, tree signature
,
667 tree (*signature_builder
) (tree
))
670 for (klass
= CLASSTYPE_SUPER (searched_class
); klass
!= NULL_TREE
;
671 klass
= CLASSTYPE_SUPER (klass
))
674 method
= shallow_find_method (klass
, flags
, method_name
,
675 signature
, signature_builder
);
676 if (method
!= NULL_TREE
)
683 /* Search in the interfaces of SEARCHED_CLASS and its superinterfaces
684 for a method matching METHOD_NAME and signature SIGNATURE. A
685 private helper for lookup_do. */
687 find_method_in_interfaces (tree searched_class
, int flags
, tree method_name
,
688 tree signature
, tree (*signature_builder
) (tree
))
691 tree binfo
, base_binfo
;
693 for (binfo
= TYPE_BINFO (searched_class
), i
= 1;
694 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); i
++)
696 tree iclass
= BINFO_TYPE (base_binfo
);
699 /* If the superinterface hasn't been loaded yet, do so now. */
700 if (!CLASS_LOADED_P (iclass
))
701 load_class (iclass
, 1);
703 /* First, we look in ICLASS. If that doesn't work we'll
704 recursively look through all its superinterfaces. */
705 method
= shallow_find_method (iclass
, flags
, method_name
,
706 signature
, signature_builder
);
707 if (method
!= NULL_TREE
)
710 method
= find_method_in_interfaces
711 (iclass
, flags
, method_name
, signature
, signature_builder
);
712 if (method
!= NULL_TREE
)
720 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
721 matching METHOD_NAME and signature SIGNATURE. FLAGS control some
722 parameters of the search.
724 SEARCH_INTERFACE means also search interfaces and superinterfaces
727 SEARCH_SUPER means skip SEARCHED_CLASS and start with its
730 SEARCH_VISIBLE means skip methods for which METHOD_INVISIBLE is
733 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
734 used on method candidates to build their (sometimes partial)
737 lookup_do (tree searched_class
, int flags
, tree method_name
,
738 tree signature
, tree (*signature_builder
) (tree
))
741 tree orig_class
= searched_class
;
743 if (searched_class
== NULL_TREE
)
746 if (flags
& SEARCH_SUPER
)
748 searched_class
= CLASSTYPE_SUPER (searched_class
);
749 if (searched_class
== NULL_TREE
)
753 /* First look in our own methods. */
754 method
= shallow_find_method (searched_class
, flags
, method_name
,
755 signature
, signature_builder
);
759 /* Then look in our superclasses. */
760 if (! CLASS_INTERFACE (TYPE_NAME (searched_class
)))
761 method
= find_method_in_superclasses (searched_class
, flags
, method_name
,
762 signature
, signature_builder
);
766 /* If that doesn't work, look in our interfaces. */
767 if (flags
& SEARCH_INTERFACE
)
768 method
= find_method_in_interfaces (orig_class
, flags
, method_name
,
769 signature
, signature_builder
);
774 /* Search in class CLAS for a constructor matching METHOD_SIGNATURE.
775 Return a FUNCTION_DECL on success, or NULL_TREE if none found. */
778 lookup_java_constructor (tree clas
, tree method_signature
)
780 tree method
= TYPE_METHODS (clas
);
781 for ( ; method
!= NULL_TREE
; method
= TREE_CHAIN (method
))
783 tree method_sig
= build_java_signature (TREE_TYPE (method
));
784 if (DECL_CONSTRUCTOR_P (method
) && method_sig
== method_signature
)
790 /* Return a type which is the Binary Numeric Promotion of the pair T1,
791 T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric
792 Promotion. It assumes that both T1 and T2 are eligible to BNP. */
795 binary_numeric_promotion (tree t1
, tree t2
, tree
*exp1
, tree
*exp2
)
797 if (t1
== double_type_node
|| t2
== double_type_node
)
799 if (t1
!= double_type_node
)
800 *exp1
= convert (double_type_node
, *exp1
);
801 if (t2
!= double_type_node
)
802 *exp2
= convert (double_type_node
, *exp2
);
803 return double_type_node
;
805 if (t1
== float_type_node
|| t2
== float_type_node
)
807 if (t1
!= float_type_node
)
808 *exp1
= convert (float_type_node
, *exp1
);
809 if (t2
!= float_type_node
)
810 *exp2
= convert (float_type_node
, *exp2
);
811 return float_type_node
;
813 if (t1
== long_type_node
|| t2
== long_type_node
)
815 if (t1
!= long_type_node
)
816 *exp1
= convert (long_type_node
, *exp1
);
817 if (t2
!= long_type_node
)
818 *exp2
= convert (long_type_node
, *exp2
);
819 return long_type_node
;
822 if (t1
!= int_type_node
)
823 *exp1
= convert (int_type_node
, *exp1
);
824 if (t2
!= int_type_node
)
825 *exp2
= convert (int_type_node
, *exp2
);
826 return int_type_node
;