Permalink
Browse files

In ilasm/codegen:

	* MethodDef.cs (MethodDef.ctor): Add type_def param. Use this for all uses of
	the owner type_def. ResolveGenParams () before creating signature.
	(MethodDef.ResolveGenParams):
	(MethodDef.ResolveGenParam): Remove type_def param, instead use type_def field.
	(MethodDef.Define): Remove overload with typedef param.
	(MethodDef.CreateSignature): Put "`0" right after the name instead of at the end.
	* TypeDef.cs (TypeDef.DefineContents): Update usage of MethodDef.Define .

In ilasm/parser:

	* ILParser.jay (method_head | ..): Update usage of MethodDef.ctor to pass
	codegen.CurrentTypeDef also. ResolveGenParams is called by MethodDef internally.
	(instr | INSTR_FIELD ..): Update usage of MethodDef.ResolveGenParam .

svn path=/trunk/mcs/; revision=54722
  • Loading branch information...
1 parent 30e9659 commit d7aad4519333c7cb7a440c1bcd399c0c580347d4 @radical radical committed Dec 22, 2005
@@ -1,3 +1,13 @@
+2005-12-22 Ankit Jain <jankit@novell.com>
+
+ * MethodDef.cs (MethodDef.ctor): Add type_def param. Use this for all uses of
+ the owner type_def. ResolveGenParams () before creating signature.
+ (MethodDef.ResolveGenParams):
+ (MethodDef.ResolveGenParam): Remove type_def param, instead use type_def field.
+ (MethodDef.Define): Remove overload with typedef param.
+ (MethodDef.CreateSignature): Put "`0" right after the name instead of at the end.
+ * TypeDef.cs (TypeDef.DefineContents): Update usage of MethodDef.Define .
+
2005-12-21 Ankit Jain <jankit@novell.com>
* GenericArguments.cs (GenericArguments): New.
@@ -53,18 +53,20 @@ protected class GenericInfo {
private PEAPI.PInvokeAttr pinvoke_attr;
private SourceMethod source;
private PEAPI.NativeType ret_native_type;
+ private TypeDef type_def;
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, ArrayList typars_list)
+ Location start, ArrayList typars_list, TypeDef type_def)
{
this.meth_attr = meth_attr;
this.call_conv = call_conv;
this.impl_attr = impl_attr;
this.name = name;
this.ret_type = ret_type;
this.param_list = param_list;
+ this.type_def = type_def;
inst_list = new ArrayList ();
label_table = new Hashtable ();
@@ -82,6 +84,7 @@ protected class GenericInfo {
is_defined = false;
is_resolved = false;
AddGenericParams (typars_list);
+ ResolveGenParams ();
CreateSignature ();
codegen.BeginMethodDef (this);
@@ -302,7 +305,7 @@ public void SetMaxStack (int max_stack)
this.max_stack = max_stack;
}
- public void ResolveGenParam (PEAPI.GenParam gpar, TypeDef type_def)
+ public void ResolveGenParam (PEAPI.GenParam gpar)
{
if (gpar.Index != -1)
return;
@@ -319,19 +322,19 @@ public void ResolveGenParam (PEAPI.GenParam gpar, TypeDef type_def)
gpar.Name));
}
- public void ResolveGenParams (TypeDef type_def)
+ public void ResolveGenParams ()
{
GenericTypeRef gtr = ret_type as GenericTypeRef;
if (gtr != null)
- ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType, type_def);
+ ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType);
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);
+ ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType);
}
}
@@ -420,30 +423,19 @@ public PEAPI.MethodRef GetVarargSig (PEAPI.Type[] opt)
}
/// <summary>
- /// Define a global method
- /// </summary>
- public void Define (CodeGen code_gen)
- {
- if (is_defined)
- return;
-
- Resolve (code_gen);
-
- WriteCode (code_gen, methoddef);
-
- //code_gen.Report.Message (String.Format ("Assembled method '<Module>'::{0}", name));
- is_defined = true;
- }
-
- /// <summary>
/// Define a member method
/// </summary>
- public void Define (CodeGen code_gen, TypeDef typedef)
+ public void Define (CodeGen code_gen)
{
if (is_defined)
return;
- Resolve (code_gen, (PEAPI.ClassDef) typedef.ClassDef);
+ if (type_def == null)
+ /* Global method */
+ Resolve (code_gen, null);
+ else
+ Resolve (code_gen, (PEAPI.ClassDef) type_def.ClassDef);
+
WriteCode (code_gen, methoddef);
//code_gen.Report.Message (String.Format ("Assembled method {0}::{1}", typedef.FullName, name)); is_defined = true;
@@ -653,6 +645,7 @@ public static string CreateSignature (ITypeRef RetType, string name, IList param
builder.Append (RetType.FullName);
builder.Append (" ");
builder.Append (name);
+ builder.AppendFormat ("`{0}", gen_param_count);
builder.Append ('(');
if (param_list != null) {
@@ -665,7 +658,6 @@ public static string CreateSignature (ITypeRef RetType, string name, IList param
}
}
builder.Append (')');
- builder.AppendFormat ("`{0}", gen_param_count);
return builder.ToString ();
}
@@ -745,6 +737,7 @@ public static string CreateSignature (ITypeRef RetType, string name, ITypeRef[]
builder.Append (RetType.FullName);
builder.Append (" ");
builder.Append (name);
+ builder.AppendFormat ("`{0}", gen_param_count);
builder.Append ('(');
if (param_list != null) {
@@ -759,7 +752,6 @@ public static string CreateSignature (ITypeRef RetType, string name, ITypeRef[]
}
}
builder.Append (')');
- builder.AppendFormat ("`{0}", gen_param_count);
return builder.ToString ();
}
@@ -394,7 +394,7 @@ public void DefineContents (CodeGen code_gen)
classdef.SetFieldOrder (fielddef_list);
foreach (MethodDef methoddef in method_table.Values) {
- methoddef.Define (code_gen, this);
+ methoddef.Define (code_gen);
}
if (event_list != null) {
@@ -1,3 +1,9 @@
+2005-12-22 Ankit Jain <jankit@novell.com>
+
+ * ILParser.jay (method_head | ..): Update usage of MethodDef.ctor to pass
+ codegen.CurrentTypeDef also. ResolveGenParams is called by MethodDef internally.
+ (instr | INSTR_FIELD ..): Update usage of MethodDef.ResolveGenParam .
+
2005-12-21 Ankit Jain <jankit@novell.com>
* ILParser.jay: Update to use new GenericArguments class for 'typars'.
@@ -1727,15 +1727,13 @@ method_head : D_METHOD meth_attr call_conv param_attr type method_name
MethodDef methdef = new MethodDef (
codegen, (MethAttr) $2, cc,
(ImplAttr) $11, (string) $6, (ITypeRef) $5,
- (ArrayList) $9, tokenizer.Reader.Location, (ArrayList) $7);
+ (ArrayList) $9, tokenizer.Reader.Location, (ArrayList) $7, codegen.CurrentTypeDef);
if (pinvoke_info) {
ExternModule mod = codegen.ExternTable.AddModule (pinvoke_mod);
methdef.AddPInvokeInfo (pinvoke_attr, mod, pinvoke_meth);
pinvoke_info = false;
}
-
- methdef.ResolveGenParams (codegen.CurrentTypeDef);
}
| D_METHOD meth_attr call_conv param_attr type
K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS method_name
@@ -1744,7 +1742,7 @@ method_head : D_METHOD meth_attr call_conv param_attr type method_name
MethodDef methdef = new MethodDef (
codegen, (MethAttr) $2, (CallConv) $3,
(ImplAttr) $14, (string) $10, (ITypeRef) $5,
- (ArrayList) $12, tokenizer.Reader.Location, null);
+ (ArrayList) $12, tokenizer.Reader.Location, null, codegen.CurrentTypeDef);
if (pinvoke_info) {
ExternModule mod = codegen.ExternTable.AddModule (pinvoke_mod);
@@ -2283,7 +2281,7 @@ instr : INSTR_NONE
ITypeRef owner = (ITypeRef) $3;
GenericTypeRef gtr = $2 as GenericTypeRef;
if (gtr != null && codegen.CurrentMethodDef != null)
- codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType, codegen.CurrentTypeDef);
+ codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType);
IFieldRef fieldref = owner.GetFieldRef (
(ITypeRef) $2, (string) $5);

0 comments on commit d7aad45

Please sign in to comment.