namespace Mono.ILASM {
- public class MethodRef : IMethodRef {
+ public class MethodRef : BaseMethodRef {
- private TypeRef owner;
- private ITypeRef ret_type;
- private string name;
- private ITypeRef[] param;
-
- private PEAPI.Method peapi_method;
-
- public MethodRef (TypeRef owner,
- ITypeRef ret_type, string name, ITypeRef[] param)
+ public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
+ BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
+ : base (owner, call_conv, ret_type, name, param, gen_param_count)
{
- this.owner = owner;
- this.ret_type = ret_type;
- this.name = name;
- this.param = param;
- }
-
- public PEAPI.Method PeapiMethod {
- get { return peapi_method; }
}
- public void Resolve (CodeGen code_gen)
+ public override void Resolve (CodeGen code_gen)
{
+ if (is_resolved)
+ return;
+
+ owner.Resolve (code_gen);
+
TypeDef owner_def = code_gen.TypeManager[owner.FullName];
- string sig = MethodDef.CreateSignature (name, new ArrayList (param));
- peapi_method = owner_def.ResolveMethod (sig, code_gen);
+ if (owner_def == null)
+ Report.Error ("Reference to undefined class '" + owner.FullName + "'");
+
+ string write_name;
+
+ if (name == "<init>")
+ write_name = ".ctor";
+ else
+ write_name = name;
+
+ if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
+ peapi_method = owner_def.ResolveMethod (ret_type, call_conv, name,
+ param, gen_param_count, code_gen);
+ } else {
+ ArrayList opt_list = new ArrayList ();
+ bool in_opt = false;
+ foreach (BaseTypeRef type in param) {
+ if (type is SentinelTypeRef) {
+ in_opt = true;
+ } else if (in_opt) {
+ type.Resolve (code_gen);
+ opt_list.Add (type.PeapiType);
+ }
+ }
+ peapi_method = owner_def.ResolveVarargMethod (
+ ret_type, call_conv, name, param, gen_param_count,
+ (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)),
+ code_gen);
+ }
+
+ is_resolved = true;
+
}
}