1 /* Handle types for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1996-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC 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 3, or (at your option)
11 GCC 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 GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>.
20 Java and all Java-based marks are trademarks or registered trademarks
21 of Sun Microsystems, Inc. in the United States and other countries.
22 The Free Software Foundation is independent of Sun Microsystems, Inc. */
24 /* Written by Per Bothner <bothner@cygnus.com> */
28 #include "coretypes.h"
32 #include "double-int.h"
40 #include "fold-const.h"
41 #include "stor-layout.h"
42 #include "stringpool.h"
45 #include "java-tree.h"
48 #include "diagnostic-core.h"
51 static tree
convert_ieee_real_to_integer (tree
, tree
);
52 static tree
parse_signature_type (const unsigned char **,
53 const unsigned char *);
54 static tree
lookup_do (tree
, int, tree
, tree
, tree (*)(tree
));
55 static tree
build_null_signature (tree
);
59 /* Set the type of the local variable with index SLOT to TYPE. */
62 set_local_type (int slot
, tree type
)
64 int max_locals
= DECL_MAX_LOCALS(current_function_decl
);
65 int nslots
= TYPE_IS_WIDE (type
) ? 2 : 1;
67 gcc_assert (slot
>= 0 && (slot
+ nslots
- 1 < max_locals
));
69 type_map
[slot
] = type
;
71 type_map
[++slot
] = void_type_node
;
74 /* Convert an IEEE real to an integer type. The result of such a
75 conversion when the source operand is a NaN isn't defined by
76 IEEE754, but by the Java language standard: it must be zero. Also,
77 overflows must be clipped to within range. This conversion
78 produces something like:
80 ((expr >= (float)MAX_INT)
82 : ((expr <= (float)MIN_INT)
89 convert_ieee_real_to_integer (tree type
, tree expr
)
92 expr
= save_expr (expr
);
94 result
= fold_build3 (COND_EXPR
, type
,
95 fold_build2 (NE_EXPR
, boolean_type_node
, expr
, expr
),
96 convert (type
, integer_zero_node
),
97 convert_to_integer (type
, expr
));
99 result
= fold_build3 (COND_EXPR
, type
,
100 fold_build2 (LE_EXPR
, boolean_type_node
, expr
,
101 convert (TREE_TYPE (expr
),
102 TYPE_MIN_VALUE (type
))),
103 TYPE_MIN_VALUE (type
),
106 result
= fold_build3 (COND_EXPR
, type
,
107 fold_build2 (GE_EXPR
, boolean_type_node
, expr
,
108 convert (TREE_TYPE (expr
),
109 TYPE_MAX_VALUE (type
))),
110 TYPE_MAX_VALUE (type
),
116 /* Create an expression whose value is that of EXPR,
117 converted to type TYPE. The TREE_TYPE of the value
118 is always TYPE. This function implements all reasonable
119 conversions; callers should filter out those that are
120 not permitted by the language being compiled. */
123 convert (tree type
, tree expr
)
125 enum tree_code code
= TREE_CODE (type
);
128 return error_mark_node
;
130 if (type
== TREE_TYPE (expr
)
131 || TREE_CODE (expr
) == ERROR_MARK
)
133 if (TREE_CODE (TREE_TYPE (expr
)) == ERROR_MARK
)
134 return error_mark_node
;
135 if (code
== VOID_TYPE
)
136 return build1 (CONVERT_EXPR
, type
, expr
);
137 if (code
== BOOLEAN_TYPE
)
138 return fold_convert (type
, expr
);
139 if (code
== INTEGER_TYPE
)
141 if (type
== char_type_node
|| type
== promoted_char_type_node
)
142 return fold_convert (type
, expr
);
143 if ((really_constant_p (expr
) || ! flag_unsafe_math_optimizations
)
144 && TREE_CODE (TREE_TYPE (expr
)) == REAL_TYPE
)
145 return convert_ieee_real_to_integer (type
, expr
);
148 /* fold very helpfully sets the overflow status if a type
149 overflows in a narrowing integer conversion, but Java
151 tree tmp
= fold (convert_to_integer (type
, expr
));
152 if (TREE_CODE (tmp
) == INTEGER_CST
)
153 TREE_OVERFLOW (tmp
) = 0;
157 if (code
== REAL_TYPE
)
158 return fold (convert_to_real (type
, expr
));
159 if (code
== POINTER_TYPE
)
160 return fold (convert_to_pointer (type
, expr
));
161 error ("conversion to non-scalar type requested");
162 return error_mark_node
;
166 /* Return a data type that has machine mode MODE.
167 If the mode is an integer,
168 then UNSIGNEDP selects between signed and unsigned types. */
171 java_type_for_mode (machine_mode mode
, int unsignedp
)
173 if (mode
== TYPE_MODE (int_type_node
))
174 return unsignedp
? unsigned_int_type_node
: int_type_node
;
175 if (mode
== TYPE_MODE (long_type_node
))
176 return unsignedp
? unsigned_long_type_node
: long_type_node
;
177 if (mode
== TYPE_MODE (short_type_node
))
178 return unsignedp
? unsigned_short_type_node
: short_type_node
;
179 if (mode
== TYPE_MODE (byte_type_node
))
180 return unsignedp
? unsigned_byte_type_node
: byte_type_node
;
181 if (mode
== TYPE_MODE (float_type_node
))
182 return float_type_node
;
183 if (mode
== TYPE_MODE (double_type_node
))
184 return double_type_node
;
189 /* Return an integer type with BITS bits of precision,
190 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
193 java_type_for_size (unsigned bits
, int unsignedp
)
195 if (bits
<= TYPE_PRECISION (byte_type_node
))
196 return unsignedp
? unsigned_byte_type_node
: byte_type_node
;
197 if (bits
<= TYPE_PRECISION (short_type_node
))
198 return unsignedp
? unsigned_short_type_node
: short_type_node
;
199 if (bits
<= TYPE_PRECISION (int_type_node
))
200 return unsignedp
? unsigned_int_type_node
: int_type_node
;
201 if (bits
<= TYPE_PRECISION (long_type_node
))
202 return unsignedp
? unsigned_long_type_node
: long_type_node
;
206 /* Thorough checking of the arrayness of TYPE. */
209 is_array_type_p (tree type
)
211 return TREE_CODE (type
) == POINTER_TYPE
212 && TREE_CODE (TREE_TYPE (type
)) == RECORD_TYPE
213 && TYPE_ARRAY_P (TREE_TYPE (type
));
216 /* Return the length of a Java array type.
217 Return -1 if the length is unknown or non-constant. */
220 java_array_type_length (tree array_type
)
223 if (TREE_CODE (array_type
) == POINTER_TYPE
)
224 array_type
= TREE_TYPE (array_type
);
225 arfld
= DECL_CHAIN (DECL_CHAIN (TYPE_FIELDS (array_type
)));
226 if (arfld
!= NULL_TREE
)
228 tree index_type
= TYPE_DOMAIN (TREE_TYPE (arfld
));
229 if (index_type
!= NULL_TREE
)
231 tree high
= TYPE_MAX_VALUE (index_type
);
232 if (TREE_CODE (high
) == INTEGER_CST
)
233 return TREE_INT_CST_LOW (high
) + 1;
239 /* An array of unknown length will be ultimately given a length of
240 -2, so that we can still have `length' producing a negative value
241 even if found. This was part of an optimization aiming at removing
242 `length' from static arrays. We could restore it, FIXME. */
245 build_prim_array_type (tree element_type
, HOST_WIDE_INT length
)
251 tree max_index
= build_int_cst (sizetype
, length
- 1);
252 index
= build_index_type (max_index
);
254 return build_array_type (element_type
, index
);
257 /* Return a Java array type with a given ELEMENT_TYPE and LENGTH.
258 These are hashed (shared) using IDENTIFIER_SIGNATURE_TYPE.
259 The LENGTH is -1 if the length is unknown. */
262 build_java_array_type (tree element_type
, HOST_WIDE_INT length
)
264 tree sig
, t
, fld
, atype
, arfld
;
266 tree elsig
= build_java_signature (element_type
);
267 tree el_name
= element_type
;
270 sprintf (buf
+1, HOST_WIDE_INT_PRINT_DEC
, length
);
273 sig
= ident_subst (IDENTIFIER_POINTER (elsig
), IDENTIFIER_LENGTH (elsig
),
275 t
= IDENTIFIER_SIGNATURE_TYPE (sig
);
277 return TREE_TYPE (t
);
279 IDENTIFIER_SIGNATURE_TYPE (sig
) = build_pointer_type (t
);
280 TYPE_ARRAY_P (t
) = 1;
282 if (TREE_CODE (el_name
) == POINTER_TYPE
)
283 el_name
= TREE_TYPE (el_name
);
284 el_name
= TYPE_NAME (el_name
);
285 if (TREE_CODE (el_name
) == TYPE_DECL
)
286 el_name
= DECL_NAME (el_name
);
290 sprintf (suffix
, "[%d]", (int)length
);
292 strcpy (suffix
, "[]");
295 = build_decl (input_location
, TYPE_DECL
,
296 identifier_subst (el_name
, "", '.', '.', suffix
),
298 TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (t
)) = true;
301 set_java_signature (t
, sig
);
302 set_super_info (0, t
, object_type_node
, 0);
303 if (TREE_CODE (element_type
) == RECORD_TYPE
)
304 element_type
= promote_type (element_type
);
305 TYPE_ARRAY_ELEMENT (t
) = element_type
;
307 /* Add length pseudo-field. */
308 fld
= build_decl (input_location
,
309 FIELD_DECL
, get_identifier ("length"), int_type_node
);
310 TYPE_FIELDS (t
) = fld
;
311 DECL_CONTEXT (fld
) = t
;
312 FIELD_PUBLIC (fld
) = 1;
313 FIELD_FINAL (fld
) = 1;
314 TREE_READONLY (fld
) = 1;
316 atype
= build_prim_array_type (element_type
, length
);
317 arfld
= build_decl (input_location
,
318 FIELD_DECL
, get_identifier ("data"), atype
);
319 DECL_CONTEXT (arfld
) = t
;
320 DECL_CHAIN (fld
) = arfld
;
321 DECL_ALIGN (arfld
) = TYPE_ALIGN (element_type
);
323 /* We could layout_class, but that loads java.lang.Object prematurely.
324 * This is called by the parser, and it is a bad idea to do load_class
325 * in the middle of parsing, because of possible circularity problems. */
326 push_super_field (t
, object_type_node
);
332 /* Promote TYPE to the type actually used for fields and parameters. */
335 promote_type (tree type
)
337 switch (TREE_CODE (type
))
340 return build_pointer_type (type
);
342 if (type
== boolean_type_node
)
343 return promoted_boolean_type_node
;
346 if (type
== char_type_node
)
347 return promoted_char_type_node
;
349 if (TYPE_PRECISION (type
) < TYPE_PRECISION (int_type_node
))
351 if (type
== short_type_node
)
352 return promoted_short_type_node
;
353 if (type
== byte_type_node
)
354 return promoted_byte_type_node
;
355 return int_type_node
;
357 /* ... else fall through ... */
363 /* Parse a signature string, starting at *PTR and ending at LIMIT.
364 Return the seen TREE_TYPE, updating *PTR. */
367 parse_signature_type (const unsigned char **ptr
, const unsigned char *limit
)
370 gcc_assert (*ptr
< limit
);
374 case 'B': (*ptr
)++; return byte_type_node
;
375 case 'C': (*ptr
)++; return char_type_node
;
376 case 'D': (*ptr
)++; return double_type_node
;
377 case 'F': (*ptr
)++; return float_type_node
;
378 case 'S': (*ptr
)++; return short_type_node
;
379 case 'I': (*ptr
)++; return int_type_node
;
380 case 'J': (*ptr
)++; return long_type_node
;
381 case 'Z': (*ptr
)++; return boolean_type_node
;
382 case 'V': (*ptr
)++; return void_type_node
;
384 for ((*ptr
)++; (*ptr
) < limit
&& ISDIGIT (**ptr
); ) (*ptr
)++;
385 type
= parse_signature_type (ptr
, limit
);
386 type
= build_java_array_type (type
, -1);
390 const unsigned char *start
= ++(*ptr
);
391 const unsigned char *str
= start
;
394 gcc_assert (str
< limit
);
399 type
= lookup_class (unmangle_classname ((const char *) start
, str
- start
));
405 return promote_type (type
);
408 /* Parse a Java "mangled" signature string, starting at SIG_STRING,
409 and SIG_LENGTH bytes long.
410 Return a gcc type node. */
413 parse_signature_string (const unsigned char *sig_string
, int sig_length
)
416 const unsigned char *str
= sig_string
;
417 const unsigned char *limit
= str
+ sig_length
;
419 if (str
< limit
&& str
[0] == '(')
421 tree argtype_list
= NULL_TREE
;
423 while (str
< limit
&& str
[0] != ')')
425 tree argtype
= parse_signature_type (&str
, limit
);
426 argtype_list
= tree_cons (NULL_TREE
, argtype
, argtype_list
);
428 if (str
++, str
>= limit
)
430 result_type
= parse_signature_type (&str
, limit
);
431 argtype_list
= chainon (nreverse (argtype_list
), end_params_node
);
432 result_type
= build_function_type (result_type
, argtype_list
);
435 result_type
= parse_signature_type (&str
, limit
);
437 error ("junk at end of signature string");
441 /* Convert a signature to its type.
442 * Uses IDENTIFIER_SIGNATURE_TYPE as a cache (except for primitive types).
446 get_type_from_signature (tree signature
)
448 const unsigned char *sig
= (const unsigned char *) IDENTIFIER_POINTER (signature
);
449 int len
= IDENTIFIER_LENGTH (signature
);
451 /* Primitive types aren't cached. */
453 return parse_signature_string (sig
, len
);
454 type
= IDENTIFIER_SIGNATURE_TYPE (signature
);
455 if (type
== NULL_TREE
)
457 type
= parse_signature_string (sig
, len
);
458 IDENTIFIER_SIGNATURE_TYPE (signature
) = type
;
463 /* Ignore signature and always return null. Used by has_method. */
466 build_null_signature (tree type ATTRIBUTE_UNUSED
)
471 /* Return the signature string for the arguments of method type TYPE. */
474 build_java_argument_signature (tree type
)
476 extern struct obstack temporary_obstack
;
477 tree sig
= TYPE_ARGUMENT_SIGNATURE (type
);
478 if (sig
== NULL_TREE
)
480 tree args
= TYPE_ARG_TYPES (type
);
481 if (TREE_CODE (type
) == METHOD_TYPE
)
482 args
= TREE_CHAIN (args
); /* Skip "this" argument. */
483 for (; args
!= end_params_node
; args
= TREE_CHAIN (args
))
485 tree t
= build_java_signature (TREE_VALUE (args
));
486 obstack_grow (&temporary_obstack
,
487 IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
));
489 obstack_1grow (&temporary_obstack
, '\0');
491 sig
= get_identifier ((char *) obstack_base (&temporary_obstack
));
492 TYPE_ARGUMENT_SIGNATURE (type
) = sig
;
493 obstack_free (&temporary_obstack
, obstack_base (&temporary_obstack
));
498 /* Return the signature of the given TYPE. */
501 build_java_signature (tree type
)
504 while (TREE_CODE (type
) == POINTER_TYPE
)
505 type
= TREE_TYPE (type
);
506 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type
);
507 sig
= TYPE_SIGNATURE (type
);
508 if (sig
== NULL_TREE
)
511 switch (TREE_CODE (type
))
513 case BOOLEAN_TYPE
: sg
[0] = 'Z'; goto native
;
514 case VOID_TYPE
: sg
[0] = 'V'; goto native
;
516 if (type
== char_type_node
|| type
== promoted_char_type_node
)
521 switch (TYPE_PRECISION (type
))
523 case 8: sg
[0] = 'B'; goto native
;
524 case 16: sg
[0] = 'S'; goto native
;
525 case 32: sg
[0] = 'I'; goto native
;
526 case 64: sg
[0] = 'J'; goto native
;
527 default: goto bad_type
;
530 switch (TYPE_PRECISION (type
))
532 case 32: sg
[0] = 'F'; goto native
;
533 case 64: sg
[0] = 'D'; goto native
;
534 default: goto bad_type
;
538 sig
= get_identifier (sg
);
541 if (TYPE_ARRAY_P (type
))
543 t
= build_java_signature (TYPE_ARRAY_ELEMENT (type
));
544 sig
= ident_subst (IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
),
549 t
= DECL_NAME (TYPE_NAME (type
));
550 sig
= ident_subst (IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
),
557 extern struct obstack temporary_obstack
;
558 sig
= build_java_argument_signature (type
);
559 obstack_1grow (&temporary_obstack
, '(');
560 obstack_grow (&temporary_obstack
,
561 IDENTIFIER_POINTER (sig
), IDENTIFIER_LENGTH (sig
));
562 obstack_1grow (&temporary_obstack
, ')');
564 t
= build_java_signature (TREE_TYPE (type
));
565 obstack_grow0 (&temporary_obstack
,
566 IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
));
568 sig
= get_identifier ((char *) obstack_base (&temporary_obstack
));
569 obstack_free (&temporary_obstack
,
570 obstack_base (&temporary_obstack
));
577 TYPE_SIGNATURE (type
) = sig
;
582 /* Save signature string SIG (an IDENTIFIER_NODE) in TYPE for future use. */
585 set_java_signature (tree type
, tree sig
)
588 while (TREE_CODE (type
) == POINTER_TYPE
)
589 type
= TREE_TYPE (type
);
590 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type
);
591 old_sig
= TYPE_SIGNATURE (type
);
592 if (old_sig
!= NULL_TREE
&& old_sig
!= sig
)
594 TYPE_SIGNATURE (type
) = sig
;
595 #if 0 /* careful about METHOD_TYPE */
596 if (IDENTIFIER_SIGNATURE_TYPE (sig
) == NULL_TREE
&& TREE_PERMANENT (type
))
597 IDENTIFIER_SIGNATURE_TYPE (sig
) = type
;
601 /* Search in SEARCHED_CLASS and its superclasses for a method matching
602 METHOD_NAME and signature METHOD_SIGNATURE. This function will
603 only search for methods declared in the class hierarchy; interfaces
604 will not be considered. Returns NULL_TREE if the method is not
607 lookup_argument_method (tree searched_class
, tree method_name
,
608 tree method_signature
)
610 return lookup_do (searched_class
, 0,
611 method_name
, method_signature
,
612 build_java_argument_signature
);
615 /* Like lookup_argument_method, but lets the caller set any flags
618 lookup_argument_method_generic (tree searched_class
, tree method_name
,
619 tree method_signature
, int flags
)
621 return lookup_do (searched_class
, flags
,
622 method_name
, method_signature
,
623 build_java_argument_signature
);
627 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
628 matching METHOD_NAME and signature METHOD_SIGNATURE. Return a
629 FUNCTION_DECL on success, or NULL_TREE if none found. (Contrast
630 lookup_argument_method, which ignores return type.) If
631 SEARCHED_CLASS is an interface, search it too. */
633 lookup_java_method (tree searched_class
, tree method_name
,
634 tree method_signature
)
636 return lookup_do (searched_class
, SEARCH_INTERFACE
, method_name
,
637 method_signature
, build_java_signature
);
640 /* Return true iff KLASS (or its ancestors) has a method METHOD_NAME. */
642 has_method (tree klass
, tree method_name
)
644 return lookup_do (klass
, SEARCH_INTERFACE
,
645 method_name
, NULL_TREE
,
646 build_null_signature
) != NULL_TREE
;
649 /* Search in class SEARCHED_CLASS, but not its superclasses, for a
650 method matching METHOD_NAME and signature SIGNATURE. A private
651 helper for lookup_do. */
653 shallow_find_method (tree searched_class
, int flags
, tree method_name
,
654 tree signature
, tree (*signature_builder
) (tree
))
657 for (method
= TYPE_METHODS (searched_class
);
658 method
!= NULL_TREE
; method
= DECL_CHAIN (method
))
660 tree method_sig
= (*signature_builder
) (TREE_TYPE (method
));
661 if (DECL_NAME (method
) == method_name
&& method_sig
== signature
)
663 /* If the caller requires a visible method, then we
664 skip invisible methods here. */
665 if (! (flags
& SEARCH_VISIBLE
)
666 || ! METHOD_INVISIBLE (method
))
673 /* Search in the superclasses of SEARCHED_CLASS for a method matching
674 METHOD_NAME and signature SIGNATURE. A private helper for
677 find_method_in_superclasses (tree searched_class
, int flags
,
678 tree method_name
, tree signature
,
679 tree (*signature_builder
) (tree
))
682 for (klass
= CLASSTYPE_SUPER (searched_class
); klass
!= NULL_TREE
;
683 klass
= CLASSTYPE_SUPER (klass
))
686 method
= shallow_find_method (klass
, flags
, method_name
,
687 signature
, signature_builder
);
688 if (method
!= NULL_TREE
)
695 /* Search in the interfaces of SEARCHED_CLASS and its superinterfaces
696 for a method matching METHOD_NAME and signature SIGNATURE. A
697 private helper for lookup_do. */
699 find_method_in_interfaces (tree searched_class
, int flags
, tree method_name
,
700 tree signature
, tree (*signature_builder
) (tree
))
703 tree binfo
, base_binfo
;
705 for (binfo
= TYPE_BINFO (searched_class
), i
= 1;
706 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); i
++)
708 tree iclass
= BINFO_TYPE (base_binfo
);
711 /* If the superinterface hasn't been loaded yet, do so now. */
712 if (!CLASS_LOADED_P (iclass
))
713 load_class (iclass
, 1);
715 /* First, we look in ICLASS. If that doesn't work we'll
716 recursively look through all its superinterfaces. */
717 method
= shallow_find_method (iclass
, flags
, method_name
,
718 signature
, signature_builder
);
719 if (method
!= NULL_TREE
)
722 method
= find_method_in_interfaces
723 (iclass
, flags
, method_name
, signature
, signature_builder
);
724 if (method
!= NULL_TREE
)
732 /* Search in class SEARCHED_CLASS (and its superclasses) for a method
733 matching METHOD_NAME and signature SIGNATURE. FLAGS control some
734 parameters of the search.
736 SEARCH_INTERFACE means also search interfaces and superinterfaces
739 SEARCH_SUPER means skip SEARCHED_CLASS and start with its
742 SEARCH_VISIBLE means skip methods for which METHOD_INVISIBLE is
745 Return the matched method DECL or NULL_TREE. SIGNATURE_BUILDER is
746 used on method candidates to build their (sometimes partial)
749 lookup_do (tree searched_class
, int flags
, tree method_name
,
750 tree signature
, tree (*signature_builder
) (tree
))
753 tree orig_class
= searched_class
;
755 if (searched_class
== NULL_TREE
)
758 if (flags
& SEARCH_SUPER
)
760 searched_class
= CLASSTYPE_SUPER (searched_class
);
761 if (searched_class
== NULL_TREE
)
765 /* First look in our own methods. */
766 method
= shallow_find_method (searched_class
, flags
, method_name
,
767 signature
, signature_builder
);
771 /* Then look in our superclasses. */
772 if (! CLASS_INTERFACE (TYPE_NAME (searched_class
)))
773 method
= find_method_in_superclasses (searched_class
, flags
, method_name
,
774 signature
, signature_builder
);
778 /* If that doesn't work, look in our interfaces. */
779 if (flags
& SEARCH_INTERFACE
)
780 method
= find_method_in_interfaces (orig_class
, flags
, method_name
,
781 signature
, signature_builder
);
786 /* Search in class CLAS for a constructor matching METHOD_SIGNATURE.
787 Return a FUNCTION_DECL on success, or NULL_TREE if none found. */
790 lookup_java_constructor (tree clas
, tree method_signature
)
792 tree method
= TYPE_METHODS (clas
);
793 for ( ; method
!= NULL_TREE
; method
= DECL_CHAIN (method
))
795 tree method_sig
= build_java_signature (TREE_TYPE (method
));
796 if (DECL_CONSTRUCTOR_P (method
) && method_sig
== method_signature
)
802 /* Return a type which is the Binary Numeric Promotion of the pair T1,
803 T2 and convert EXP1 and/or EXP2. See 5.6.2 Binary Numeric
804 Promotion. It assumes that both T1 and T2 are eligible to BNP. */
807 binary_numeric_promotion (tree t1
, tree t2
, tree
*exp1
, tree
*exp2
)
809 if (t1
== double_type_node
|| t2
== double_type_node
)
811 if (t1
!= double_type_node
)
812 *exp1
= convert (double_type_node
, *exp1
);
813 if (t2
!= double_type_node
)
814 *exp2
= convert (double_type_node
, *exp2
);
815 return double_type_node
;
817 if (t1
== float_type_node
|| t2
== float_type_node
)
819 if (t1
!= float_type_node
)
820 *exp1
= convert (float_type_node
, *exp1
);
821 if (t2
!= float_type_node
)
822 *exp2
= convert (float_type_node
, *exp2
);
823 return float_type_node
;
825 if (t1
== long_type_node
|| t2
== long_type_node
)
827 if (t1
!= long_type_node
)
828 *exp1
= convert (long_type_node
, *exp1
);
829 if (t2
!= long_type_node
)
830 *exp2
= convert (long_type_node
, *exp2
);
831 return long_type_node
;
834 if (t1
!= int_type_node
)
835 *exp1
= convert (int_type_node
, *exp1
);
836 if (t2
!= int_type_node
)
837 *exp2
= convert (int_type_node
, *exp2
);
838 return int_type_node
;