Author: ankit
Date: 2005-04-12 10:56:28 -0400 (Tue, 12 Apr 2005)
New Revision: 42836
Modified:
trunk/mcs/class/PEAPI/ChangeLog
trunk/mcs/class/PEAPI/PEAPI.cs
trunk/mcs/ilasm/codegen/ChangeLog
trunk/mcs/ilasm/codegen/CodeGen.cs
trunk/mcs/ilasm/codegen/CustomAttr.cs
trunk/mcs/ilasm/codegen/EventDef.cs
trunk/mcs/ilasm/codegen/ExternTable.cs
trunk/mcs/ilasm/codegen/FieldDef.cs
trunk/mcs/ilasm/codegen/MethodDef.cs
trunk/mcs/ilasm/codegen/ParamDef.cs
trunk/mcs/ilasm/codegen/PropertyDef.cs
trunk/mcs/ilasm/codegen/TypeDef.cs
trunk/mcs/ilasm/parser/ChangeLog
trunk/mcs/ilasm/parser/ILParser.jay
Log:
In class/PEAPI:
2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
* PEAPI.cs (CustomAttribute.ctor): Dont throw
NotYetImplementedException.
(MethodSemantics.SortKey): Should be sorted by
'Association' column.
In ilasm/codegen:
2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
* CustomAttr.cs (ICustomAttrTarget): New interface.
* TypeDef.cs: Implement ICustomAttrTarget.
* FieldDef.cs, PropertyDef.cs, ParamDef.cs, EventDef.cs
(AddCustomAttribute): Implement ICustomAttrTarget
(.Resolve): Add custom attributes.
* CodeGen.cs (CurrentCustomAttrTarget): New. Property for
current CustomAttr target.
(BeginTypeDef, BeginMethodDef, BeginAssemblyRef): Set
current_customattrtarget accordingly.
* ExternTable.cs (ExternRef): Implement ICustomAttrTarget.
(ExternModule.Resolve): Add custom attributes to ModuleRef.
(ExternAssembly.Resolve): Add custom attributes to AssemblyRef.
* MethodDef.cs: Implement ICustomAttrTarget and add custom
attributes.
(GetParam): New. Get ParamDef by index.
In ilasm/parser:
2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (class_decl, method_decl, prop_decl,
assemblyref_decl | customattr_decl): Use
codegen.CurrentCustomAttrTarget for adding custom
attributes.
(field_decl, method_decl, event_head, prop_head):
Set codegen.CurrentCustomAttrTarget
Modified: trunk/mcs/class/PEAPI/ChangeLog
===================================================================
--- trunk/mcs/class/PEAPI/ChangeLog 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/class/PEAPI/ChangeLog 2005-04-12 14:56:28 UTC (rev 42836)
@@ -1,3 +1,10 @@
+2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
+
+ * PEAPI.cs (CustomAttribute.ctor): Dont throw
+ NotYetImplementedException.
+ (MethodSemantics.SortKey): Should be sorted by
+ 'Association' column.
+
2005-04-08 Ankit Jain <[EMAIL PROTECTED]>
* PEAPI.cs (MSCorLib.GetSpecialClass): Don't encode
Modified: trunk/mcs/class/PEAPI/PEAPI.cs
===================================================================
--- trunk/mcs/class/PEAPI/PEAPI.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/class/PEAPI/PEAPI.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -2698,7 +2698,6 @@
type = constrType;
cVal = val;
tabIx = MDTable.CustomAttribute;
- throw(new NotYetImplementedException("Custom Attributes "));
}
internal CustomAttribute(MetaDataElement paren, Method constrType,
@@ -5716,7 +5715,7 @@
}
internal override uint SortKey() {
- return meth.Row;
+ return eventOrProp.Row;
}
internal sealed override uint Size(MetaData md) {
Modified: trunk/mcs/ilasm/codegen/ChangeLog
===================================================================
--- trunk/mcs/ilasm/codegen/ChangeLog 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/ChangeLog 2005-04-12 14:56:28 UTC (rev 42836)
@@ -1,3 +1,21 @@
+2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
+
+ * CustomAttr.cs (ICustomAttrTarget): New interface.
+ * TypeDef.cs: Implement ICustomAttrTarget.
+ * FieldDef.cs, PropertyDef.cs, ParamDef.cs, EventDef.cs
+ (AddCustomAttribute): Implement ICustomAttrTarget
+ (.Resolve): Add custom attributes.
+ * CodeGen.cs (CurrentCustomAttrTarget): New. Property for
+ current CustomAttr target.
+ (BeginTypeDef, BeginMethodDef, BeginAssemblyRef): Set
+ current_customattrtarget accordingly.
+ * ExternTable.cs (ExternRef): Implement ICustomAttrTarget.
+ (ExternModule.Resolve): Add custom attributes to ModuleRef.
+ (ExternAssembly.Resolve): Add custom attributes to AssemblyRef.
+ * MethodDef.cs: Implement ICustomAttrTarget and add custom
+ attributes.
+ (GetParam): New. Get ParamDef by index.
+
2005-04-08 Ankit Jain <[EMAIL PROTECTED]>
* MethodDef.cs (named_param_table, CreateNamedParamTable): Remove.
Modified: trunk/mcs/ilasm/codegen/CodeGen.cs
===================================================================
--- trunk/mcs/ilasm/codegen/CodeGen.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/CodeGen.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -32,6 +32,7 @@
private ArrayList typedef_stack;
private int typedef_stack_top;
private SymbolWriter symwriter;
+ private ICustomAttrTarget current_customattrtarget;
private byte [] assembly_public_key;
private int assembly_major_version;
@@ -133,6 +134,11 @@
get { return current_moduleref; }
}
+ public ICustomAttrTarget CurrentCustomAttrTarget {
+ get { return current_customattrtarget; }
+ set { current_customattrtarget = value; }
+ }
+
public ExternTable ExternTable {
get { return extern_table; }
}
@@ -228,7 +234,7 @@
typedef.OuterType = outer;
type_manager[cache_name] = typedef;
- current_typedef = typedef;
+ current_customattrtarget = current_typedef = typedef;
typedef_stack.Add (typedef);
typedef_stack_top++;
}
@@ -267,7 +273,7 @@
methoddef);
}
- current_methoddef = methoddef;
+ current_customattrtarget = current_methoddef =
methoddef;
}
public void EndMethodDef (Location location)
@@ -292,7 +298,7 @@
public void BeginAssemblyRef (string name, AssemblyName
asmb_name)
{
- current_assemblyref = ExternTable.AddAssembly (name,
asmb_name);
+ current_customattrtarget = current_assemblyref =
ExternTable.AddAssembly (name, asmb_name);
}
public void EndAssemblyRef ()
Modified: trunk/mcs/ilasm/codegen/CustomAttr.cs
===================================================================
--- trunk/mcs/ilasm/codegen/CustomAttr.cs 2005-04-12 14:33:53 UTC (rev
42835)
+++ trunk/mcs/ilasm/codegen/CustomAttr.cs 2005-04-12 14:56:28 UTC (rev
42836)
@@ -9,10 +9,14 @@
using System;
+using System.Collections;
-
namespace Mono.ILASM {
+ public interface ICustomAttrTarget {
+ void AddCustomAttribute (CustomAttr customattr);
+ }
+
public class CustomAttr {
private IMethodRef method_ref;
Modified: trunk/mcs/ilasm/codegen/EventDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/EventDef.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/EventDef.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -13,13 +13,14 @@
namespace Mono.ILASM {
- public class EventDef {
+ public class EventDef : ICustomAttrTarget {
private FeatureAttr attr;
private string name;
private ITypeRef type;
private PEAPI.Event event_def;
private bool is_resolved;
+ private ArrayList customattr_list;
private MethodRef addon;
private MethodRef fire;
@@ -34,6 +35,14 @@
is_resolved = false;
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
public PEAPI.Event Resolve (CodeGen code_gen, PEAPI.ClassDef
classdef)
{
if (is_resolved)
@@ -47,6 +56,10 @@
if ((attr & FeatureAttr.Specialname) != 0)
event_def.SetSpecialName ();
+
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen, event_def);
is_resolved = true;
Modified: trunk/mcs/ilasm/codegen/ExternTable.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ExternTable.cs 2005-04-12 14:33:53 UTC (rev
42835)
+++ trunk/mcs/ilasm/codegen/ExternTable.cs 2005-04-12 14:56:28 UTC (rev
42836)
@@ -13,11 +13,12 @@
namespace Mono.ILASM {
- public abstract class ExternRef {
+ public abstract class ExternRef : ICustomAttrTarget {
protected string name;
protected Hashtable class_table;
protected Hashtable typeref_table;
+ protected ArrayList customattr_list;
public abstract void Resolve (CodeGen codegen);
public abstract PEAPI.IExternRef GetExternRef ();
@@ -29,6 +30,14 @@
class_table = new Hashtable ();
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
public ExternTypeRef GetTypeRef (string full_name, bool
is_valuetype, ExternTable table)
{
ExternTypeRef type_ref = typeref_table [full_name] as
ExternTypeRef;
@@ -86,6 +95,9 @@
public override void Resolve (CodeGen codegen)
{
ModuleRef = codegen.PEFile.AddExternModule (name);
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (codegen, ModuleRef);
}
@@ -105,8 +117,6 @@
private string locale;
private byte [] hash;
- private ArrayList cattrs_list;
-
public ExternAssembly (string name, AssemblyName asmb_name) :
base (name)
{
this.name = name;
@@ -127,10 +137,9 @@
if (hash != null)
AssemblyRef.AddHash (hash);
- if (cattrs_list != null) {
- foreach (CustomAttr cattr in cattrs_list)
- cattr.AddTo (code_gen, AssemblyRef);
- }
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen,
AssemblyRef);
class_table = new Hashtable ();
}
@@ -168,12 +177,6 @@
this.hash = hash;
}
- public void AddCustomAttribute (CustomAttr cattr)
- {
- if (cattrs_list == null)
- cattrs_list = new ArrayList ();
- cattrs_list.Add (cattr);
- }
}
Modified: trunk/mcs/ilasm/codegen/FieldDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/FieldDef.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/FieldDef.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -9,15 +9,17 @@
using System;
+using System.Collections;
namespace Mono.ILASM {
- public class FieldDef {
+ public class FieldDef : ICustomAttrTarget {
private string name;
private ITypeRef type;
private PEAPI.FieldAttr attr;
private PEAPI.FieldDef field_def;
+ private ArrayList customattr_list;
private bool offset_set;
private bool datavalue_set;
@@ -79,6 +81,14 @@
this.at_data_id = at_data_id;
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
public PEAPI.FieldDef Resolve (CodeGen code_gen)
{
if (is_resolved)
@@ -100,6 +110,10 @@
type.Resolve (code_gen);
field_def = classdef.AddField (attr, name,
type.PeapiType);
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen, field_def);
+
is_resolved = true;
return field_def;
Modified: trunk/mcs/ilasm/codegen/MethodDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/MethodDef.cs 2005-04-12 14:33:53 UTC (rev
42835)
+++ trunk/mcs/ilasm/codegen/MethodDef.cs 2005-04-12 14:56:28 UTC (rev
42836)
@@ -15,7 +15,7 @@
namespace Mono.ILASM {
- public class MethodDef {
+ public class MethodDef : ICustomAttrTarget {
protected class GenericInfo {
public string Id;
@@ -64,7 +64,6 @@
this.param_list = param_list;
inst_list = new ArrayList ();
- customattr_list = new ArrayList ();
label_table = new Hashtable ();
labelref_table = new Hashtable ();
label_list = new ArrayList ();
@@ -176,6 +175,15 @@
}
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+
public void AddLocals (ArrayList local_list)
{
int slot_pos = this.local_list.Count;
@@ -218,6 +226,14 @@
return pos;
}
+ public ParamDef GetParam (int index)
+ {
+ if (param_list [index] != null)
+ return (ParamDef)param_list [index];
+ else
+ return null;
+ }
+
public void InitLocals ()
{
init_locals = true;
@@ -238,11 +254,6 @@
this.max_stack = max_stack;
}
- public void AddCustomAttr (CustomAttr customattr)
- {
- customattr_list.Add (customattr);
- }
-
public PEAPI.MethodDef Resolve (CodeGen code_gen)
{
if (is_resolved)
@@ -400,8 +411,9 @@
methoddef.SetMaxStack (max_stack);
/// Add the custrom attributes to this method
- foreach (CustomAttr customattr in customattr_list)
- customattr.AddTo (code_gen, methoddef);
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen, methoddef);
if (pinvoke_info) {
methoddef.AddPInvokeInfo
(pinvoke_mod.ModuleRef,
Modified: trunk/mcs/ilasm/codegen/ParamDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/ParamDef.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/ParamDef.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -9,6 +9,7 @@
using System;
+using System.Collections;
namespace Mono.ILASM {
@@ -16,7 +17,7 @@
/// <summary>
/// Definition of a parameter passed to a method
/// </summary>
- public class ParamDef {
+ public class ParamDef : ICustomAttrTarget {
private PEAPI.ParamAttr attr;
private string name;
@@ -24,6 +25,7 @@
private bool is_defined;
private PEAPI.Param peapi_param;
private PEAPI.Constant defval;
+ private ArrayList customattr_list;
public static readonly ParamDef Ellipsis = new ParamDef (new
PEAPI.ParamAttr (), "ELLIPSIS", null);
@@ -41,6 +43,14 @@
defval = cVal;
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
public ITypeRef Type {
get { return typeref; }
}
@@ -75,6 +85,10 @@
peapi_param.AddDefaultValue (defval);
}
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen,
peapi_param);
+
is_defined = true;
}
}
Modified: trunk/mcs/ilasm/codegen/PropertyDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/PropertyDef.cs 2005-04-12 14:33:53 UTC (rev
42835)
+++ trunk/mcs/ilasm/codegen/PropertyDef.cs 2005-04-12 14:56:28 UTC (rev
42836)
@@ -13,7 +13,7 @@
namespace Mono.ILASM {
- public class PropertyDef {
+ public class PropertyDef : ICustomAttrTarget {
private FeatureAttr attr;
private string name;
@@ -21,6 +21,7 @@
private ArrayList arg_list;
private PEAPI.Property prop_def;
private bool is_resolved;
+ private ArrayList customattr_list;
private MethodRef _get;
private MethodRef _set;
@@ -36,6 +37,14 @@
is_resolved = false;
}
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
public PEAPI.Property Resolve (CodeGen code_gen,
PEAPI.ClassDef classdef)
{
if (is_resolved)
@@ -58,6 +67,11 @@
if ((attr & FeatureAttr.Specialname) != 0)
prop_def.SetSpecialName ();
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in
customattr_list)
+ customattr.AddTo (code_gen, prop_def);
+
+
is_resolved = true;
return prop_def;
Modified: trunk/mcs/ilasm/codegen/TypeDef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/TypeDef.cs 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/codegen/TypeDef.cs 2005-04-12 14:56:28 UTC (rev 42836)
@@ -13,7 +13,7 @@
namespace Mono.ILASM {
- public class TypeDef {
+ public class TypeDef : ICustomAttrTarget {
protected class GenericInfo {
public string Id;
Modified: trunk/mcs/ilasm/parser/ChangeLog
===================================================================
--- trunk/mcs/ilasm/parser/ChangeLog 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/parser/ChangeLog 2005-04-12 14:56:28 UTC (rev 42836)
@@ -1,3 +1,12 @@
+2005-04-12 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay (class_decl, method_decl, prop_decl,
+ assemblyref_decl | customattr_decl): Use
+ codegen.CurrentCustomAttrTarget for adding custom
+ attributes.
+ (field_decl, method_decl, event_head, prop_head):
+ Set codegen.CurrentCustomAttrTarget
+
2005-04-08 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay (type): When parsing K_VALUETYPE, mark the typeref
Modified: trunk/mcs/ilasm/parser/ILParser.jay
===================================================================
--- trunk/mcs/ilasm/parser/ILParser.jay 2005-04-12 14:33:53 UTC (rev 42835)
+++ trunk/mcs/ilasm/parser/ILParser.jay 2005-04-12 14:56:28 UTC (rev 42836)
@@ -660,7 +660,7 @@
| extsource_spec
| customattr_decl
{
- codegen.CurrentTypeDef.AddCustomAttribute
((CustomAttr) $1);
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| D_SIZE int32
{
@@ -1146,6 +1146,7 @@
FieldDef field_def = new FieldDef((FieldAttr)
$3,
(string) $5, (ITypeRef) $4);
codegen.AddFieldDef (field_def);
+ codegen.CurrentCustomAttrTarget = field_def;
if ($2 != null) {
field_def.SetOffset ((uint) $2);
@@ -1716,6 +1717,7 @@
| D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt
{
codegen.CurrentMethodDef.AddParamDefaultValue
((int)$3 - 1, (Constant)$5);
+ codegen.CurrentCustomAttrTarget =
codegen.CurrentMethodDef.GetParam ((int)$3 - 1);
}
| id COLON
{
@@ -1728,7 +1730,7 @@
| language_decl
| customattr_decl
{
- codegen.CurrentMethodDef.AddCustomAttr
((CustomAttr) $1);
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| data_decl
;
@@ -2195,6 +2197,7 @@
EventDef event_def = new EventDef
((FeatureAttr) $2,
(ITypeRef) $3, (string) $4);
codegen.CurrentTypeDef.BeginEventDef
(event_def);
+ codegen.CurrentCustomAttrTarget = event_def;
}
| D_EVENT event_attr id
;
@@ -2253,6 +2256,7 @@
PropertyDef prop_def = new PropertyDef
((FeatureAttr) $2, (ITypeRef) $3,
(string) $4, (ArrayList) $6);
codegen.CurrentTypeDef.BeginPropertyDef
(prop_def);
+ codegen.CurrentCustomAttrTarget = prop_def;
if ($8 != null) {
prop_def.AddInitValue ((Constant) $8);
@@ -2294,6 +2298,9 @@
codegen.CurrentTypeDef.CurrentProperty.AddOther ((MethodRef) $2);
}
| customattr_decl
+ {
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ }
| extsource_spec
| language_decl
;
@@ -2524,7 +2531,7 @@
}
| customattr_decl
{
- codegen.CurrentAssemblyRef.AddCustomAttribute
((CustomAttr) $1);
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches