mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoReflectionField *f)
{
	MonoType *type;
	guint32 token;
	MonoClassField *field;

	token = GPOINTER_TO_UINT (g_hash_table_lookup (assembly->handleref, f));
	if (token)
		return token;
	g_assert (f->field->parent);

	field = f->field;
	if (field->parent->generic_class && field->parent->generic_class->container_class && field->parent->generic_class->container_class->fields) {
		int index = field - field->parent->fields;
		type = field->parent->generic_class->container_class->fields [index].type;
	} else {
		if (is_field_on_inst (f->field))
			type = get_field_on_inst_generic_type (f->field);
		else
			type = f->field->type;
	}
	token = mono_image_get_memberref_token (assembly, &f->field->parent->byval_arg, 
											mono_field_get_name (f->field),  
											fieldref_encode_signature (assembly, field->parent->image, type));
	g_hash_table_insert (assembly->handleref, f, GUINT_TO_POINTER(token));
	return token;
}
mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoReflectionField *f)
{
	MonoType *type;
	guint32 token;
	MonoClassField *field;

	token = GPOINTER_TO_UINT (g_hash_table_lookup (assembly->handleref, f));
	if (token)
		return token;
	g_assert (f->field->parent);

	field = f->field;
	if (field->parent->generic_class && field->parent->generic_class->container_class && field->parent->generic_class->container_class->fields) {
		int index = field - field->parent->fields;
		type = field->parent->generic_class->container_class->fields [index].type;
	} else {
		if (is_field_on_inst (f->field))
			type = get_field_on_inst_generic_type (f->field);
		else
			type = f->field->type;
	}
	token = mono_image_get_memberref_token (assembly, &f->field->parent->byval_arg, 
											mono_field_get_name (f->field),  
											fieldref_encode_signature (assembly, field->parent->image, type));
	g_hash_table_insert (assembly->handleref, f, GUINT_TO_POINTER(token));
	return token;
}