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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "arch.h"
00040 ARCH_COPYRIGHT_APACHE(method, c, "$URL: https://svn.apache.org/path/name/method.c $ $Id: method.c 0 09/28/2005 dlydick $");
00041
00042
00043 #include <stdlib.h>
00044 #include <strings.h>
00045
00046 #include "jvmcfg.h"
00047 #include "cfmacros.h"
00048 #include "classfile.h"
00049 #include "exit.h"
00050 #include "jvm.h"
00051 #include "jvmclass.h"
00052 #include "linkage.h"
00053 #include "nts.h"
00054 #include "utf.h"
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 jvm_method_index method_find_by_cp_entry(jvm_class_index clsidx,
00087 cp_info_dup *mthname,
00088 cp_info_dup *mthdesc)
00089 {
00090
00091 if (jvm_class_index_null == clsidx)
00092 {
00093 exit_throw_exception(EXIT_JVM_METHOD,
00094 JVMCLASS_JAVA_LANG_INTERNALERROR);
00095 }
00096
00097
00098 CONSTANT_Utf8_info *pmthdata = PTR_THIS_CP_Utf8(mthname);
00099 if (CONSTANT_Utf8 != pmthdata->tag)
00100 {
00101 return(jvm_method_index_bad);
00102 }
00103
00104 pmthdata = PTR_THIS_CP_Utf8(mthdesc);
00105 if (CONSTANT_Utf8 != pmthdata->tag)
00106 {
00107 return(jvm_method_index_bad);
00108 }
00109
00110
00111 ClassFile *pcfs = CLASS_OBJECT_LINKAGE(clsidx)->pcfs;
00112
00113 u2 mcount = pcfs->methods_count;
00114 jvm_method_index mthidx;
00115 for (mthidx = 0; mthidx < mcount; mthidx++)
00116 {
00117
00118 if ((0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(mthname),
00119 pcfs,
00120 pcfs->methods[mthidx]->name_index))
00121 &&
00122 (0 == utf_pcfs_strcmp(PTR_THIS_CP_Utf8(mthdesc),
00123 pcfs,
00124 pcfs
00125 ->methods[mthidx]
00126 ->descriptor_index)))
00127 {
00128 return(mthidx);
00129 }
00130 }
00131
00132
00133 return(jvm_method_index_bad);
00134
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 jvm_method_index
00158 method_find_by_prchar(jvm_class_index clsidx,
00159 rchar *mthname,
00160 rchar *mthdesc)
00161 {
00162 cp_info_dup *pcip_mthname = nts_prchar2utf(mthname);
00163 cp_info_dup *pcip_mthdesc = nts_prchar2utf(mthdesc);
00164
00165 jvm_method_index rc =
00166 method_find_by_cp_entry(clsidx, pcip_mthname, pcip_mthdesc);
00167
00168 HEAP_FREE_DATA(pcip_mthname);
00169 HEAP_FREE_DATA(pcip_mthdesc);
00170
00171 return(rc);
00172
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 jvm_basetype method_return_type(jvm_class_index clsidx,
00193 jvm_constant_pool_index mthdescidx)
00194 {
00195 cp_info_dup *pcpd;
00196 CONSTANT_Utf8_info *pcpd_Utf8;
00197
00198 pcpd =CLASS_OBJECT_LINKAGE(clsidx)->pcfs->constant_pool[mthdescidx];
00199 pcpd_Utf8 = PTR_THIS_CP_Utf8(pcpd);
00200
00201 u2 idx;
00202
00203 for(idx = 0; idx < pcpd_Utf8->length - 1; idx++)
00204 {
00205
00206 if (METHOD_CHAR_CLOSE_PARM == pcpd_Utf8->bytes[idx])
00207 {
00208 switch (pcpd_Utf8->bytes[idx + 1])
00209 {
00210 case BASETYPE_CHAR_B:
00211 case BASETYPE_CHAR_C:
00212 case BASETYPE_CHAR_D:
00213 case BASETYPE_CHAR_F:
00214 case BASETYPE_CHAR_I:
00215 case BASETYPE_CHAR_J:
00216 case BASETYPE_CHAR_L:
00217 case BASETYPE_CHAR_S:
00218 case BASETYPE_CHAR_Z:
00219 case BASETYPE_CHAR_ARRAY:
00220 case METHOD_CHAR_VOID:
00221 return((jvm_basetype) pcpd_Utf8->bytes[idx + 1]);
00222 }
00223 }
00224 }
00225
00226
00227
00228
00229
00230
00231
00232 return((jvm_basetype) LOCAL_BASETYPE_ERROR);
00233
00234 }
00235
00236
00237
00238