Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 81 additions & 25 deletions mono/metadata/class-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct _MonoMethod {
guint16 flags; /* method flags */
guint16 iflags; /* method implementation flags */
guint32 token;
MonoClass *klass;
MonoClass *klass; /* To what class does this method belong */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, it should go in outside of this PR/commit.

MonoMethodSignature *signature;
/* name is useful mostly for debugging */
const char *name;
Expand Down Expand Up @@ -528,7 +528,7 @@ struct _MonoMethodInflated {
*/
struct _MonoGenericClass {
MonoClass *container_class; /* the generic type definition */
MonoGenericContext context; /* a context that contains the type instantiation doesn't contain any method instantiation */
MonoGenericContext context; /* a context that contains the type instantiation doesn't contain any method instantiation */ /* FIXME: Only the class_inst member of "context" is ever used, so this field could be replaced with just a monogenericinst */
guint is_dynamic : 1; /* We're a MonoDynamicGenericClass */
guint is_tb_open : 1; /* This is the fully open instantiation for a type_builder. Quite ugly, but it's temporary.*/
MonoClass *cached_class; /* if present, the MonoClass corresponding to the instantiation. */
Expand Down Expand Up @@ -570,13 +570,6 @@ struct _MonoGenericParam {
* sharing.
*/
MonoType *gshared_constraint;
/*
* If owner is NULL, or owner is 'owned' by this gparam,
* then this is the image whose mempool this struct was allocated from.
* The second case happens for gparams created in
* mono_reflection_initialize_generic_parameter ().
*/
MonoImage *image;
};

/* Additional details about a MonoGenericParam */
Expand Down Expand Up @@ -609,33 +602,87 @@ struct _MonoGenericContainer {
the generic container of the containing class. */
MonoGenericContainer *parent;
/* the generic type definition or the generic method definition corresponding to this container */
/* Union rules: If is_anonymous, image field is valid; else if is_method, method field is valid; else klass is valid. */
union {
MonoClass *klass;
MonoMethod *method;
MonoImage *image;
} owner;
int type_argc : 31;
int type_argc : 29; // Per the ECMA spec, this value is capped at 16 bits
/* If true, we're a generic method, otherwise a generic type definition. */
/* Invariant: parent != NULL => is_method */
int is_method : 1;
int is_method : 1;
/* If true, this container has no associated class/method and only the image is known. This can happen:
1. For the special anonymous containers kept by MonoImage.
2. During container creation via the mono_metadata_load_generic_params path-- in this case the caller
sets the owner, so temporarily while load_generic_params is completing the container is anonymous.
3. When user code creates a generic parameter via SRE, but has not yet set an owner. */
int is_anonymous : 1;
/* If false, all params in this container are full-size. If true, all params are just param structs. */
/* This field is always == to the is_anonymous field, except in "temporary" cases (2) and (3) above. */
/* TODO: Merge GenericParam and GenericParamFull, remove this field. Benefit is marginal. */
int is_small_param : 1;
/* Our type parameters. */
MonoGenericParamFull *type_params;

/*
* For owner-less containers created by SRE, the image the container was
* allocated from.
*/
MonoImage *image;
};

#define mono_generic_container_get_param(gc, i) ((MonoGenericParam *) ((gc)->type_params + (i)))
#define mono_generic_container_get_param_info(gc, i) (&((gc)->type_params + (i))->info)
static inline MonoGenericParam *
mono_generic_container_get_param (MonoGenericContainer *gc, int i)
{
return (MonoGenericParam *) &gc->type_params [i];
}

static inline MonoGenericParamInfo *
mono_generic_container_get_param_info (MonoGenericContainer *gc, int i)
{
return &gc->type_params [i].info;
}

static inline MonoGenericContainer *
mono_generic_param_owner (MonoGenericParam *p)
{
return p->owner;
}

static inline int
mono_generic_param_num (MonoGenericParam *p)
{
return p->num;
}

static inline gboolean
mono_generic_param_is_fullsize (MonoGenericParam *p)
{
return !mono_generic_param_owner (p)->is_small_param;
}

static inline MonoGenericParamInfo *
mono_generic_param_info (MonoGenericParam *p)
{
if (mono_generic_param_is_fullsize (p))
return &((MonoGenericParamFull *) p)->info;
return NULL;
}

#define mono_generic_param_owner(p) ((p)->owner)
#define mono_generic_param_num(p) ((p)->num)
#define mono_generic_param_info(p) (mono_generic_param_owner (p) ? &((MonoGenericParamFull *) p)->info : NULL)
#define mono_generic_param_name(p) (((mono_generic_param_owner (p) || (p)->gshared_constraint)) ? ((MonoGenericParamFull *) p)->info.name : NULL)
#define mono_type_get_generic_param_owner(t) (mono_generic_param_owner ((t)->data.generic_param))
#define mono_type_get_generic_param_num(t) (mono_generic_param_num ((t)->data.generic_param))
static inline const char *
mono_generic_param_name (MonoGenericParam *p)
{
if (mono_generic_param_is_fullsize (p))
return ((MonoGenericParamFull *) p)->info.name;
return NULL;
}

static inline MonoGenericContainer *
mono_type_get_generic_param_owner (MonoType *t)
{
return mono_generic_param_owner (t->data.generic_param);
}

static inline int
mono_type_get_generic_param_num (MonoType *t)
{
return mono_generic_param_num (t->data.generic_param);
}

/*
* Class information which might be cached by the runtime in the AOT file for
Expand Down Expand Up @@ -1416,4 +1463,13 @@ mono_field_from_token_checked (MonoImage *image, uint32_t token, MonoClass **ret
gpointer
mono_ldtoken_checked (MonoImage *image, guint32 token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error);

MonoClass *
mono_class_from_generic_parameter_internal (MonoGenericParam *param);

MonoImage *
get_image_for_generic_param (MonoGenericParam *param);

char *
make_generic_name_string (MonoImage *image, int num);

#endif /* __MONO_METADATA_CLASS_INTERNALS_H__ */
Loading