Author: ankit
Date: 2006-01-09 11:12:24 -0500 (Mon, 09 Jan 2006)
New Revision: 55238
Added:
trunk/mcs/ilasm/codegen/GenericParamRef.cs
Removed:
trunk/mcs/ilasm/codegen/GenericTypeRef.cs
Modified:
trunk/mcs/class/PEAPI/ChangeLog
trunk/mcs/class/PEAPI/Metadata.cs
trunk/mcs/class/PEAPI/PEAPI.cs
trunk/mcs/ilasm/ChangeLog
trunk/mcs/ilasm/codegen/ChangeLog
trunk/mcs/ilasm/codegen/GenericTypeInst.cs
trunk/mcs/ilasm/codegen/Local.cs
trunk/mcs/ilasm/codegen/MethodDef.cs
trunk/mcs/ilasm/ilasm.exe.sources
trunk/mcs/ilasm/parser/ChangeLog
trunk/mcs/ilasm/parser/ILParser.jay
Log:
In ilasm/codegen:
* GenericTypeRef.cs: Rename to ..
* GenericParamRef.cs: .. this.
(IGenericTypeRef): New.
(GenericParamRef): Implement IGenericTypeRef.
* GenericTypeInst.cs (GenericTypeInst): Implement IGenericTypeRef
instead
of IClassRef.
(GenericTypeInst.ResolveOnly): Rename to ResolveNoTypeSpec to implement
IGenericTypeRef.ResolveNoTypeSpec .
* MethodDef.cs (MethodDef.ResolveGenParams): Update to use
GenericParamRef.
* Local.cs (Local.GetPeapiLocal): Use IGenericTypeRef.
In ilasm:
* ilasm.exe.sources: Replace GenericTypeRef.cs with GenericParamRef.cs
In ilasm/parser:
* ILParser.jay: Update to use GenericParamRef instead of GenericTypeRef.
In class/PEAPI:
* PEAPI.cs (PEFile.AddGenricParam): New. Adds a GenParam to the TypeSpec
table.
* Metadata.cs (GenParam): Inherit from 'Class' instead of 'Type'.
(GenParam.name): Rename to param_name as it hides Class.name .
(GenParam.GetTypeSpec): Override to create TypeSpec for genparam.
Modified: trunk/mcs/class/PEAPI/ChangeLog
===================================================================
--- trunk/mcs/class/PEAPI/ChangeLog 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/class/PEAPI/ChangeLog 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1,3 +1,11 @@
+2006-01-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * PEAPI.cs (PEFile.AddGenricParam): New. Adds a GenParam to the TypeSpec
+ table.
+ * Metadata.cs (GenParam): Inherit from 'Class' instead of 'Type'.
+ (GenParam.name): Rename to param_name as it hides Class.name .
+ (GenParam.GetTypeSpec): Override to create TypeSpec for genparam.
+
2006-01-08 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (TypeOp): Add 'constrained' op.
Modified: trunk/mcs/class/PEAPI/Metadata.cs
===================================================================
--- trunk/mcs/class/PEAPI/Metadata.cs 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/class/PEAPI/Metadata.cs 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1978,15 +1978,15 @@
}
- public class GenParam : Type {
+ public class GenParam : Class {
private int index;
- private string name;
+ private string param_name;
public GenParam (int index, string name, GenParamType ptype) :
base ((byte) ptype)
{
this.index = index;
- this.name = name;
+ this.param_name = name;
tabIx = MDTable.TypeSpec;
}
@@ -1996,17 +1996,27 @@
}
public string Name {
- get { return name; }
- set { name = value; }
+ get { return param_name; }
+ set { param_name = value; }
}
public GenParamType Type {
get { return (GenParamType) GetTypeIndex (); }
}
+
+ internal override MetaDataElement GetTypeSpec(MetaData md)
+ {
+ if (typeSpec == null) {
+ typeSpec = new TypeSpec(this,md);
+ md.AddToTable(MDTable.TypeSpec,typeSpec);
+ }
+ return typeSpec;
+ }
+
internal sealed override void TypeSig(MemoryStream str)
{
if (index < 0)
- throw new Exception (String.Format ("Unresolved
{0} - {1}", (GenParamType) GetTypeIndex (), name));
+ throw new Exception (String.Format ("Unresolved
{0} - {1}", (GenParamType) GetTypeIndex (), param_name));
str.WriteByte(typeIndex);
MetaData.CompressNum ((uint) index, str);
}
Modified: trunk/mcs/class/PEAPI/PEAPI.cs
===================================================================
--- trunk/mcs/class/PEAPI/PEAPI.cs 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/class/PEAPI/PEAPI.cs 2006-01-09 16:12:24 UTC (rev 55238)
@@ -896,6 +896,11 @@
metaData.AddToTable (MDTable.TypeSpec, gti);
}
+ public void AddGenericParam (GenParam param)
+ {
+ param.GetTypeSpec (metaData);
+ }
+
public FileRef AddFile(string fName, byte[] hashBytes, bool
hasMetaData, bool entryPoint)
{
FileRef file = new
FileRef(fName,hashBytes,hasMetaData,entryPoint,metaData);
Modified: trunk/mcs/ilasm/ChangeLog
===================================================================
--- trunk/mcs/ilasm/ChangeLog 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/ChangeLog 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1,3 +1,7 @@
+2006-01-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ilasm.exe.sources: Replace GenericTypeRef.cs with GenericParamRef.cs
+
2006-01-07 Ankit Jain <[EMAIL PROTECTED]>
* ilasm.exe.sources: Add GenericParameters.cs to the build.
Modified: trunk/mcs/ilasm/codegen/ChangeLog
===================================================================
--- trunk/mcs/ilasm/codegen/ChangeLog 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/codegen/ChangeLog 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1,3 +1,16 @@
+2006-01-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * GenericTypeRef.cs: Rename to ..
+ * GenericParamRef.cs: .. this.
+ (IGenericTypeRef): New.
+ (GenericParamRef): Implement IGenericTypeRef.
+ * GenericTypeInst.cs (GenericTypeInst): Implement IGenericTypeRef
instead
+ of IClassRef.
+ (GenericTypeInst.ResolveOnly): Rename to ResolveNoTypeSpec to implement
+ IGenericTypeRef.ResolveNoTypeSpec .
+ * MethodDef.cs (MethodDef.ResolveGenParams): Update to use
GenericParamRef.
+ * Local.cs (Local.GetPeapiLocal): Use IGenericTypeRef.
+
2006-01-08 Ankit Jain <[EMAIL PROTECTED]>
* InstrTable.cs (inst_table): Add stelem.any, ldelem.any and
Copied: trunk/mcs/ilasm/codegen/GenericParamRef.cs (from rev 55220,
trunk/mcs/ilasm/codegen/GenericTypeRef.cs)
===================================================================
--- trunk/mcs/ilasm/codegen/GenericTypeRef.cs 2006-01-09 06:19:55 UTC (rev
55220)
+++ trunk/mcs/ilasm/codegen/GenericParamRef.cs 2006-01-09 16:12:24 UTC (rev
55238)
@@ -0,0 +1,132 @@
+//
+// Mono.ILASM.GenericParamRef
+//
+// Author(s):
+// Jackson Harper ([EMAIL PROTECTED])
+// Ankit Jain ([EMAIL PROTECTED])
+//
+// (C) 2003 Jackson Harper, All rights reserved
+// (C) 2006 Novell, Inc (http://www.novell.com)
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public interface IGenericTypeRef : IClassRef {
+ /* Used to resolve any gen params in arguments, constraints
etc */
+ void Resolve (GenericParameters type_gen_params,
GenericParameters method_gen_params);
+
+ /* Only resolves, does not add it to the TypeSpec
+ table */
+ void ResolveNoTypeSpec (CodeGen code_gen);
+ }
+
+ public class GenericParamRef : ModifiableType, IGenericTypeRef {
+
+ /* Might get modified */
+ private PEAPI.Type type;
+ /* Unmodified GenParam */
+ private PEAPI.GenParam param;
+ private string full_name;
+ private string sig_mod;
+ private bool is_resolved;
+ private bool is_added; /* Added to TypeSpec table ? */
+
+ public GenericParamRef (PEAPI.GenParam gen_param, string
full_name)
+ : this (gen_param, full_name, null)
+ {
+ }
+
+ public GenericParamRef (PEAPI.GenParam gen_param, string
full_name, ArrayList conv_list)
+ {
+ this.type = gen_param;
+ this.param = gen_param;
+ this.full_name = full_name;
+ sig_mod = String.Empty;
+ is_resolved = false;
+ is_added = false;
+ if (conv_list != null)
+ ConversionList = conv_list;
+ }
+
+ public string FullName {
+ get {
+ return (param.Type == PEAPI.GenParamType.Var ?
"!" : "!!")
+ + param.Index + sig_mod;
+ }
+ }
+
+ public override string SigMod {
+ get { return sig_mod; }
+ set { sig_mod = value; }
+ }
+
+ public PEAPI.Type PeapiType {
+ get { return type; }
+ }
+
+ public PEAPI.Class PeapiClass {
+ get { return (PEAPI.Class) type; }
+ }
+
+ public void MakeValueClass ()
+ {
+ throw new Exception ("Not supported");
+ }
+
+ public IClassRef Clone ()
+ {
+ return new GenericParamRef (param, full_name,
(ArrayList) ConversionList.Clone ());
+ }
+
+ public GenericTypeInst GetGenericTypeInst (GenericArguments
gen_args)
+ {
+ throw new Exception ("Not supported");
+ }
+
+ public PEAPI.Type ResolveInstance (CodeGen code_gen,
GenericArguments gen_args)
+ {
+ throw new Exception ("Not supported");
+ }
+
+ public void ResolveNoTypeSpec (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ type = Modify (code_gen, type);
+ is_resolved = true;
+ }
+
+ public void Resolve (CodeGen code_gen)
+ {
+ ResolveNoTypeSpec (code_gen);
+ if (is_added)
+ return;
+
+ code_gen.PEFile.AddGenericParam (param);
+ is_added = true;
+ }
+
+ public void Resolve (GenericParameters type_gen_params,
GenericParameters method_gen_params)
+ {
+ throw new Exception ("Not implemented yet");
+ }
+
+ public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
+ string name, ITypeRef[] param, int
gen_param_count)
+ {
+ return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
+ }
+
+ public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
+ {
+ return new TypeSpecFieldRef (this, ret_type, name);
+ }
+ }
+
+}
+
Modified: trunk/mcs/ilasm/codegen/GenericTypeInst.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericTypeInst.cs 2006-01-09 16:08:10 UTC (rev
55237)
+++ trunk/mcs/ilasm/codegen/GenericTypeInst.cs 2006-01-09 16:12:24 UTC (rev
55238)
@@ -15,7 +15,7 @@
namespace Mono.ILASM {
- public class GenericTypeInst : ModifiableType, IClassRef {
+ public class GenericTypeInst : ModifiableType, IGenericTypeRef {
private IClassRef class_ref;
private PEAPI.Type ptype;
@@ -89,9 +89,7 @@
throw new Exception (String.Format ("Invalid attempt
to create '{0}''{1}'", FullName, gen_args.ToString ()));
}
- /* Only resolves, does not add it to the TypeSpec
- table */
- public void ResolveOnly (CodeGen code_gen)
+ public void ResolveNoTypeSpec (CodeGen code_gen)
{
if (is_resolved)
return;
@@ -106,7 +104,7 @@
public void Resolve (CodeGen code_gen)
{
- ResolveOnly (code_gen);
+ ResolveNoTypeSpec (code_gen);
if (is_added)
return;
@@ -114,6 +112,11 @@
is_added = true;
}
+ public void Resolve (GenericParameters type_gen_params,
GenericParameters method_gen_params)
+ {
+ throw new Exception ("Not implemented yet");
+ }
+
public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
string meth_name, ITypeRef[] param, int
gen_param_count)
{
Deleted: trunk/mcs/ilasm/codegen/GenericTypeRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericTypeRef.cs 2006-01-09 16:08:10 UTC (rev
55237)
+++ trunk/mcs/ilasm/codegen/GenericTypeRef.cs 2006-01-09 16:12:24 UTC (rev
55238)
@@ -1,62 +0,0 @@
-//
-// Mono.ILASM.GenericTypeRef
-//
-// Author(s):
-// Jackson Harper ([EMAIL PROTECTED])
-//
-// (C) 2003 Jackson Harper, All rights reserved
-//
-
-
-using System;
-
-namespace Mono.ILASM {
-
- public class GenericTypeRef : ModifiableType, ITypeRef {
-
- private PEAPI.Type type;
- private string full_name;
- private string sig_mod;
-
- public GenericTypeRef (PEAPI.GenParam gen_param, string
full_name)
- {
- this.type = gen_param;
- this.full_name = full_name;
- sig_mod = String.Empty;
- }
-
- public string FullName {
- get {
- PEAPI.GenParam gp = (PEAPI.GenParam) type;
- return (gp.Type == PEAPI.GenParamType.Var ? "!"
: "!!") + gp.Index + sig_mod;
- }
- }
-
- public override string SigMod {
- get { return sig_mod; }
- set { sig_mod = value; }
- }
-
- public PEAPI.Type PeapiType {
- get { return type; }
- }
-
- public void Resolve (CodeGen code_gen)
- {
- type = Modify (code_gen, type);
- }
-
- public IMethodRef GetMethodRef (ITypeRef ret_type,
PEAPI.CallConv call_conv,
- string name, ITypeRef[] param, int
gen_param_count)
- {
- return new TypeSpecMethodRef (this, ret_type,
call_conv, name, param, gen_param_count);
- }
-
- public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
- {
- return new TypeSpecFieldRef (this, ret_type, name);
- }
- }
-
-}
-
Modified: trunk/mcs/ilasm/codegen/Local.cs
===================================================================
--- trunk/mcs/ilasm/codegen/Local.cs 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/codegen/Local.cs 2006-01-09 16:12:24 UTC (rev 55238)
@@ -45,11 +45,11 @@
public PEAPI.Local GetPeapiLocal (CodeGen code_gen)
{
int ec = code_gen.Report.ErrorCount;
- GenericTypeInst gti = type as GenericTypeInst;
- if (gti == null)
+ IGenericTypeRef gtr = type as IGenericTypeRef;
+ if (gtr == null)
type.Resolve (code_gen);
else
- gti.ResolveOnly (code_gen);
+ gtr.ResolveNoTypeSpec (code_gen);
if (code_gen.Report.ErrorCount > ec)
return null;
Modified: trunk/mcs/ilasm/codegen/MethodDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/MethodDef.cs 2006-01-09 16:08:10 UTC (rev
55237)
+++ trunk/mcs/ilasm/codegen/MethodDef.cs 2006-01-09 16:12:24 UTC (rev
55238)
@@ -296,7 +296,7 @@
public void ResolveGenParams ()
{
- GenericTypeRef gtr = ret_type as GenericTypeRef;
+ GenericParamRef gtr = ret_type as GenericParamRef;
if (gtr != null)
ResolveGenParam ((PEAPI.GenParam)
gtr.PeapiType);
@@ -304,7 +304,7 @@
return;
foreach (ParamDef param in param_list) {
- gtr = param.Type as GenericTypeRef;
+ gtr = param.Type as GenericParamRef;
if (gtr != null)
ResolveGenParam ((PEAPI.GenParam)
gtr.PeapiType);
}
Modified: trunk/mcs/ilasm/ilasm.exe.sources
===================================================================
--- trunk/mcs/ilasm/ilasm.exe.sources 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/ilasm.exe.sources 2006-01-09 16:12:24 UTC (rev 55238)
@@ -54,7 +54,7 @@
codegen/CatchBlock.cs
codegen/CustomAttr.cs
codegen/DeclSecurity.cs
-codegen/GenericTypeRef.cs
+codegen/GenericParamRef.cs
codegen/GenericTypeInst.cs
codegen/TypeSpecMethodRef.cs
codegen/TypeSpecFieldRef.cs
Modified: trunk/mcs/ilasm/parser/ChangeLog
===================================================================
--- trunk/mcs/ilasm/parser/ChangeLog 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/parser/ChangeLog 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1,3 +1,7 @@
+2006-01-09 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay: Update to use GenericParamRef instead of
GenericTypeRef.
+
2006-01-08 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (constraint_decl): Remove. This syntax is no longer used.
Modified: trunk/mcs/ilasm/parser/ILParser.jay
===================================================================
--- trunk/mcs/ilasm/parser/ILParser.jay 2006-01-09 16:08:10 UTC (rev 55237)
+++ trunk/mcs/ilasm/parser/ILParser.jay 2006-01-09 16:12:24 UTC (rev 55238)
@@ -1008,12 +1008,12 @@
| BANG int32
{
GenParam gpar = new GenParam ((int) $2, "",
GenParamType.Var);
- $$ = new GenericTypeRef (gpar, $2.ToString ());
+ $$ = new GenericParamRef (gpar, $2.ToString
());
}
| BANG BANG int32
{
GenParam gpar = new GenParam ((int) $3, "",
GenParamType.MVar);
- $$ = new GenericTypeRef (gpar, $3.ToString ());
+ $$ = new GenericParamRef (gpar, $3.ToString
());
}
| BANG id
{
@@ -1022,7 +1022,7 @@
if (codegen.CurrentTypeDef != null)
num =
codegen.CurrentTypeDef.GetGenericParamNum (name);
GenParam gpar = new GenParam (num, name,
GenParamType.Var);
- $$ = new GenericTypeRef (gpar, name);
+ $$ = new GenericParamRef (gpar, name);
}
| BANG BANG id
{
@@ -1031,7 +1031,7 @@
if (codegen.CurrentMethodDef != null)
num =
codegen.CurrentMethodDef.GetGenericParamNum (name);
GenParam gpar = new GenParam (num, name,
GenParamType.MVar);
- $$ = new GenericTypeRef (gpar, name);
+ $$ = new GenericParamRef (gpar, name);
}
;
@@ -2338,9 +2338,9 @@
{
ITypeRef owner = (ITypeRef) $3;
- GenericTypeRef gtr = $2 as GenericTypeRef;
- if (gtr != null && codegen.CurrentMethodDef !=
null)
-
codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gtr.PeapiType);
+ GenericParamRef gpr = $2 as GenericParamRef;
+ if (gpr != null && codegen.CurrentMethodDef !=
null)
+
codegen.CurrentMethodDef.ResolveGenParam ((PEAPI.GenParam) gpr.PeapiType);
IFieldRef fieldref = owner.GetFieldRef (
(ITypeRef) $2, (string) $5);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches