Skip to content

Commit

Permalink
2004-03-24 Martin Baulig <martin@ximian.com>
Browse files Browse the repository at this point in the history
	* mini.c (mini_get_class): New static method; if we're inside a
	generic instance, inflate the class if neccessary.
	(mono_method_to_ir): Use mini_get_class() instead of mono_class_get().

svn path=/trunk/mono/; revision=24555
  • Loading branch information
Martin Baulig committed Mar 25, 2004
1 parent 020c22b commit 3a735b0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
6 changes: 6 additions & 0 deletions mono/mini/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2004-03-24 Martin Baulig <martin@ximian.com>

* mini.c (mini_get_class): New static method; if we're inside a
generic instance, inflate the class if neccessary.
(mono_method_to_ir): Use mini_get_class() instead of mono_class_get().

2004-03-24 Zoltan Varga <vargaz@freemail.hu>

* iltests.il: New regression test for #55976.
Expand Down
48 changes: 32 additions & 16 deletions mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,22 @@ mini_get_method (MonoImage *image, guint32 token, MonoMethod *calling_method)
return mono_class_inflate_generic_method (method, gmethod, NULL);
}

static MonoClass *
mini_get_class (MonoImage *image, guint32 token, MonoMethod *calling_method)
{
MonoClass *klass = mono_class_get (image, token);
MonoType *inflated;

if (!calling_method->signature->gen_method || !klass->generic_inst)
return klass;

inflated = mono_class_inflate_generic_type (
&klass->byval_arg, calling_method->klass->generic_inst,
calling_method->signature->gen_method);

return mono_class_from_mono_type (inflated);
}

/*
* mono_method_to_ir: translates IL into basic blocks containing trees
*/
Expand Down Expand Up @@ -3741,7 +3757,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);

mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
Expand Down Expand Up @@ -3795,7 +3811,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);

mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
Expand Down Expand Up @@ -3986,7 +4002,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
CHECK_STACK (1);
--sp;
CHECK_OPSIZE (5);
klass = mono_class_get (image, read32 (ip + 1));
klass = mini_get_class (image, read32 (ip + 1), method);
mono_class_init (klass);

if (klass->marshalbyref || klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
Expand Down Expand Up @@ -4041,7 +4057,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);

if (klass->byval_arg.type == MONO_TYPE_VAR)
Expand Down Expand Up @@ -4141,7 +4157,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);

if (klass->byval_arg.type == MONO_TYPE_VAR)
Expand Down Expand Up @@ -4170,7 +4186,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
CHECK_STACK (1);
--sp;
CHECK_OPSIZE (5);
klass = mono_class_get (image, read32 (ip + 1));
klass = mini_get_class (image, read32 (ip + 1), method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -4558,7 +4574,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -4593,7 +4609,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -4659,7 +4675,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);

mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
Expand Down Expand Up @@ -4705,7 +4721,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = (MonoClass*)mono_method_get_wrapper_data (method, read32 (ip + 1));
else
klass = mono_class_get (image, read32 (ip + 1));
klass = mini_get_class (image, read32 (ip + 1), method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand All @@ -4722,7 +4738,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
sp -= 2;
CHECK_OPSIZE (5);
token = read32 (ip + 1);
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -4807,7 +4823,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
sp -= 3;
CHECK_OPSIZE (5);
token = read32 (ip + 1);
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -4893,7 +4909,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MONO_INST_NEW (cfg, ins, *ip);
--sp;
CHECK_OPSIZE (5);
klass = mono_class_get (image, read32 (ip + 1));
klass = mini_get_class (image, read32 (ip + 1), method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand All @@ -4914,7 +4930,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MONO_INST_NEW (cfg, ins, *ip);
--sp;
CHECK_OPSIZE (5);
klass = mono_class_get (image, read32 (ip + 1));
klass = mini_get_class (image, read32 (ip + 1), method);
mono_class_init (klass);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
Expand Down Expand Up @@ -5588,7 +5604,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->wrapper_type != MONO_WRAPPER_NONE)
klass = mono_method_get_wrapper_data (method, token);
else
klass = mono_class_get (image, token);
klass = mini_get_class (image, token, method);
if (klass->byval_arg.type == MONO_TYPE_VAR)
klass = TYPE_PARAM_TO_CLASS (klass->byval_arg.data.generic_param->num);
else if (klass->byval_arg.type == MONO_TYPE_MVAR)
Expand Down Expand Up @@ -5680,7 +5696,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MonoType *type = mono_type_create_from_typespec (image, token);
token = mono_type_size (type, &align);
} else {
MonoClass *szclass = mono_class_get (image, token);
MonoClass *szclass = mini_get_class (image, token, method);
mono_class_init (szclass);
token = mono_class_value_size (szclass, &align);
}
Expand Down

0 comments on commit 3a735b0

Please sign in to comment.