Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/ilasm
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2008-06-01 20:17:31 +0400
committerAnkit Jain <radical@corewars.org>2008-06-01 20:17:31 +0400
commite1bc7598075a44573438a287272c8d85d55e8186 (patch)
tree510e7308d2516f47ff8efb52524df7b9df206907 /mcs/ilasm
parent2f04b53293837a57b52dead4e103177888fd1876 (diff)
In ilasm/codegen:
Fix bug #364580. * MethodDef.cs (CreateSignature): Add new @include_optional and @call_conv param. Make private. (CreateVarargSignature): Likewise. (CreateSignature): Add new static method for vararg and other methods. (GetVarargSig): Add new @full_signature param to uniquely identify vararg methods. * CodeGen.cs (ResolveVarargMethod): This now takes two signatures - one with only the required params and the other with the optional ones, to correctly resolve global vararg methods. * BaseTypeRef.cs: * GenericTypeInst.cs: * GlobalMethodRef.cs: * PrimitiveTypeRef.cs: * TypeDef.cs: Track api changes. In ilasm/parser: * ILParser.jay: Track api changes. svn path=/trunk/mcs/; revision=104628
Diffstat (limited to 'mcs/ilasm')
-rw-r--r--mcs/ilasm/codegen/BaseTypeRef.cs2
-rw-r--r--mcs/ilasm/codegen/ChangeLog20
-rw-r--r--mcs/ilasm/codegen/CodeGen.cs12
-rw-r--r--mcs/ilasm/codegen/GenericTypeInst.cs2
-rw-r--r--mcs/ilasm/codegen/GlobalMethodRef.cs10
-rw-r--r--mcs/ilasm/codegen/MethodDef.cs38
-rw-r--r--mcs/ilasm/codegen/PrimitiveTypeRef.cs2
-rw-r--r--mcs/ilasm/codegen/TypeDef.cs10
-rw-r--r--mcs/ilasm/parser/ChangeLog4
-rw-r--r--mcs/ilasm/parser/ILParser.jay4
10 files changed, 69 insertions, 35 deletions
diff --git a/mcs/ilasm/codegen/BaseTypeRef.cs b/mcs/ilasm/codegen/BaseTypeRef.cs
index 293007fb6fd..b690e4d792c 100644
--- a/mcs/ilasm/codegen/BaseTypeRef.cs
+++ b/mcs/ilasm/codegen/BaseTypeRef.cs
@@ -64,7 +64,7 @@ namespace Mono.ILASM {
BaseMethodRef mr = null;
/* Note: FullName not reqd as this is cached per object */
- string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ string key = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
if (method_table == null)
method_table = new Hashtable ();
else
diff --git a/mcs/ilasm/codegen/ChangeLog b/mcs/ilasm/codegen/ChangeLog
index 4ad8728be70..a084e7e6f09 100644
--- a/mcs/ilasm/codegen/ChangeLog
+++ b/mcs/ilasm/codegen/ChangeLog
@@ -1,3 +1,23 @@
+2008-06-01 Ankit Jain <jankit@novell.com>
+
+ Fix bug #364580.
+ * MethodDef.cs (CreateSignature): Add new @include_optional and
+ @call_conv param. Make private.
+ (CreateVarargSignature): Likewise.
+ (CreateSignature): Add new static method for vararg and other methods.
+ (GetVarargSig): Add new @full_signature param to uniquely identify
+ vararg methods.
+
+ * CodeGen.cs (ResolveVarargMethod): This now takes two signatures - one
+ with only the required params and the other with the optional ones, to
+ correctly resolve global vararg methods.
+
+ * BaseTypeRef.cs:
+ * GenericTypeInst.cs:
+ * GlobalMethodRef.cs:
+ * PrimitiveTypeRef.cs:
+ * TypeDef.cs: Track api changes.
+
2008-04-10 Erven Rohou <erven.rohou@st.com>
* DebuggingInfo.cs: use new DefineMethod API. Remove useless
diff --git a/mcs/ilasm/codegen/CodeGen.cs b/mcs/ilasm/codegen/CodeGen.cs
index f3d9bf02d1c..b0b1803c180 100644
--- a/mcs/ilasm/codegen/CodeGen.cs
+++ b/mcs/ilasm/codegen/CodeGen.cs
@@ -171,7 +171,7 @@ namespace Mono.ILASM {
public GlobalMethodRef GetGlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
string name, BaseTypeRef[] param, int gen_param_count)
{
- string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ string key = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
GlobalMethodRef methref = null;
@@ -515,13 +515,15 @@ namespace Mono.ILASM {
return methoddef.Resolve (this);
}
- public PEAPI.Method ResolveVarargMethod (string signature,
+ public PEAPI.Method ResolveVarargMethod (string sig_only_required_params, string sig_with_optional_params,
CodeGen code_gen, PEAPI.Type[] opt)
{
- MethodDef methoddef = (MethodDef) global_method_table[signature];
- methoddef.Resolve (code_gen);
+ MethodDef methoddef = (MethodDef) global_method_table [sig_only_required_params];
+ if (methoddef == null)
+ Report.Error ("Unable to resolve global method : " + sig_only_required_params);
- return methoddef.GetVarargSig (opt);
+ methoddef.Resolve (code_gen);
+ return methoddef.GetVarargSig (opt, sig_with_optional_params);
}
public PEAPI.Field ResolveField (string name, string type_name)
diff --git a/mcs/ilasm/codegen/GenericTypeInst.cs b/mcs/ilasm/codegen/GenericTypeInst.cs
index 94a29bc30aa..6634f418b63 100644
--- a/mcs/ilasm/codegen/GenericTypeInst.cs
+++ b/mcs/ilasm/codegen/GenericTypeInst.cs
@@ -99,7 +99,7 @@ namespace Mono.ILASM {
string meth_name, BaseTypeRef[] param, int gen_param_count)
{
/* Note: Using FullName here as we are caching in a static hashtable */
- string key = FullName + MethodDef.CreateSignature (ret_type, meth_name, param, gen_param_count);
+ string key = FullName + MethodDef.CreateSignature (ret_type, call_conv, meth_name, param, gen_param_count, true);
TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
if (mr == null) {
mr = new TypeSpecMethodRef (this, call_conv, ret_type, meth_name, param, gen_param_count);
diff --git a/mcs/ilasm/codegen/GlobalMethodRef.cs b/mcs/ilasm/codegen/GlobalMethodRef.cs
index fb85d1af4b6..6a47aa002d1 100644
--- a/mcs/ilasm/codegen/GlobalMethodRef.cs
+++ b/mcs/ilasm/codegen/GlobalMethodRef.cs
@@ -26,10 +26,8 @@ namespace Mono.ILASM {
if (is_resolved)
return;
- string sig;
-
if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
- sig = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ string sig = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, false);
peapi_method = code_gen.ResolveMethod (sig);
} else {
ArrayList opt_list = new ArrayList ();
@@ -42,8 +40,10 @@ namespace Mono.ILASM {
opt_list.Add (type.PeapiType);
}
}
- sig = MethodDef.CreateVarargSignature (ret_type, name, param);
- peapi_method = code_gen.ResolveVarargMethod (sig, code_gen,
+
+ string sig_only_required_params = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, false);
+ string sig_with_optional_params = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
+ peapi_method = code_gen.ResolveVarargMethod (sig_only_required_params, sig_with_optional_params, code_gen,
(PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
}
diff --git a/mcs/ilasm/codegen/MethodDef.cs b/mcs/ilasm/codegen/MethodDef.cs
index b7e8288679c..c32a219b08f 100644
--- a/mcs/ilasm/codegen/MethodDef.cs
+++ b/mcs/ilasm/codegen/MethodDef.cs
@@ -414,27 +414,21 @@ namespace Mono.ILASM {
return param_array;
}
- public PEAPI.MethodRef GetVarargSig (PEAPI.Type[] opt)
+ public PEAPI.MethodRef GetVarargSig (PEAPI.Type[] opt, string full_signature)
{
if (!is_resolved)
throw new InternalErrorException ("Methods must be resolved before a vararg sig can be created.");
PEAPI.MethodRef methref = null;
- StringBuilder sigbuilder = new StringBuilder ();
- string sig;
- foreach (PEAPI.Type t in opt)
- sigbuilder.Append (opt + ", ");
- sig = sigbuilder.ToString ();
-
if (vararg_sig_table == null) {
vararg_sig_table = new Hashtable ();
} else {
- methref = vararg_sig_table [sig] as PEAPI.MethodRef;
+ methref = vararg_sig_table [full_signature] as PEAPI.MethodRef;
}
if (methref == null) {
methref = methoddef.MakeVarArgSignature (opt);
- vararg_sig_table [sig] = methref;
+ vararg_sig_table [full_signature] = methref;
}
return methref;
@@ -689,7 +683,7 @@ namespace Mono.ILASM {
signature = CreateSignature (RetType, name, param_list, GenParamCount);
}
- public static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count)
+ static string CreateSignature (BaseTypeRef RetType, string name, IList param_list, int gen_param_count)
{
StringBuilder builder = new StringBuilder ();
@@ -714,7 +708,7 @@ namespace Mono.ILASM {
return builder.ToString ();
}
- public static string CreateVarargSignature (BaseTypeRef RetType, string name, IList param_list)
+ static string CreateVarargSignature (BaseTypeRef RetType, string name, IList param_list)
{
StringBuilder builder = new StringBuilder ();
ParamDef last = null;
@@ -747,7 +741,19 @@ namespace Mono.ILASM {
return builder.ToString ();
}
- public static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list)
+ // @include_optional: include optional parameters for vararg methods
+ // This will be true mostly for *Ref use, eg. methodrefs at call sites
+ // and false for *Def (include only the required params)
+ public static string CreateSignature (BaseTypeRef RetType, PEAPI.CallConv call_conv, string name,
+ BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
+ {
+ if ((call_conv & PEAPI.CallConv.Vararg) != 0)
+ return CreateVarargSignature (RetType, name, param_list, include_optional);
+ else
+ return CreateSignature (RetType, name, param_list, gen_param_count, include_optional);
+ }
+
+ static string CreateVarargSignature (BaseTypeRef RetType, string name, BaseTypeRef [] param_list, bool include_optional)
{
StringBuilder builder = new StringBuilder ();
BaseTypeRef last = null;
@@ -765,13 +771,13 @@ namespace Mono.ILASM {
builder.Append (param.FullName);
first = false;
last = param;
- if (param is SentinelTypeRef)
+ if (!include_optional && param is SentinelTypeRef)
break;
}
}
- if (last == null || !(last is SentinelTypeRef)) {
+ if (!include_optional && (last == null || !(last is SentinelTypeRef))) {
if (!first)
builder.Append (',');
builder.Append ("...");
@@ -782,7 +788,7 @@ namespace Mono.ILASM {
return builder.ToString ();
}
- public static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count)
+ static string CreateSignature (BaseTypeRef RetType, string name, BaseTypeRef[] param_list, int gen_param_count, bool include_optional)
{
StringBuilder builder = new StringBuilder ();
@@ -800,7 +806,7 @@ namespace Mono.ILASM {
builder.Append (',');
builder.Append (param.FullName);
first = false;
- if (param is SentinelTypeRef)
+ if (!include_optional && param is SentinelTypeRef)
break;
}
}
diff --git a/mcs/ilasm/codegen/PrimitiveTypeRef.cs b/mcs/ilasm/codegen/PrimitiveTypeRef.cs
index 0280725d245..40a52290355 100644
--- a/mcs/ilasm/codegen/PrimitiveTypeRef.cs
+++ b/mcs/ilasm/codegen/PrimitiveTypeRef.cs
@@ -82,7 +82,7 @@ namespace Mono.ILASM {
string name, BaseTypeRef[] param, int gen_param_count)
{
/* Use FullName also here, as we are caching in a static hashtable */
- string key = FullName + MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ string key = FullName + MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
if (mr != null)
return mr;
diff --git a/mcs/ilasm/codegen/TypeDef.cs b/mcs/ilasm/codegen/TypeDef.cs
index 0f6bbe49c49..1a16eba5547 100644
--- a/mcs/ilasm/codegen/TypeDef.cs
+++ b/mcs/ilasm/codegen/TypeDef.cs
@@ -480,7 +480,7 @@ namespace Mono.ILASM {
public PEAPI.Method ResolveMethod (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
string name, BaseTypeRef [] param, int gen_param_count, CodeGen code_gen)
{
- string signature = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ string signature = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, false);
MethodDef methoddef = (MethodDef) method_table[signature];
if (methoddef != null)
@@ -491,12 +491,14 @@ namespace Mono.ILASM {
public PEAPI.Method ResolveVarargMethod (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
string name, BaseTypeRef [] param, int gen_param_count, PEAPI.Type [] opt, CodeGen code_gen)
{
- string signature = MethodDef.CreateVarargSignature (ret_type, name, param);
+ // Only MethodDef sig required to lookup in the method_table
+ string signature = MethodDef.CreateSignature (ret_type, call_conv, name, param, 0, false);
MethodDef methoddef = (MethodDef) method_table[signature];
-
if (methoddef != null) {
methoddef.Resolve (code_gen, classdef);
- return methoddef.GetVarargSig (opt);
+ return methoddef.GetVarargSig (
+ opt,
+ MethodDef.CreateSignature (ret_type, call_conv, name, param, 0, true));
}
return ResolveAsMethodRef (ret_type, call_conv, name, param, gen_param_count, code_gen);
diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog
index 83d61ab8392..567c2d791d8 100644
--- a/mcs/ilasm/parser/ChangeLog
+++ b/mcs/ilasm/parser/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-01 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay: Track api changes.
+
2008-03-05 Ankit Jain <jankit@novell.com>
* ILParser.jay (custom_type): Allow any method name.
diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay
index d3c44d77c39..bf9820bc5ba 100644
--- a/mcs/ilasm/parser/ILParser.jay
+++ b/mcs/ilasm/parser/ILParser.jay
@@ -915,8 +915,8 @@ class_decl : method_all
(CallConv) $6, (string) $4, param_list, 0);
// NOTICE: `owner' here might be wrong
- string sig = MethodDef.CreateSignature (owner, (string) $10,
- param_list, 0);
+ string sig = MethodDef.CreateSignature (owner, (CallConv) $6, (string) $10,
+ param_list, 0, false);
codegen.CurrentTypeDef.AddOverride (sig, decl);
}
OPEN_PARENS sig_args CLOSE_PARENS