MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
+ guint32 idx;
if (!mono_method_signature (method)->param_count)
return;
methodt = &klass->image->tables [MONO_TABLE_METHOD];
paramt = &klass->image->tables [MONO_TABLE_PARAM];
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i]) {
- guint32 idx = klass->method.first + i;
- guint32 cols [MONO_PARAM_SIZE];
- guint param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
+ idx = mono_method_get_index (method);
+ if (idx > 0) {
+ guint32 cols [MONO_PARAM_SIZE];
+ guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
- if (idx + 1 < methodt->rows)
- lastp = mono_metadata_decode_row_col (methodt, idx + 1, MONO_METHOD_PARAMLIST);
- else
- lastp = paramt->rows + 1;
- for (i = param_index; i < lastp; ++i) {
- mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
- if (cols [MONO_PARAM_SEQUENCE]) /* skip return param spec */
- names [cols [MONO_PARAM_SEQUENCE] - 1] = mono_metadata_string_heap (klass->image, cols [MONO_PARAM_NAME]);
- }
- return;
+ if (idx < methodt->rows)
+ lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
+ else
+ lastp = paramt->rows + 1;
+ for (i = param_index; i < lastp; ++i) {
+ mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
+ if (cols [MONO_PARAM_SEQUENCE]) /* skip return param spec */
+ names [cols [MONO_PARAM_SEQUENCE] - 1] = mono_metadata_string_heap (klass->image, cols [MONO_PARAM_NAME]);
}
+ return;
}
}
guint32
mono_method_get_param_token (MonoMethod *method, int index)
{
- int i;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
+ guint32 idx;
if (klass->generic_class)
g_assert_not_reached ();
}
methodt = &klass->image->tables [MONO_TABLE_METHOD];
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i]) {
- guint32 idx = klass->method.first + i;
- guint param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
+ idx = mono_method_get_index (method);
+ if (idx > 0) {
+ guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
- return mono_metadata_make_token (MONO_TABLE_PARAM, param_index + index);
- }
+ return mono_metadata_make_token (MONO_TABLE_PARAM, param_index + index);
}
return 0;
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
+ guint32 idx;
for (i = 0; i < mono_method_signature (method)->param_count + 1; ++i)
mspecs [i] = NULL;
methodt = &klass->image->tables [MONO_TABLE_METHOD];
paramt = &klass->image->tables [MONO_TABLE_PARAM];
+ idx = mono_method_get_index (method);
+ if (idx > 0) {
+ guint32 cols [MONO_PARAM_SIZE];
+ guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i]) {
- guint32 idx = klass->method.first + i;
- guint32 cols [MONO_PARAM_SIZE];
- guint param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
-
- if (idx + 1 < methodt->rows)
- lastp = mono_metadata_decode_row_col (methodt, idx + 1, MONO_METHOD_PARAMLIST);
- else
- lastp = paramt->rows + 1;
+ if (idx < methodt->rows)
+ lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
+ else
+ lastp = paramt->rows + 1;
- for (i = param_index; i < lastp; ++i) {
- mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
+ for (i = param_index; i < lastp; ++i) {
+ mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
- if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL) {
- const char *tp;
- tp = mono_metadata_get_marshal_info (klass->image, i - 1, FALSE);
- g_assert (tp);
- mspecs [cols [MONO_PARAM_SEQUENCE]]= mono_metadata_parse_marshal_spec (klass->image, tp);
- }
+ if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL) {
+ const char *tp;
+ tp = mono_metadata_get_marshal_info (klass->image, i - 1, FALSE);
+ g_assert (tp);
+ mspecs [cols [MONO_PARAM_SEQUENCE]]= mono_metadata_parse_marshal_spec (klass->image, tp);
}
-
- return;
}
+
+ return;
}
}
MonoClass *klass = method->klass;
MonoTableInfo *methodt;
MonoTableInfo *paramt;
+ guint32 idx;
if (method->klass->image->dynamic) {
MonoReflectionMethodAux *method_aux =
methodt = &klass->image->tables [MONO_TABLE_METHOD];
paramt = &klass->image->tables [MONO_TABLE_PARAM];
+ idx = mono_method_get_index (method);
+ if (idx > 0) {
+ guint32 cols [MONO_PARAM_SIZE];
+ guint param_index = mono_metadata_decode_row_col (methodt, idx - 1, MONO_METHOD_PARAMLIST);
+
+ if (idx + 1 < methodt->rows)
+ lastp = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
+ else
+ lastp = paramt->rows + 1;
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i]) {
- guint32 idx = klass->method.first + i;
- guint32 cols [MONO_PARAM_SIZE];
- guint param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
-
- if (idx + 1 < methodt->rows)
- lastp = mono_metadata_decode_row_col (methodt, idx + 1, MONO_METHOD_PARAMLIST);
- else
- lastp = paramt->rows + 1;
-
- for (i = param_index; i < lastp; ++i) {
- mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
+ for (i = param_index; i < lastp; ++i) {
+ mono_metadata_decode_row (paramt, i -1, cols, MONO_PARAM_SIZE);
- if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL)
- return TRUE;
- }
- return FALSE;
+ if (cols [MONO_PARAM_FLAGS] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL)
+ return TRUE;
}
+ return FALSE;
}
return FALSE;
}
return method->flags;
}
+/*
+ * Find the method index in the metadata methodDef table.
+ */
+guint32
+mono_method_get_index (MonoMethod *method) {
+ MonoClass *klass = method->klass;
+ int i;
+
+ for (i = 0; i < klass->method.count; ++i) {
+ if (method == klass->methods [i])
+ return klass->method.first + 1 + i;
+ }
+ return 0;
+}
{
guint32 param_index, i, lastp, crow = 0;
guint32 param_cols [MONO_PARAM_SIZE], const_cols [MONO_CONSTANT_SIZE];
- gint32 idx = -1;
+ gint32 idx;
MonoClass *klass = method->klass;
MonoImage *image = klass->image;
paramt = &klass->image->tables [MONO_TABLE_PARAM];
constt = &image->tables [MONO_TABLE_CONSTANT];
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i]) {
- idx = klass->method.first + i;
- break;
- }
- }
-
+ idx = mono_method_get_index (method) - 1;
g_assert (idx != -1);
param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
}
}
-/*
- * Find the method index in the metadata methodDef table.
- * Later put these three helper methods in metadata and export them.
- */
-static guint32
-find_method_index (MonoMethod *method) {
- MonoClass *klass = method->klass;
- int i;
-
- for (i = 0; i < klass->method.count; ++i) {
- if (method == klass->methods [i])
- return klass->method.first + 1 + i;
- }
- return 0;
-}
-
/*
* Find the field index in the metadata FieldDef table.
*/
if (dynamic_custom_attrs && (cinfo = g_hash_table_lookup (dynamic_custom_attrs, method)))
return cinfo;
- idx = find_method_index (method);
+ idx = mono_method_get_index (method);
idx <<= MONO_CUSTOM_ATTR_BITS;
idx |= MONO_CUSTOM_ATTR_METHODDEF;
return mono_custom_attrs_from_index (method->klass->image, idx);
}
image = method->klass->image;
- method_index = find_method_index (method);
+ method_index = mono_method_get_index (method);
ca = &image->tables [MONO_TABLE_METHOD];
if (method->klass->generic_class || mono_method_signature (method)->generic_param_count) {
{
if (method->flags & METHOD_ATTRIBUTE_HAS_SECURITY) {
/* FIXME: No cache (for the moment) */
- guint32 idx = find_method_index (method);
+ guint32 idx = mono_method_get_index (method);
idx <<= MONO_HAS_DECL_SECURITY_BITS;
idx |= MONO_HAS_DECL_SECURITY_METHODDEF;
return mono_declsec_get_flags (method->klass->image, idx);
mono_class_init (method->klass);
memset (demands, 0, sizeof (MonoDeclSecurityActions));
- guint32 idx = find_method_index (method);
+ guint32 idx = mono_method_get_index (method);
idx <<= MONO_HAS_DECL_SECURITY_BITS;
idx |= MONO_HAS_DECL_SECURITY_METHODDEF;
result = fill_actions_from_index (image, idx, demands);
mono_declsec_get_method_action (MonoMethod *method, guint32 action, MonoDeclSecurityEntry *entry)
{
if (method->flags & METHOD_ATTRIBUTE_HAS_SECURITY) {
- guint32 idx = find_method_index (method);
+ guint32 idx = mono_method_get_index (method);
idx <<= MONO_HAS_DECL_SECURITY_BITS;
idx |= MONO_HAS_DECL_SECURITY_METHODDEF;
return get_declsec_action (method->klass->image, idx, action, entry);