Author: ankit
Date: 2005-12-09 08:02:33 -0500 (Fri, 09 Dec 2005)
New Revision: 54160
Modified:
trunk/mcs/class/PEAPI/ChangeLog
trunk/mcs/class/PEAPI/Metadata.cs
trunk/mcs/class/PEAPI/PEAPI.cs
trunk/mcs/ilasm/codegen/ChangeLog
trunk/mcs/ilasm/codegen/ExternMethodRef.cs
trunk/mcs/ilasm/codegen/ExternTypeRef.cs
trunk/mcs/ilasm/codegen/ExternTypeRefInst.cs
trunk/mcs/ilasm/codegen/GenericMethodRef.cs
trunk/mcs/ilasm/codegen/GenericTypeInst.cs
trunk/mcs/ilasm/codegen/GenericTypeRef.cs
trunk/mcs/ilasm/codegen/GlobalMethodRef.cs
trunk/mcs/ilasm/codegen/ITypeRef.cs
trunk/mcs/ilasm/codegen/MethodDef.cs
trunk/mcs/ilasm/codegen/MethodPointerTypeRef.cs
trunk/mcs/ilasm/codegen/MethodRef.cs
trunk/mcs/ilasm/codegen/PrimitiveTypeRef.cs
trunk/mcs/ilasm/codegen/Sentinel.cs
trunk/mcs/ilasm/codegen/TypeDef.cs
trunk/mcs/ilasm/codegen/TypeRef.cs
trunk/mcs/ilasm/codegen/TypeSpecMethodRef.cs
trunk/mcs/ilasm/parser/ChangeLog
trunk/mcs/ilasm/parser/ILParser.jay
Log:
In ilasm/codegen:
2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
* ITypeRef.cs (ITypeRef.GetMethodRef): Add 'gen_param_count' param.
* Sentinel.cs (Sentinel.GetMethodRef): Update.
* GlobalMethodRef.cs (GlobalMethodRef.ctor): Add 'gen_param_count'
param.
(GlobalMethodRef.Resolve): Update usage of MethodDef.CreateSignature .
* TypeDef.cs (TypeDef.GetGenericParamNum): New.
(TypeDef.DefineContents): Update usage of ITypeRef.GetMethodRef .
* ExternTypeRefInst.cs (ExternTypeRefInst.ctor): Add parameter for list
of type
parameters (type_list).
(ExternTypeRefInst.Clone): Clone type_list also.
(ExternTypeRefInst.Resolve): Resolve the list of type parameters, and
create
instance of PEAPI.GenericTypeInst instead of PEAPI.ClassRefInst .
(ExternTypeRefInst.GetMethodRef): Update.
* GenericTypeInst.cs (GenericTypeInst.GetMethodRef): Update signature.
Update
usage of TypeSpecMethodRef.ctor .
* MethodRef.cs (MethodRef.ctor): Add 'gen_param_count' param.
(MethodRef.Resolve): Throw exception for non-existant owner. Update
usage of
MethodDef.CreateSignature .
* ExternMethodRef.cs (ExternMethodRef.ctor): Add 'gen_param_count'
param.
(ExternMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec
and .AddMethod
* GenericMethodRef.cs (GenericMethodRef.PeapiMethod): Return
PEAPI.Method obtained in
.Resolve .
* GenericTypeRef.cs (GenericTypeRef.GetMethodRef): Update.
* MethodPointerTypeRef.cs (MethodPointerTypeRef.GetMethodRef): Likewise.
* TypeSpecMethodRef.cs (TypeSpecMethodRef.ctor): Add 'gen_param_count'
param.
(TypeSpecMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec
.
* MethodDef.cs (MethodDef.ctor): Add 'typars_list' param.
(MethodDef.AddGenericParam): Replace ..
(MethodDef.AddGenericParams): .. with this.
(MethodDef.GenParamCount): New.
(MethodDef.GetGenericParamNum): New. Returns index for a given method
type parameter name.
(MethodDef.ResolveGenParams): Resolves type parameter names in the
parameter
list to their corresponding indices.
(MethodDef.ResolveGenParam): Resolves a give type parameter to its
corresponding
index.
(MethodDef.CreateSignature): Add 'gen_param_count' param.
* TypeRef.cs (TypeRef.GetMethodRef): Update.
* ExternTypeRef.cs (ExternTypeRef.GetMethodRef): Likewise.
* PrimitiveTypeRef.cs (PrimitiveTypeRef.GetMethodRef): Likewise.
In ilasm/parser:
2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (class_decl | D_OVERRIDE ..): Update usage of
ITypeRef.GetMethodRef
and MethodDef.CreateSignature .
(method_head | D_METHOD ..): Update usage of MethodDef.ctor .
Use MethodDef.ResolveGenParams to resolve VARs/MVARs in parameter list.
(type | K_CLASS slashed_name ..): Remove redundant rule.
(type | BANG id): New. Generic type parameter.
(type | BANG BANG id): New. Generic method type parameter.
(instr | INSTR_FIELD type ..): Resolve generic param for 'type'.
(method_ref | call_conv ..): Set MethodRef's GenParamCount.
(method_ref | call_conv type ..): Update usage of
TypeSpecMethodRef.ctor and GetMethodRef.
(method_ref | call_conv type ..): New. Rule for global generic method
refs.
(custom_type | call_conv ..): Update usage of GlobalMethodRef.ctor .
In class/PEAPI:
2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (Method.ctor): Remove rType parameter.
(Method.GetRetType): Remove.
(Method.AddCallConv): Make it abstract.
(Method.GetSigIx): Likewise.
(MethodDef): Override and implement abstract methods from Method class.
(MethodRef): Likewise.
(MethodSpec): Change base class from MetaDataElement to Method.
Override
abstract methods from Method but throw Exception as they are not meant
to be used here.
(MethodDef.TypeSig): Write gen_param_count before num of params.
(ClassRef.AddMethod): New overload with an extra gen_param_count param.
* PEAPI.cs (PEFile.AddMethodToTypeSpec): New overload with an extra
gen_param_count
param.
(PEFile.AddMethodSpec): Change return type from void to Method.
Modified: trunk/mcs/class/PEAPI/ChangeLog
===================================================================
--- trunk/mcs/class/PEAPI/ChangeLog 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/class/PEAPI/ChangeLog 2005-12-09 13:02:33 UTC (rev 54160)
@@ -1,3 +1,19 @@
+2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * Metadata.cs (Method.ctor): Remove rType parameter.
+ (Method.GetRetType): Remove.
+ (Method.AddCallConv): Make it abstract.
+ (Method.GetSigIx): Likewise.
+ (MethodDef): Override and implement abstract methods from Method class.
+ (MethodRef): Likewise.
+ (MethodSpec): Change base class from MetaDataElement to Method.
Override
+ abstract methods from Method but throw Exception as they are not meant
to be used here.
+ (MethodDef.TypeSig): Write gen_param_count before num of params.
+ (ClassRef.AddMethod): New overload with an extra gen_param_count param.
+ * PEAPI.cs (PEFile.AddMethodToTypeSpec): New overload with an extra
gen_param_count
+ param.
+ (PEFile.AddMethodSpec): Change return type from void to Method.
+
2005-12-05 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (GenParamType): New enum.
Modified: trunk/mcs/class/PEAPI/Metadata.cs
===================================================================
--- trunk/mcs/class/PEAPI/Metadata.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/class/PEAPI/Metadata.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -834,19 +834,29 @@
}
- internal class MethodSpec : MetaDataElement {
+ internal class MethodSpec : Method {
Method meth;
GenericMethodSig g_sig;
uint sidx;
- internal MethodSpec (Method meth, GenericMethodSig g_sig)
+ internal MethodSpec (Method meth, GenericMethodSig g_sig) :
base ("")
{
this.meth = meth;
this.g_sig = g_sig;
tabIx = MDTable.MethodSpec;
}
+ internal override uint GetSigIx (MetaData md)
+ {
+ throw new Exception ("Should not be used.");
+ }
+
+ public override void AddCallConv (CallConv cconv)
+ {
+ throw new Exception ("Should not be used.");
+ }
+
internal sealed override void BuildTables (MetaData md)
{
if (done) return;
@@ -865,6 +875,11 @@
output.WriteCodedIndex (CIx.MethodDefOrRef, meth);
output.BlobIndex (sidx);
}
+
+ internal sealed override void TypeSig (MemoryStream sig)
+ {
+ throw new Exception ("Should not be used.");
+ }
}
/**************************************************************************/
@@ -1747,7 +1762,20 @@
/// <returns>a descriptor for this method</returns>
public MethodRef AddMethod(string name, Type retType, Type[]
pars)
{
- MethodRef meth = new
MethodRef(this,name,retType,pars,false,null);
+ return AddMethod (name, retType, pars, 0);
+ }
+
+ /// <summary>
+ /// Add a method to this class
+ /// </summary>
+ /// <param name="name">method name</param>
+ /// <param name="retType">return type</param>
+ /// <param name="pars">parameter types</param>
+ /// <param name="gen_param_count">num of generic
parameters</param>
+ /// <returns>a descriptor for this method</returns>
+ public MethodRef AddMethod (string name, Type retType, Type[]
pars, int gen_param_count)
+ {
+ MethodRef meth = new MethodRef (this, name, retType,
pars, false, null, gen_param_count);
metaData.AddToTable(MDTable.MemberRef,meth);
return meth;
}
@@ -1762,7 +1790,7 @@
public MethodRef AddVarArgMethod(string name, Type retType,
Type[] pars, Type[] optPars)
{
- MethodRef meth = new
MethodRef(this,name,retType,pars,true,optPars);
+ MethodRef meth = new
MethodRef(this,name,retType,pars,true,optPars, 0);
metaData.AddToTable(MDTable.MemberRef,meth);
return meth;
}
@@ -2441,7 +2469,7 @@
/// <returns>a descriptor for this method in anther
module</returns>
public MethodRef AddMethod(string name, Type retType, Type[]
pars)
{
- MethodRef meth = new
MethodRef(this,name,retType,pars,false,null);
+ MethodRef meth = new
MethodRef(this,name,retType,pars,false,null, 0);
metaData.AddToTable(MDTable.MemberRef,meth);
return meth;
}
@@ -2456,7 +2484,7 @@
/// <returns>a descriptor for this method</returns>
public MethodRef AddVarArgMethod(string name, Type retType,
Type[] pars, Type[] optPars) {
- MethodRef meth = new
MethodRef(this,name,retType,pars,true,optPars);
+ MethodRef meth = new
MethodRef(this,name,retType,pars,true,optPars, 0);
metaData.AddToTable(MDTable.MemberRef,meth);
return meth;
}
@@ -3409,39 +3437,12 @@
public abstract class Method : Member {
- protected CallConv callConv = CallConv.Default;
- protected Type retType;
- protected int gen_param_count;
+ internal Method (string methName) : base (methName)
+ {}
- internal Method(string methName, Type rType) : base(methName)
- {
- retType = rType;
- gen_param_count = 0;
- }
-
- /// <summary>
- /// Add calling conventions to this method descriptor
- /// </summary>
- /// <param name="cconv"></param>
- public void AddCallConv(CallConv cconv)
- {
- callConv |= cconv;
- }
-
+ public abstract void AddCallConv(CallConv cconv);
internal abstract void TypeSig(MemoryStream sig);
-
- internal uint GetSigIx(MetaData md)
- {
- MemoryStream sig = new MemoryStream();
- TypeSig(sig);
- return md.AddToBlobHeap(sig.ToArray());
- }
-
- internal Type GetRetType()
- {
- return retType;
- }
-
+ internal abstract uint GetSigIx(MetaData md);
}
/**************************************************************************/
@@ -3456,6 +3457,9 @@
//private static readonly uint UnmanagedExport = 0x0008;
// private static readonly byte LocalSigByte = 0x7;
uint parIx = 0, textOffset = 0;
+ private CallConv callConv = CallConv.Default;
+ private Type retType;
+ private int gen_param_count;
MetaData metaData;
CILInstructions code;
@@ -3472,8 +3476,9 @@
Param ret_param;
- internal MethodDef(MetaData md, string name, Type retType,
Param[] pars) : base(name,retType)
+ internal MethodDef(MetaData md, string name, Type retType,
Param[] pars) : base (name)
{
+ this.retType = retType;
metaData = md;
parList = pars;
if (parList != null) numPars = parList.Length;
@@ -3492,6 +3497,18 @@
return parList;
}
+ internal override uint GetSigIx(MetaData md)
+ {
+ MemoryStream sig = new MemoryStream();
+ TypeSig(sig);
+ return md.AddToBlobHeap(sig.ToArray());
+ }
+
+ public override void AddCallConv(CallConv cconv)
+ {
+ callConv |= cconv;
+ }
+
/// <summary>
/// Add some attributes to this method descriptor
/// </summary>
@@ -3585,7 +3602,7 @@
for (int i=0; i < numPars; i++) {
pars[i] = parList[i].GetParType();
}
- varArgSig = new
MethodRef(this,name,retType,pars,true,optPars);
+ varArgSig = new
MethodRef(this,name,retType,pars,true,optPars, 0);
if (varArgSigList == null)
varArgSigList = new ArrayList ();
@@ -3596,9 +3613,9 @@
internal sealed override void TypeSig(MemoryStream sig)
{
sig.WriteByte((byte)callConv);
- MetaData.CompressNum((uint)numPars,sig);
if ((callConv & CallConv.Generic) == CallConv.Generic)
MetaData.CompressNum ((uint) gen_param_count,
sig);
+ MetaData.CompressNum((uint)numPars,sig);
if (ret_param != null)
ret_param.seqNo = 0;
retType.TypeSig(sig);
@@ -3697,25 +3714,37 @@
Type[] parList, optParList;
MetaDataElement parent;
uint numPars = 0, numOptPars = 0;
+ CallConv callConv = CallConv.Default;
+ Type retType;
+ int gen_param_count;
internal MethodRef(MetaDataElement paren, string name, Type
retType,
- Type[] pars, bool varArgMeth, Type[] optPars) :
base(name,retType)
+ Type[] pars, bool varArgMeth, Type[] optPars,
int gen_param_count) : base(name)
{
parent = paren;
parList = pars;
+ this.retType = retType;
if (parList != null) numPars = (uint)parList.Length;
if (varArgMeth) {
optParList = optPars;
if (optParList != null) numOptPars =
(uint)optParList.Length;
callConv = CallConv.Vararg;
}
+ this.gen_param_count = gen_param_count;
}
- internal int GenParamCount {
- get { return gen_param_count; }
- set { gen_param_count = value; }
+ internal override uint GetSigIx(MetaData md)
+ {
+ MemoryStream sig = new MemoryStream();
+ TypeSig(sig);
+ return md.AddToBlobHeap(sig.ToArray());
}
+ public override void AddCallConv(CallConv cconv)
+ {
+ callConv |= cconv;
+ }
+
internal sealed override void TypeSig(MemoryStream sig)
{
sig.WriteByte((byte)callConv);
Modified: trunk/mcs/class/PEAPI/PEAPI.cs
===================================================================
--- trunk/mcs/class/PEAPI/PEAPI.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/class/PEAPI/PEAPI.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -781,14 +781,19 @@
public MethodRef AddMethodToTypeSpec (Type item, string name,
Type retType, Type[] pars)
{
- MethodRef meth = new MethodRef (item.GetTypeSpec
(metaData), name, retType, pars, false, null);
+ return AddMethodToTypeSpec (item, name, retType, pars,
0);
+ }
+
+ public MethodRef AddMethodToTypeSpec (Type item, string name,
Type retType, Type[] pars, int gen_param_count)
+ {
+ MethodRef meth = new MethodRef (item.GetTypeSpec
(metaData), name, retType, pars, false, null, gen_param_count);
metaData.AddToTable (MDTable.MemberRef,meth);
return meth;
}
public MethodRef AddVarArgMethodToTypeSpec (Type item, string
name, Type retType,
Type[] pars, Type[] optPars) {
- MethodRef meth = new MethodRef(item.GetTypeSpec
(metaData), name,retType,pars,true,optPars);
+ MethodRef meth = new MethodRef(item.GetTypeSpec
(metaData), name,retType,pars,true,optPars, 0);
metaData.AddToTable(MDTable.MemberRef,meth);
return meth;
}
@@ -800,10 +805,11 @@
return field;
}
- public void AddMethodSpec (Method m, GenericMethodSig g_sig)
+ public Method AddMethodSpec (Method m, GenericMethodSig g_sig)
{
MethodSpec ms = new MethodSpec (m, g_sig);
metaData.AddToTable (MDTable.MethodSpec, ms);
+ return ms;
}
/// <summary>
Modified: trunk/mcs/ilasm/codegen/ChangeLog
===================================================================
--- trunk/mcs/ilasm/codegen/ChangeLog 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/codegen/ChangeLog 2005-12-09 13:02:33 UTC (rev 54160)
@@ -1,3 +1,44 @@
+2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ITypeRef.cs (ITypeRef.GetMethodRef): Add 'gen_param_count' param.
+ * Sentinel.cs (Sentinel.GetMethodRef): Update.
+ * GlobalMethodRef.cs (GlobalMethodRef.ctor): Add 'gen_param_count'
param.
+ (GlobalMethodRef.Resolve): Update usage of MethodDef.CreateSignature .
+ * TypeDef.cs (TypeDef.GetGenericParamNum): New.
+ (TypeDef.DefineContents): Update usage of ITypeRef.GetMethodRef .
+ * ExternTypeRefInst.cs (ExternTypeRefInst.ctor): Add parameter for list
of type
+ parameters (type_list).
+ (ExternTypeRefInst.Clone): Clone type_list also.
+ (ExternTypeRefInst.Resolve): Resolve the list of type parameters, and
create
+ instance of PEAPI.GenericTypeInst instead of PEAPI.ClassRefInst .
+ (ExternTypeRefInst.GetMethodRef): Update.
+ * GenericTypeInst.cs (GenericTypeInst.GetMethodRef): Update signature.
Update
+ usage of TypeSpecMethodRef.ctor .
+ * MethodRef.cs (MethodRef.ctor): Add 'gen_param_count' param.
+ (MethodRef.Resolve): Throw exception for non-existant owner. Update
usage of
+ MethodDef.CreateSignature .
+ * ExternMethodRef.cs (ExternMethodRef.ctor): Add 'gen_param_count'
param.
+ (ExternMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec
and .AddMethod
+ * GenericMethodRef.cs (GenericMethodRef.PeapiMethod): Return
PEAPI.Method obtained in
+ .Resolve .
+ * GenericTypeRef.cs (GenericTypeRef.GetMethodRef): Update.
+ * MethodPointerTypeRef.cs (MethodPointerTypeRef.GetMethodRef): Likewise.
+ * TypeSpecMethodRef.cs (TypeSpecMethodRef.ctor): Add 'gen_param_count'
param.
+ (TypeSpecMethodRef.Resolve): Update usage of PEFile.AddMethodToTypeSpec
.
+ * MethodDef.cs (MethodDef.ctor): Add 'typars_list' param.
+ (MethodDef.AddGenericParam): Replace ..
+ (MethodDef.AddGenericParams): .. with this.
+ (MethodDef.GenParamCount): New.
+ (MethodDef.GetGenericParamNum): New. Returns index for a given method
type parameter name.
+ (MethodDef.ResolveGenParams): Resolves type parameter names in the
parameter
+ list to their corresponding indices.
+ (MethodDef.ResolveGenParam): Resolves a give type parameter to its
corresponding
+ index.
+ (MethodDef.CreateSignature): Add 'gen_param_count' param.
+ * TypeRef.cs (TypeRef.GetMethodRef): Update.
+ * ExternTypeRef.cs (ExternTypeRef.GetMethodRef): Likewise.
+ * PrimitiveTypeRef.cs (PrimitiveTypeRef.GetMethodRef): Likewise.
+
2005-12-05 Ankit Jain <[EMAIL PROTECTED]>
* TypeDef.cs (TypeDef.GenericInfo.num): New.
Modified: trunk/mcs/ilasm/codegen/ExternMethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ExternMethodRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/ExternMethodRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -23,15 +23,19 @@
private PEAPI.Method peapi_method;
private bool is_resolved;
+ private int gen_param_count;
public ExternMethodRef (ExternTypeRef owner, ITypeRef ret_type,
- PEAPI.CallConv call_conv, string name, ITypeRef[]
param)
+ PEAPI.CallConv call_conv, string name, ITypeRef[]
param, int gen_param_count)
{
this.owner = owner;
this.ret_type = ret_type;
this.name = name;
this.param = param;
this.call_conv = call_conv;
+ this.gen_param_count = gen_param_count;
+ if (gen_param_count > 0)
+ CallConv |= PEAPI.CallConv.Generic;
is_resolved = false;
}
@@ -80,12 +84,12 @@
if (owner.UseTypeSpec) {
PEAPI.Type owner_ref = owner.PeapiType;
peapi_method =
code_gen.PEFile.AddMethodToTypeSpec (owner_ref, write_name,
- ret_type.PeapiType,
param_list);
+ ret_type.PeapiType,
param_list, gen_param_count);
} else {
PEAPI.ClassRef owner_ref;
owner_ref = (PEAPI.ClassRef) owner.PeapiType;
peapi_method = owner_ref.AddMethod (write_name,
- ret_type.PeapiType,
param_list);
+ ret_type.PeapiType,
param_list, gen_param_count);
}
peapi_method.AddCallConv (call_conv);
Modified: trunk/mcs/ilasm/codegen/ExternTypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ExternTypeRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/ExternTypeRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -104,13 +104,13 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- string sig = MethodDef.CreateSignature (ret_type,
name, param);
+ string sig = MethodDef.CreateSignature (ret_type,
name, param, gen_param_count);
ExternMethodRef mr = method_table [sig] as
ExternMethodRef;
if (mr == null) {
- mr = new ExternMethodRef (this, ret_type,
call_conv, name, param);
+ mr = new ExternMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
method_table [sig] = mr;
}
Modified: trunk/mcs/ilasm/codegen/ExternTypeRefInst.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ExternTypeRefInst.cs 2005-12-09 12:48:52 UTC
(rev 54159)
+++ trunk/mcs/ilasm/codegen/ExternTypeRefInst.cs 2005-12-09 13:02:33 UTC
(rev 54160)
@@ -19,11 +19,13 @@
private PEAPI.Type type;
private bool is_valuetypeinst;
private bool is_resolved;
+ private ITypeRef [] type_list;
private static Hashtable method_table = new Hashtable ();
- public ExternTypeRefInst (ExternTypeRef type_ref, bool
is_valuetypeinst)
+ public ExternTypeRefInst (ExternTypeRef type_ref, ITypeRef []
type_list, bool is_valuetypeinst)
{
this.type_ref = type_ref;
+ this.type_list = type_list;
this.is_valuetypeinst = is_valuetypeinst;
is_resolved = false;
@@ -62,7 +64,7 @@
public ExternTypeRefInst Clone ()
{
- return new ExternTypeRefInst (type_ref.Clone (),
is_valuetypeinst);
+ return new ExternTypeRefInst (type_ref.Clone (),
(ITypeRef []) type_list.Clone (), is_valuetypeinst);
}
public void MakeArray ()
@@ -109,18 +111,25 @@
return;
type_ref.Resolve (code_gen);
- type = new PEAPI.ClassRefInst (type_ref.PeapiType,
is_valuetypeinst);
+ PEAPI.Type [] p_type_list = new PEAPI.Type
[type_list.Length];
+ for (int i = 0; i < type_list.Length; i ++) {
+ type_list [i].Resolve (code_gen);
+ p_type_list [i] = type_list [i].PeapiType;
+ }
+
+ type = new PEAPI.GenericTypeInst (type_ref.PeapiType,
p_type_list);
+
is_resolved = true;
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- string key = type_ref.FullName +
MethodDef.CreateSignature (ret_type, name, param) + type_ref.SigMod;
+ string key = type_ref.FullName +
MethodDef.CreateSignature (ret_type, name, param, gen_param_count) +
type_ref.SigMod;
TypeSpecMethodRef mr = method_table [key] as
TypeSpecMethodRef;
if (mr == null) {
- mr = new TypeSpecMethodRef (this, ret_type,
call_conv, name, param);
+ mr = new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
method_table [key] = mr;
}
Modified: trunk/mcs/ilasm/codegen/GenericMethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericMethodRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/GenericMethodRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -17,16 +17,18 @@
private IMethodRef meth;
private GenericMethodSig sig;
private bool is_resolved;
+ private PEAPI.Method ms;
public GenericMethodRef (IMethodRef meth, GenericMethodSig sig)
{
this.meth = meth;
this.sig = sig;
+ ms = null;
is_resolved = false;
}
public PEAPI.Method PeapiMethod {
- get { return meth.PeapiMethod; }
+ get { return ms; }
}
public PEAPI.CallConv CallConv {
@@ -44,7 +46,7 @@
return;
meth.Resolve (code_gen);
- code_gen.PEFile.AddMethodSpec (meth.PeapiMethod,
sig.Resolve (code_gen));
+ ms = code_gen.PEFile.AddMethodSpec (meth.PeapiMethod,
sig.Resolve (code_gen));
is_resolved = true;
}
Modified: trunk/mcs/ilasm/codegen/GenericTypeInst.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericTypeInst.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/GenericTypeInst.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -66,9 +66,9 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param);
+ return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
Modified: trunk/mcs/ilasm/codegen/GenericTypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericTypeRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/GenericTypeRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -44,9 +44,9 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param);
+ return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
Modified: trunk/mcs/ilasm/codegen/GlobalMethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GlobalMethodRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/GlobalMethodRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -22,14 +22,18 @@
private PEAPI.Method peapi_method;
private bool is_resolved;
+ private int gen_param_count;
public GlobalMethodRef (ITypeRef ret_type, PEAPI.CallConv
call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
this.ret_type = ret_type;
this.call_conv = call_conv;
this.name = name;
this.param = param;
+ this.gen_param_count = gen_param_count;
+ if (gen_param_count > 0)
+ CallConv |= PEAPI.CallConv.Generic;
is_resolved = false;
}
@@ -55,7 +59,7 @@
string sig;
if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
- sig = MethodDef.CreateSignature (ret_type,
name, param);
+ sig = MethodDef.CreateSignature (ret_type,
name, param, gen_param_count);
peapi_method = code_gen.ResolveMethod (sig);
} else {
ArrayList opt_list = new ArrayList ();
Modified: trunk/mcs/ilasm/codegen/ITypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ITypeRef.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/codegen/ITypeRef.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -70,7 +70,7 @@
void Resolve (CodeGen code_gen);
IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv
call_conv,
- string name, ITypeRef[] param);
+ string name, ITypeRef[] param, int
gen_param_count);
IFieldRef GetFieldRef (ITypeRef ret_type, string name);
Modified: trunk/mcs/ilasm/codegen/MethodDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/MethodDef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/MethodDef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -13,7 +13,6 @@
using System.Collections;
using System.Security;
-
namespace Mono.ILASM {
public class MethodDef : ICustomAttrTarget, IDeclSecurityTarget {
@@ -58,7 +57,7 @@
public MethodDef (CodeGen codegen, PEAPI.MethAttr meth_attr,
PEAPI.CallConv call_conv, PEAPI.ImplAttr
impl_attr,
string name, ITypeRef ret_type, ArrayList
param_list,
- Location start)
+ Location start, ArrayList typars_list)
{
this.meth_attr = meth_attr;
this.call_conv = call_conv;
@@ -82,6 +81,7 @@
is_defined = false;
is_resolved = false;
+ AddGenericParams (typars_list);
CreateSignature ();
codegen.BeginMethodDef (this);
@@ -152,18 +152,37 @@
pinvoke_info = true;
}
- public void AddGenericParam (string id)
+ internal void AddGenericParams (ArrayList typars_list)
{
- if (typar_list == null)
- typar_list = new ArrayList ();
+ if (typars_list == null)
+ return;
- GenericInfo gi = new GenericInfo ();
- gi.Id = id;
- gi.num = typar_list.Count;
+ typar_list = new ArrayList ();
+ foreach (string id in typars_list) {
+ GenericInfo gi = new GenericInfo ();
+ gi.Id = id;
+ gi.num = typar_list.Count;
- typar_list.Add (gi);
+ typar_list.Add (gi);
+ }
}
+
+ public int GenParamCount {
+ get { return typar_list.Count; }
+ }
+ public int GetGenericParamNum (string id)
+ {
+ if (typar_list == null)
+ //FIXME: Report error
+ throw new Exception (String.Format ("Invalid
method type parameter '{0}'", id));
+
+ foreach (GenericInfo gi in typar_list)
+ if (gi.Id == id)
+ return gi.num;
+ return -1;
+ }
+
public void AddGenericConstraint (int index, ITypeRef
constraint)
{
GenericInfo gi = (GenericInfo) typar_list[index];
@@ -283,6 +302,39 @@
this.max_stack = max_stack;
}
+ public void ResolveGenParam (PEAPI.GenParam gpar, TypeDef
type_def)
+ {
+ if (gpar.Index != -1)
+ return;
+
+ if (gpar.Type == PEAPI.GenParamType.MVar)
+ gpar.Index = GetGenericParamNum (gpar.Name);
+ else
+ gpar.Index = type_def.GetGenericParamNum
(gpar.Name);
+
+ if (gpar.Index < 0)
+ /* TODO: Report error */
+ throw new Exception (String.Format ("Invalid
{0}type parameter '{1}'",
+ (gpar.Type ==
PEAPI.GenParamType.MVar ? "method " : ""),
+ gpar.Name));
+ }
+
+ public void ResolveGenParams (TypeDef type_def)
+ {
+ GenericTypeRef gtr = ret_type as GenericTypeRef;
+ if (gtr != null)
+ ResolveGenParam ((PEAPI.GenParam)
gtr.PeapiType, type_def);
+
+ if (param_list == null)
+ return;
+
+ foreach (ParamDef param in param_list) {
+ gtr = param.Type as GenericTypeRef;
+ if (gtr != null)
+ ResolveGenParam ((PEAPI.GenParam)
gtr.PeapiType, type_def);
+ }
+ }
+
public PEAPI.MethodDef Resolve (CodeGen code_gen)
{
return Resolve (code_gen, null);
@@ -591,10 +643,10 @@
if (IsVararg)
signature = CreateVarargSignature (RetType,
name, param_list);
else
- signature = CreateSignature (RetType, name,
param_list);
+ signature = CreateSignature (RetType, name,
param_list, (typar_list != null ? typar_list.Count : 0));
}
- public static string CreateSignature (ITypeRef RetType, string
name, IList param_list)
+ public static string CreateSignature (ITypeRef RetType, string
name, IList param_list, int gen_param_count)
{
StringBuilder builder = new StringBuilder ();
@@ -613,6 +665,7 @@
}
}
builder.Append (')');
+ builder.AppendFormat ("`{0}", gen_param_count);
return builder.ToString ();
}
@@ -685,7 +738,7 @@
return builder.ToString ();
}
- public static string CreateSignature (ITypeRef RetType, string
name, ITypeRef[] param_list)
+ public static string CreateSignature (ITypeRef RetType, string
name, ITypeRef[] param_list, int gen_param_count)
{
StringBuilder builder = new StringBuilder ();
@@ -706,6 +759,7 @@
}
}
builder.Append (')');
+ builder.AppendFormat ("`{0}", gen_param_count);
return builder.ToString ();
}
Modified: trunk/mcs/ilasm/codegen/MethodPointerTypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/MethodPointerTypeRef.cs 2005-12-09 12:48:52 UTC
(rev 54159)
+++ trunk/mcs/ilasm/codegen/MethodPointerTypeRef.cs 2005-12-09 13:02:33 UTC
(rev 54160)
@@ -97,9 +97,9 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param);
+ return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
Modified: trunk/mcs/ilasm/codegen/MethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/MethodRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/MethodRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -23,15 +23,17 @@
private PEAPI.Method peapi_method;
private bool is_resolved;
+ private int gen_param_count;
public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
- ITypeRef ret_type, string name, ITypeRef[] param)
+ ITypeRef ret_type, string name, ITypeRef[] param, int
gen_param_count)
{
this.owner = owner;
this.call_conv = call_conv;
this.ret_type = ret_type;
this.name = name;
this.param = param;
+ this.gen_param_count = gen_param_count;
is_resolved = false;
}
@@ -54,6 +56,9 @@
return;
TypeDef owner_def =
code_gen.TypeManager[owner.FullName];
+ if (owner_def == null)
+ throw new Exception (String.Format ("Reference
to undefined class '{0}'", owner.FullName));
+
string write_name;
if (name == "<init>")
@@ -64,7 +69,7 @@
string sig;
if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
- sig = MethodDef.CreateSignature (ret_type,
name, param);
+ sig = MethodDef.CreateSignature (ret_type,
name, param, gen_param_count);
peapi_method = owner_def.ResolveMethod (sig,
code_gen);
} else {
sig = MethodDef.CreateVarargSignature
(ret_type, name, param);
Modified: trunk/mcs/ilasm/codegen/PrimitiveTypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/PrimitiveTypeRef.cs 2005-12-09 12:48:52 UTC (rev
54159)
+++ trunk/mcs/ilasm/codegen/PrimitiveTypeRef.cs 2005-12-09 13:02:33 UTC (rev
54160)
@@ -80,14 +80,15 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- string key = full_name + MethodDef.CreateSignature
(ret_type, name, param) + sig_mod;
+ string key = full_name + MethodDef.CreateSignature
(ret_type, name, param, gen_param_count) + sig_mod;
TypeSpecMethodRef mr = method_table [key] as
TypeSpecMethodRef;
if (mr != null)
return mr;
- mr = new TypeSpecMethodRef (this, ret_type, call_conv,
name, param);
+ //FIXME: generic methodref for primitive type?
+ mr = new TypeSpecMethodRef (this, ret_type, call_conv,
name, param, gen_param_count);
method_table [key] = mr;
return mr;
}
Modified: trunk/mcs/ilasm/codegen/Sentinel.cs
===================================================================
--- trunk/mcs/ilasm/codegen/Sentinel.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/codegen/Sentinel.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -50,9 +50,9 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
- return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param);
+ return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
Modified: trunk/mcs/ilasm/codegen/TypeDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/TypeDef.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/codegen/TypeDef.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -243,6 +243,18 @@
typar_list.Add (gi);
}
+ public int GetGenericParamNum (string id)
+ {
+ if (typar_list == null)
+ // FIXME: Report error
+ throw new Exception (String.Format ("Invalid
type parameter '{0}'", id));
+
+ foreach (GenericInfo gi in typar_list)
+ if (gi.Id == id)
+ return gi.num;
+ return -1;
+ }
+
public void AddGenericConstraint (int index, ITypeRef
constraint)
{
GenericInfo gi = (GenericInfo) typar_list[index];
@@ -393,7 +405,7 @@
parent_type.Resolve (code_gen);
string over_name = (string) decl.Value;
IMethodRef over_meth =
parent_type.GetMethodRef (body.RetType,
- body.CallConv,
over_name, body.ParamTypeList ());
+ body.CallConv,
over_name, body.ParamTypeList (), body.GenParamCount);
over_meth.Resolve (code_gen);
classdef.AddMethodOverride
(over_meth.PeapiMethod,
body.PeapiMethodDef);
Modified: trunk/mcs/ilasm/codegen/TypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/TypeRef.cs 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/codegen/TypeRef.cs 2005-12-09 13:02:33 UTC (rev 54160)
@@ -65,9 +65,9 @@
}
public IMethodRef GetMethodRef (ITypeRef ret_type,
- PEAPI.CallConv call_conv, string name, ITypeRef[]
param)
+ PEAPI.CallConv call_conv, string name, ITypeRef[]
param, int gen_param_count)
{
- return new MethodRef (this, call_conv, ret_type, name,
param);
+ return new MethodRef (this, call_conv, ret_type, name,
param, gen_param_count);
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
Modified: trunk/mcs/ilasm/codegen/TypeSpecMethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/TypeSpecMethodRef.cs 2005-12-09 12:48:52 UTC
(rev 54159)
+++ trunk/mcs/ilasm/codegen/TypeSpecMethodRef.cs 2005-12-09 13:02:33 UTC
(rev 54160)
@@ -22,18 +22,22 @@
private ITypeRef ret_type;
private string name;
private ITypeRef[] param;
+ private int gen_param_count;
private bool is_resolved;
public TypeSpecMethodRef (ITypeRef owner,
ITypeRef ret_type, PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int
gen_param_count)
{
this.owner = owner;
this.call_conv = call_conv;
this.ret_type = ret_type;
this.name = name;
this.param = param;
+ this.gen_param_count = gen_param_count;
+ if (gen_param_count > 0)
+ CallConv |= PEAPI.CallConv.Generic;
is_resolved = false;
}
@@ -75,7 +79,7 @@
owner.Resolve (code_gen);
peapi_method = code_gen.PEFile.AddMethodToTypeSpec
(owner.PeapiType, write_name,
- ret_type.PeapiType, param_list);
+ ret_type.PeapiType, param_list,
gen_param_count);
peapi_method.AddCallConv (call_conv);
Modified: trunk/mcs/ilasm/parser/ChangeLog
===================================================================
--- trunk/mcs/ilasm/parser/ChangeLog 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/parser/ChangeLog 2005-12-09 13:02:33 UTC (rev 54160)
@@ -1,3 +1,18 @@
+2005-12-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay (class_decl | D_OVERRIDE ..): Update usage of
ITypeRef.GetMethodRef
+ and MethodDef.CreateSignature .
+ (method_head | D_METHOD ..): Update usage of MethodDef.ctor .
+ Use MethodDef.ResolveGenParams to resolve VARs/MVARs in parameter list.
+ (type | K_CLASS slashed_name ..): Remove redundant rule.
+ (type | BANG id): New. Generic type parameter.
+ (type | BANG BANG id): New. Generic method type parameter.
+ (instr | INSTR_FIELD type ..): Resolve generic param for 'type'.
+ (method_ref | call_conv ..): Set MethodRef's GenParamCount.
+ (method_ref | call_conv type ..): Update usage of
TypeSpecMethodRef.ctor and GetMethodRef.
+ (method_ref | call_conv type ..): New. Rule for global generic method
refs.
+ (custom_type | call_conv ..): Update usage of GlobalMethodRef.ctor .
+
2005-12-05 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (type | BANG int32 .. ): Update to use GenParam instead
of
Modified: trunk/mcs/ilasm/parser/ILParser.jay
===================================================================
--- trunk/mcs/ilasm/parser/ILParser.jay 2005-12-09 12:48:52 UTC (rev 54159)
+++ trunk/mcs/ilasm/parser/ILParser.jay 2005-12-09 13:02:33 UTC (rev 54160)
@@ -611,6 +611,10 @@
;
extends_clause : /* EMPTY */
+ | K_EXTENDS K_CLASS class_ref typars_clause
+ {
+ $$ = $2;
+ }
| K_EXTENDS class_ref
{
$$ = $2;
@@ -770,11 +774,11 @@
param_list = new ITypeRef[0];
decl = owner.GetMethodRef ((ITypeRef) $7,
- (CallConv) $6, (string) $4,
param_list);
+ (CallConv) $6, (string) $4,
param_list, 0);
// NOTICE: `owner' here might be wrong
string sig = MethodDef.CreateSignature (owner,
(string) $10,
-
param_list);
+
param_list, 0);
codegen.CurrentTypeDef.AddOverride (sig,
decl);
}
OPEN_PARENS sig_args CLOSE_PARENS
@@ -943,10 +947,24 @@
GenParam gpar = new GenParam ((int) $3, "",
GenParamType.MVar);
$$ = new GenericTypeRef (gpar, $3.ToString ());
}
- | K_CLASS slashed_name OPEN_ANGLE_BRACKET BANG int32
CLOSE_ANGLE_BRACKET
+ | BANG id
{
- $$ = new TypeRef ((string) $2, false, null);
+ int num = -1;
+ string name = (string) $2;
+ if (codegen.CurrentTypeDef != null)
+ num =
codegen.CurrentTypeDef.GetGenericParamNum (name);
+ GenParam gpar = new GenParam (num, name,
GenParamType.Var);
+ $$ = new GenericTypeRef (gpar, name);
}
+ | BANG BANG id
+ {
+ int num = -1;
+ string name = (string) $3;
+ if (codegen.CurrentMethodDef != null)
+ num =
codegen.CurrentMethodDef.GetGenericParamNum (name);
+ GenParam gpar = new GenParam (num, name,
GenParamType.MVar);
+ $$ = new GenericTypeRef (gpar, name);
+ }
| K_CLASS slashed_name OPEN_ANGLE_BRACKET typars
CLOSE_ANGLE_BRACKET
{
ArrayList typar_list = (ArrayList) $4;
@@ -1676,19 +1694,15 @@
MethodDef methdef = new MethodDef (
codegen, (MethAttr) $2, cc,
(ImplAttr) $11, (string) $6,
(ITypeRef) $5,
- (ArrayList) $9,
tokenizer.Reader.Location);
+ (ArrayList) $9,
tokenizer.Reader.Location, (ArrayList) $7);
if (pinvoke_info) {
ExternModule mod =
codegen.ExternTable.AddModule (pinvoke_mod);
methdef.AddPInvokeInfo (pinvoke_attr,
mod, pinvoke_meth);
pinvoke_info = false;
}
-
- if ($7 != null) {
- ArrayList typars_list = (ArrayList) $7;
- foreach (string id in typars_list)
- methdef.AddGenericParam (id);
- }
+
+ methdef.ResolveGenParams
(codegen.CurrentTypeDef);
}
| D_METHOD meth_attr call_conv param_attr type
K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS
method_name
@@ -1697,7 +1711,7 @@
MethodDef methdef = new MethodDef (
codegen, (MethAttr) $2, (CallConv) $3,
(ImplAttr) $14, (string) $10,
(ITypeRef) $5,
- (ArrayList) $12,
tokenizer.Reader.Location);
+ (ArrayList) $12,
tokenizer.Reader.Location, null);
if (pinvoke_info) {
ExternModule mod =
codegen.ExternTable.AddModule (pinvoke_mod);
@@ -2234,6 +2248,9 @@
{
ITypeRef owner = (ITypeRef) $3;
+ GenericTypeRef gtr = $2 as GenericTypeRef;
+ if (gtr != null && codegen.CurrentMethodDef !=
null)
+
codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType,
codegen.CurrentTypeDef);
IFieldRef fieldref = owner.GetFieldRef (
(ITypeRef) $2, (string) $5);
@@ -2316,7 +2333,7 @@
}
methref = owner.GetMethodRef ((ITypeRef) $2,
- (CallConv) $1, (string) $5,
param_list);
+ (CallConv) $1, (string) $5,
param_list, 0);
$$ = methref;
}
@@ -2332,13 +2349,36 @@
param_list = new ITypeRef[0];
$$ = new GlobalMethodRef ((ITypeRef) $2,
(CallConv) $1,
- (string) $3, param_list);
+ (string) $3, param_list, 0);
}
+ | call_conv type method_name typars_clause
+ OPEN_PARENS type_list CLOSE_PARENS
+ {
+ ArrayList arg_list = (ArrayList) $6;
+ ArrayList tp = (ArrayList) $4;
+ ITypeRef[] param_list;
+
+ if (arg_list != null)
+ param_list = (ITypeRef[])
arg_list.ToArray (typeof (ITypeRef));
+ else
+ param_list = new ITypeRef[0];
+
+ IMethodRef methref = new GlobalMethodRef
((ITypeRef) $2, (CallConv) $1,
+ (string) $3, param_list, (tp != null ?
tp.Count : 0));
+
+ if (tp != null) {
+ ITypeRef[] ta = (ITypeRef[])
tp.ToArray (typeof (ITypeRef));
+ methref = new GenericMethodRef
(methref, new GenericMethodSig (ta));
+ }
+
+ $$ = methref;
+ }
| call_conv type type_spec DOUBLE_COLON method_name
typars_clause OPEN_PARENS type_list CLOSE_PARENS
{
ITypeRef owner = (ITypeRef) $3;
ArrayList arg_list = (ArrayList) $8;
+ ArrayList tp = (ArrayList) $6;
ITypeRef[] param_list;
IMethodRef methref;
@@ -2349,17 +2389,14 @@
if (owner.UseTypeSpec) {
methref = new TypeSpecMethodRef
(owner, (ITypeRef) $2,
- (CallConv) $1, (string) $5,
param_list);
+ (CallConv) $1, (string) $5,
param_list, (tp != null ? tp.Count : 0));
} else {
methref = owner.GetMethodRef
((ITypeRef) $2,
- (CallConv) $1, (string) $5,
param_list);
+ (CallConv) $1, (string) $5,
param_list, (tp != null ? tp.Count : 0));
}
- if ($6 != null) {
- ArrayList tp = (ArrayList) $6;
+ if (tp != null) {
ITypeRef[] ta = (ITypeRef[])
tp.ToArray (typeof (ITypeRef));
-
- methref.CallConv |= CallConv.Generic;
methref = new GenericMethodRef
(methref, new GenericMethodSig (ta));
}
@@ -2563,7 +2600,7 @@
param_list = new ITypeRef[0];
$$ = owner.GetMethodRef ((ITypeRef) $2,
- (CallConv) $1, (string) $5,
param_list);
+ (CallConv) $1, (string) $5,
param_list, 0);
}
| call_conv type D_CTOR OPEN_PARENS type_list
CLOSE_PARENS
{
@@ -2576,7 +2613,7 @@
param_list = new ITypeRef[0];
$$ = new GlobalMethodRef ((ITypeRef) $2,
(CallConv) $1,
- (string) $3, param_list);
+ (string) $3, param_list, 0);
}
;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches