00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "config.h"
00029 #include "system.h"
00030 #include "tree.h"
00031 #include "obstack.h"
00032 #include "flags.h"
00033 #include "java-tree.h"
00034 #include "jcf.h"
00035 #include "convert.h"
00036 #include "toplev.h"
00037 #include "ggc.h"
00038
00039 static tree convert_ieee_real_to_integer PARAMS ((tree, tree));
00040 static tree parse_signature_type PARAMS ((const unsigned char **,
00041 const unsigned char *));
00042 static tree lookup_do PARAMS ((tree, tree, tree, tree, tree (*)(tree)));
00043 static tree build_null_signature PARAMS ((tree));
00044
00045 tree * type_map;
00046 extern struct obstack permanent_obstack;
00047
00048
00049
00050 void
00051 set_local_type (slot, type)
00052 int slot;
00053 tree type;
00054 {
00055 int max_locals = DECL_MAX_LOCALS(current_function_decl);
00056 int nslots = TYPE_IS_WIDE (type) ? 2 : 1;
00057
00058 if (slot < 0 || slot + nslots - 1 >= max_locals)
00059 abort ();
00060
00061 type_map[slot] = type;
00062 while (--nslots > 0)
00063 type_map[++slot] = void_type_node;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 static tree
00081 convert_ieee_real_to_integer (type, expr)
00082 tree type, expr;
00083 {
00084 tree result;
00085 expr = save_expr (expr);
00086
00087 result = build (COND_EXPR, type,
00088 build (NE_EXPR, boolean_type_node, expr, expr),
00089 convert (type, integer_zero_node),
00090 convert_to_integer (type, expr));
00091
00092 result = build (COND_EXPR, type,
00093 build (LE_EXPR, boolean_type_node, expr,
00094 convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
00095 TYPE_MIN_VALUE (type),
00096 result);
00097
00098 result = build (COND_EXPR, type,
00099 build (GE_EXPR, boolean_type_node, expr,
00100 convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),
00101 TYPE_MAX_VALUE (type),
00102 result);
00103
00104 return result;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113 tree
00114 convert (type, expr)
00115 tree type, expr;
00116 {
00117 register enum tree_code code = TREE_CODE (type);
00118
00119 if (!expr)
00120 return error_mark_node;
00121
00122 if (do_not_fold)
00123 return build1 (NOP_EXPR, type, expr);
00124
00125 if (type == TREE_TYPE (expr)
00126 || TREE_CODE (expr) == ERROR_MARK)
00127 return expr;
00128 if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
00129 return error_mark_node;
00130 if (code == VOID_TYPE)
00131 return build1 (CONVERT_EXPR, type, expr);
00132 if (code == BOOLEAN_TYPE)
00133 return fold (convert_to_boolean (type, expr));
00134 if (code == INTEGER_TYPE)
00135 {
00136 if (! flag_unsafe_math_optimizations
00137 && ! flag_emit_class_files
00138 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
00139 && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
00140 return fold (convert_ieee_real_to_integer (type, expr));
00141 else
00142 return fold (convert_to_integer (type, expr));
00143 }
00144 if (code == REAL_TYPE)
00145 return fold (convert_to_real (type, expr));
00146 if (code == CHAR_TYPE)
00147 return fold (convert_to_char (type, expr));
00148 if (code == POINTER_TYPE)
00149 return fold (convert_to_pointer (type, expr));
00150 error ("conversion to non-scalar type requested");
00151 return error_mark_node;
00152 }
00153
00154
00155 tree
00156 convert_to_char (type, expr)
00157 tree type, expr;
00158 {
00159 return build1 (NOP_EXPR, type, expr);
00160 }
00161
00162 tree
00163 convert_to_boolean (type, expr)
00164 tree type, expr;
00165 {
00166 return build1 (NOP_EXPR, type, expr);
00167 }
00168
00169
00170
00171
00172
00173 void
00174 incomplete_type_error (value, type)
00175 tree value ATTRIBUTE_UNUSED;
00176 tree type ATTRIBUTE_UNUSED;
00177 {
00178 error ("internal error - use of undefined type");
00179 }
00180
00181
00182
00183
00184
00185 tree
00186 type_for_mode (mode, unsignedp)
00187 enum machine_mode mode;
00188 int unsignedp;
00189 {
00190 if (mode == TYPE_MODE (int_type_node))
00191 return unsignedp ? unsigned_int_type_node : int_type_node;
00192 if (mode == TYPE_MODE (long_type_node))
00193 return unsignedp ? unsigned_long_type_node : long_type_node;
00194 if (mode == TYPE_MODE (short_type_node))
00195 return unsignedp ? unsigned_short_type_node : short_type_node;
00196 if (mode == TYPE_MODE (byte_type_node))
00197 return unsignedp ? unsigned_byte_type_node : byte_type_node;
00198 if (mode == TYPE_MODE (float_type_node))
00199 return float_type_node;
00200 if (mode == TYPE_MODE (double_type_node))
00201 return double_type_node;
00202
00203 return 0;
00204 }
00205
00206
00207
00208
00209 tree
00210 type_for_size (bits, unsignedp)
00211 unsigned bits;
00212 int unsignedp;
00213 {
00214 if (bits <= TYPE_PRECISION (byte_type_node))
00215 return unsignedp ? unsigned_byte_type_node : byte_type_node;
00216 if (bits <= TYPE_PRECISION (short_type_node))
00217 return unsignedp ? unsigned_short_type_node : short_type_node;
00218 if (bits <= TYPE_PRECISION (int_type_node))
00219 return unsignedp ? unsigned_int_type_node : int_type_node;
00220 if (bits <= TYPE_PRECISION (long_type_node))
00221 return unsignedp ? unsigned_long_type_node : long_type_node;
00222 return 0;
00223 }
00224
00225
00226
00227
00228 tree
00229 signed_or_unsigned_type (unsignedp, type)
00230 int unsignedp;
00231 tree type;
00232 {
00233 if (! INTEGRAL_TYPE_P (type))
00234 return type;
00235 if (TYPE_PRECISION (type) == TYPE_PRECISION (int_type_node))
00236 return unsignedp ? unsigned_int_type_node : int_type_node;
00237 if (TYPE_PRECISION (type) == TYPE_PRECISION (byte_type_node))
00238 return unsignedp ? unsigned_byte_type_node : byte_type_node;
00239 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_type_node))
00240 return unsignedp ? unsigned_short_type_node : short_type_node;
00241 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_type_node))
00242 return unsignedp ? unsigned_long_type_node : long_type_node;
00243 return type;
00244 }
00245
00246
00247
00248 tree
00249 signed_type (type)
00250 tree type;
00251 {
00252 return signed_or_unsigned_type (0, type);
00253 }
00254
00255
00256
00257 tree
00258 unsigned_type (type)
00259 tree type;
00260 {
00261 return signed_or_unsigned_type (1, type);
00262
00263 }
00264
00265
00266
00267
00268
00269 int
00270 mark_addressable (exp)
00271 tree exp;
00272 {
00273 register tree x = exp;
00274 while (1)
00275 switch (TREE_CODE (x))
00276 {
00277 case ADDR_EXPR:
00278 case COMPONENT_REF:
00279 case ARRAY_REF:
00280 case REALPART_EXPR:
00281 case IMAGPART_EXPR:
00282 x = TREE_OPERAND (x, 0);
00283 break;
00284
00285 case TRUTH_ANDIF_EXPR:
00286 case TRUTH_ORIF_EXPR:
00287 case COMPOUND_EXPR:
00288 x = TREE_OPERAND (x, 1);
00289 break;
00290
00291 case COND_EXPR:
00292 return mark_addressable (TREE_OPERAND (x, 1))
00293 & mark_addressable (TREE_OPERAND (x, 2));
00294
00295 case CONSTRUCTOR:
00296 TREE_ADDRESSABLE (x) = 1;
00297 return 1;
00298
00299 case INDIRECT_REF:
00300
00301
00302 if (TREE_CODE (TREE_OPERAND (x, 0)) == NOP_EXPR
00303 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (x, 0), 0)) == ADDR_EXPR)
00304 {
00305 x = TREE_OPERAND (TREE_OPERAND (x, 0), 0);
00306 break;
00307 }
00308 if (TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR)
00309 {
00310 x = TREE_OPERAND (x, 0);
00311 break;
00312 }
00313 return 1;
00314
00315 case VAR_DECL:
00316 case CONST_DECL:
00317 case PARM_DECL:
00318 case RESULT_DECL:
00319 case FUNCTION_DECL:
00320 TREE_ADDRESSABLE (x) = 1;
00321 #if 0
00322 if (DECL_CONTEXT (x) == 0)
00323 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
00324 #endif
00325
00326 default:
00327 return 1;
00328 }
00329 }
00330
00331
00332
00333 int
00334 is_array_type_p (type)
00335 tree type;
00336 {
00337 return TREE_CODE (type) == POINTER_TYPE
00338 && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
00339 && TYPE_ARRAY_P (TREE_TYPE (type));
00340 }
00341
00342
00343
00344
00345 HOST_WIDE_INT
00346 java_array_type_length (array_type)
00347 tree array_type;
00348 {
00349 tree arfld;
00350 if (TREE_CODE (array_type) == POINTER_TYPE)
00351 array_type = TREE_TYPE (array_type);
00352 arfld = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type)));
00353 if (arfld != NULL_TREE)
00354 {
00355 tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld));
00356 if (index_type != NULL_TREE)
00357 {
00358 tree high = TYPE_MAX_VALUE (index_type);
00359 if (TREE_CODE (high) == INTEGER_CST)
00360 return TREE_INT_CST_LOW (high) + 1;
00361 }
00362 }
00363 return -1;
00364 }
00365
00366
00367
00368
00369
00370
00371 tree
00372 build_prim_array_type (element_type, length)
00373 tree element_type;
00374 HOST_WIDE_INT length;
00375 {
00376 tree index = NULL;
00377
00378 if (length != -1)
00379 {
00380 tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
00381 TREE_TYPE (max_index) = sizetype;
00382 index = build_index_type (max_index);
00383 }
00384 return build_array_type (element_type, index);
00385 }
00386
00387
00388
00389
00390
00391 tree
00392 build_java_array_type (element_type, length)
00393 tree element_type;
00394 HOST_WIDE_INT length;
00395 {
00396 tree sig, t, fld, atype, arfld;
00397 char buf[12];
00398 tree elsig = build_java_signature (element_type);
00399 tree el_name = element_type;
00400 buf[0] = '[';
00401 if (length >= 0)
00402 sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length);
00403 else
00404 buf[1] = '\0';
00405 sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
00406 buf, 0, 0, "");
00407 t = IDENTIFIER_SIGNATURE_TYPE (sig);
00408 if (t != NULL_TREE)
00409 return TREE_TYPE (t);
00410 t = make_class ();
00411 IDENTIFIER_SIGNATURE_TYPE (sig) = build_pointer_type (t);
00412 TYPE_ARRAY_P (t) = 1;
00413
00414 if (TREE_CODE (el_name) == POINTER_TYPE)
00415 el_name = TREE_TYPE (el_name);
00416 el_name = TYPE_NAME (el_name);
00417 if (TREE_CODE (el_name) == TYPE_DECL)
00418 el_name = DECL_NAME (el_name);
00419 TYPE_NAME (t) = build_decl (TYPE_DECL,
00420 identifier_subst (el_name, "", '.', '.', "[]"),
00421 t);
00422
00423 set_java_signature (t, sig);
00424 set_super_info (0, t, object_type_node, 0);
00425 if (TREE_CODE (element_type) == RECORD_TYPE)
00426 element_type = promote_type (element_type);
00427 TYPE_ARRAY_ELEMENT (t) = element_type;
00428
00429
00430 fld = build_decl (FIELD_DECL, get_identifier ("length"), int_type_node);
00431 TYPE_FIELDS (t) = fld;
00432 DECL_CONTEXT (fld) = t;
00433 FIELD_PUBLIC (fld) = 1;
00434 FIELD_FINAL (fld) = 1;
00435 TREE_READONLY (fld) = 1;
00436
00437 atype = build_prim_array_type (element_type, length);
00438 arfld = build_decl (FIELD_DECL, get_identifier ("data"), atype);
00439 DECL_CONTEXT (arfld) = t;
00440 TREE_CHAIN (fld) = arfld;
00441 DECL_ALIGN (arfld) = TYPE_ALIGN (element_type);
00442
00443
00444
00445
00446 push_super_field (t, object_type_node);
00447 layout_type (t);
00448
00449 return t;
00450 }
00451
00452
00453
00454 tree
00455 promote_type (type)
00456 tree type;
00457 {
00458 switch (TREE_CODE (type))
00459 {
00460 case RECORD_TYPE:
00461 return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
00462 case BOOLEAN_TYPE:
00463 if (type == boolean_type_node)
00464 return promoted_boolean_type_node;
00465 goto handle_int;
00466 case CHAR_TYPE:
00467 if (type == char_type_node)
00468 return promoted_char_type_node;
00469 goto handle_int;
00470 case INTEGER_TYPE:
00471 handle_int:
00472 if (TYPE_PRECISION (type) < TYPE_PRECISION (int_type_node))
00473 {
00474 if (type == short_type_node)
00475 return promoted_short_type_node;
00476 if (type == byte_type_node)
00477 return promoted_byte_type_node;
00478 return int_type_node;
00479 }
00480
00481 default:
00482 return type;
00483 }
00484 }
00485
00486
00487
00488
00489 static tree
00490 parse_signature_type (ptr, limit)
00491 const unsigned char **ptr, *limit;
00492 {
00493 tree type;
00494
00495 if (*ptr >= limit)
00496 abort ();
00497
00498 switch (**ptr)
00499 {
00500 case 'B': (*ptr)++; return byte_type_node;
00501 case 'C': (*ptr)++; return char_type_node;
00502 case 'D': (*ptr)++; return double_type_node;
00503 case 'F': (*ptr)++; return float_type_node;
00504 case 'S': (*ptr)++; return short_type_node;
00505 case 'I': (*ptr)++; return int_type_node;
00506 case 'J': (*ptr)++; return long_type_node;
00507 case 'Z': (*ptr)++; return boolean_type_node;
00508 case 'V': (*ptr)++; return void_type_node;
00509 case '[':
00510 for ((*ptr)++; (*ptr) < limit && ISDIGIT (**ptr); ) (*ptr)++;
00511 type = parse_signature_type (ptr, limit);
00512 type = build_java_array_type (type, -1);
00513 break;
00514 case 'L':
00515 {
00516 const unsigned char *start = ++(*ptr);
00517 register const unsigned char *str = start;
00518 for ( ; ; str++)
00519 {
00520 if (str >= limit)
00521 abort ();
00522 if (*str == ';')
00523 break;
00524 }
00525 *ptr = str+1;
00526 type = lookup_class (unmangle_classname (start, str - start));
00527 break;
00528 }
00529 default:
00530 abort ();
00531 }
00532 return promote_type (type);
00533 }
00534
00535
00536
00537
00538
00539 tree
00540 parse_signature_string (sig_string, sig_length)
00541 const unsigned char *sig_string;
00542 int sig_length;
00543 {
00544 tree result_type;
00545 const unsigned char *str = sig_string;
00546 const unsigned char *limit = str + sig_length;
00547
00548 if (str < limit && str[0] == '(')
00549 {
00550 tree argtype_list = NULL_TREE;
00551 str++;
00552 while (str < limit && str[0] != ')')
00553 {
00554 tree argtype = parse_signature_type (&str, limit);
00555 argtype_list = tree_cons (NULL_TREE, argtype, argtype_list);
00556 }
00557 if (str++, str >= limit)
00558 abort ();
00559 result_type = parse_signature_type (&str, limit);
00560 argtype_list = chainon (nreverse (argtype_list), end_params_node);
00561 result_type = build_function_type (result_type, argtype_list);
00562 }
00563 else
00564 result_type = parse_signature_type (&str, limit);
00565 if (str != limit)
00566 error ("junk at end of signature string");
00567 return result_type;
00568 }
00569
00570
00571
00572
00573
00574 tree
00575 get_type_from_signature (tree signature)
00576 {
00577 const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature);
00578 int len = IDENTIFIER_LENGTH (signature);
00579 tree type;
00580
00581 if (len <= 1)
00582 return parse_signature_string (sig, len);
00583 type = IDENTIFIER_SIGNATURE_TYPE (signature);
00584 if (type == NULL_TREE)
00585 {
00586 type = parse_signature_string (sig, len);
00587 IDENTIFIER_SIGNATURE_TYPE (signature) = type;
00588 }
00589 return type;
00590 }
00591
00592
00593
00594 static tree
00595 build_null_signature (type)
00596 tree type ATTRIBUTE_UNUSED;
00597 {
00598 return NULL_TREE;
00599 }
00600
00601
00602
00603 tree
00604 build_java_argument_signature (type)
00605 tree type;
00606 {
00607 extern struct obstack temporary_obstack;
00608 tree sig = TYPE_ARGUMENT_SIGNATURE (type);
00609 if (sig == NULL_TREE)
00610 {
00611 tree args = TYPE_ARG_TYPES (type);
00612 if (TREE_CODE (type) == METHOD_TYPE)
00613 args = TREE_CHAIN (args);
00614 for (; args != end_params_node; args = TREE_CHAIN (args))
00615 {
00616 tree t = build_java_signature (TREE_VALUE (args));
00617 obstack_grow (&temporary_obstack,
00618 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
00619 }
00620 obstack_1grow (&temporary_obstack, '\0');
00621
00622 sig = get_identifier (obstack_base (&temporary_obstack));
00623 TYPE_ARGUMENT_SIGNATURE (type) = sig;
00624 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
00625 }
00626 return sig;
00627 }
00628
00629
00630
00631 tree
00632 build_java_signature (type)
00633 tree type;
00634 {
00635 tree sig, t;
00636 while (TREE_CODE (type) == POINTER_TYPE)
00637 type = TREE_TYPE (type);
00638 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
00639 sig = TYPE_SIGNATURE (type);
00640 if (sig == NULL_TREE)
00641 {
00642 char sg[2];
00643 switch (TREE_CODE (type))
00644 {
00645 case BOOLEAN_TYPE: sg[0] = 'Z'; goto native;
00646 case CHAR_TYPE: sg[0] = 'C'; goto native;
00647 case VOID_TYPE: sg[0] = 'V'; goto native;
00648 case INTEGER_TYPE:
00649 switch (TYPE_PRECISION (type))
00650 {
00651 case 8: sg[0] = 'B'; goto native;
00652 case 16: sg[0] = 'S'; goto native;
00653 case 32: sg[0] = 'I'; goto native;
00654 case 64: sg[0] = 'J'; goto native;
00655 default: goto bad_type;
00656 }
00657 case REAL_TYPE:
00658 switch (TYPE_PRECISION (type))
00659 {
00660 case 32: sg[0] = 'F'; goto native;
00661 case 64: sg[0] = 'D'; goto native;
00662 default: goto bad_type;
00663 }
00664 native:
00665 sg[1] = 0;
00666 sig = get_identifier (sg);
00667 break;
00668 case RECORD_TYPE:
00669 if (TYPE_ARRAY_P (type))
00670 {
00671 t = build_java_signature (TYPE_ARRAY_ELEMENT (type));
00672 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
00673 "[", 0, 0, "");
00674 }
00675 else
00676 {
00677 t = DECL_NAME (TYPE_NAME (type));
00678 sig = ident_subst (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t),
00679 "L", '.', '/', ";");
00680 }
00681 break;
00682 case METHOD_TYPE:
00683 case FUNCTION_TYPE:
00684 {
00685 extern struct obstack temporary_obstack;
00686 sig = build_java_argument_signature (type);
00687 obstack_1grow (&temporary_obstack, '(');
00688 obstack_grow (&temporary_obstack,
00689 IDENTIFIER_POINTER (sig), IDENTIFIER_LENGTH (sig));
00690 obstack_1grow (&temporary_obstack, ')');
00691
00692 t = build_java_signature (TREE_TYPE (type));
00693 obstack_grow0 (&temporary_obstack,
00694 IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
00695
00696 sig = get_identifier (obstack_base (&temporary_obstack));
00697 obstack_free (&temporary_obstack,
00698 obstack_base (&temporary_obstack));
00699 }
00700 break;
00701 bad_type:
00702 default:
00703 abort ();
00704 }
00705 TYPE_SIGNATURE (type) = sig;
00706 }
00707 return sig;
00708 }
00709
00710
00711
00712 void
00713 set_java_signature (type, sig)
00714 tree type;
00715 tree sig;
00716 {
00717 tree old_sig;
00718 while (TREE_CODE (type) == POINTER_TYPE)
00719 type = TREE_TYPE (type);
00720 MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
00721 old_sig = TYPE_SIGNATURE (type);
00722 if (old_sig != NULL_TREE && old_sig != sig)
00723 abort ();
00724 TYPE_SIGNATURE (type) = sig;
00725 #if 0
00726 if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type))
00727 IDENTIFIER_SIGNATURE_TYPE (sig) = type;
00728 #endif
00729 }
00730
00731
00732
00733
00734
00735
00736
00737
00738 tree
00739 lookup_argument_method (searched_class, method_name, method_signature)
00740 tree searched_class, method_name, method_signature;
00741 {
00742 return lookup_do (searched_class, NULL_TREE, method_name, method_signature,
00743 build_java_argument_signature);
00744 }
00745
00746
00747
00748
00749
00750
00751
00752 tree
00753 lookup_argument_method2 (searched_class, method_name, method_signature)
00754 tree searched_class, method_name, method_signature;
00755 {
00756 return lookup_do (CLASSTYPE_SUPER (searched_class), searched_class,
00757 method_name, method_signature,
00758 build_java_argument_signature);
00759 }
00760
00761
00762
00763
00764
00765
00766
00767 tree
00768 lookup_java_method (searched_class, method_name, method_signature)
00769 tree searched_class, method_name, method_signature;
00770 {
00771 tree searched_interface;
00772
00773
00774
00775
00776
00777 searched_interface = (CLASS_INTERFACE (TYPE_NAME (searched_class)) ?
00778 searched_class : NULL_TREE);
00779 return lookup_do (searched_class, searched_interface, method_name,
00780 method_signature, build_java_signature);
00781 }
00782
00783
00784
00785 int
00786 has_method (class, method_name)
00787 tree class;
00788 tree method_name;
00789 {
00790 return lookup_do (class, class, method_name,
00791 NULL_TREE, build_null_signature) != NULL_TREE;
00792 }
00793
00794
00795
00796
00797
00798
00799
00800
00801 static tree
00802 lookup_do (searched_class, searched_interface, method_name, signature, signature_builder)
00803 tree searched_class, searched_interface, method_name, signature;
00804 tree (*signature_builder) PARAMS ((tree));
00805 {
00806 tree method;
00807
00808 if (searched_interface)
00809 {
00810 int i;
00811 int interface_len =
00812 TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (searched_interface)) - 1;
00813
00814 for (i = interface_len; i > 0; i--)
00815 {
00816 tree child =
00817 TREE_VEC_ELT (TYPE_BINFO_BASETYPES (searched_interface), i);
00818 tree iclass = BINFO_TYPE (child);
00819
00820
00821 if (CLASS_FROM_SOURCE_P (iclass))
00822 safe_layout_class (iclass);
00823 else if (!CLASS_LOADED_P (iclass))
00824 load_class (iclass, 1);
00825
00826 for (method = TYPE_METHODS (iclass);
00827 method != NULL_TREE; method = TREE_CHAIN (method))
00828 {
00829 tree method_sig = (*signature_builder) (TREE_TYPE (method));
00830
00831 if (DECL_NAME (method) == method_name && method_sig == signature)
00832 return method;
00833 }
00834
00835
00836 if (CLASS_INTERFACE (TYPE_NAME (iclass)))
00837 {
00838 method = lookup_do (iclass, iclass, method_name,
00839 signature, signature_builder);
00840 if (method != NULL_TREE)
00841 return method;
00842 }
00843 }
00844 }
00845
00846 while (searched_class != NULL_TREE)
00847 {
00848 for (method = TYPE_METHODS (searched_class);
00849 method != NULL_TREE; method = TREE_CHAIN (method))
00850 {
00851 tree method_sig = (*signature_builder) (TREE_TYPE (method));
00852 if (DECL_NAME (method) == method_name && method_sig == signature)
00853 return method;
00854 }
00855 searched_class = CLASSTYPE_SUPER (searched_class);
00856 }
00857
00858 return NULL_TREE;
00859 }
00860
00861
00862
00863
00864 tree
00865 lookup_java_constructor (clas, method_signature)
00866 tree clas, method_signature;
00867 {
00868 tree method = TYPE_METHODS (clas);
00869 for ( ; method != NULL_TREE; method = TREE_CHAIN (method))
00870 {
00871 tree method_sig = build_java_signature (TREE_TYPE (method));
00872 if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature)
00873 return method;
00874 }
00875 return NULL_TREE;
00876 }
00877
00878
00879
00880
00881
00882 tree
00883 binary_numeric_promotion (t1, t2, exp1, exp2)
00884 tree t1;
00885 tree t2;
00886 tree *exp1;
00887 tree *exp2;
00888 {
00889 if (t1 == double_type_node || t2 == double_type_node)
00890 {
00891 if (t1 != double_type_node)
00892 *exp1 = convert (double_type_node, *exp1);
00893 if (t2 != double_type_node)
00894 *exp2 = convert (double_type_node, *exp2);
00895 return double_type_node;
00896 }
00897 if (t1 == float_type_node || t2 == float_type_node)
00898 {
00899 if (t1 != float_type_node)
00900 *exp1 = convert (float_type_node, *exp1);
00901 if (t2 != float_type_node)
00902 *exp2 = convert (float_type_node, *exp2);
00903 return float_type_node;
00904 }
00905 if (t1 == long_type_node || t2 == long_type_node)
00906 {
00907 if (t1 != long_type_node)
00908 *exp1 = convert (long_type_node, *exp1);
00909 if (t2 != long_type_node)
00910 *exp2 = convert (long_type_node, *exp2);
00911 return long_type_node;
00912 }
00913
00914 if (t1 != int_type_node)
00915 *exp1 = convert (int_type_node, *exp1);
00916 if (t2 != int_type_node)
00917 *exp2 = convert (int_type_node, *exp2);
00918 return int_type_node;
00919 }