Author: ankit
Date: 2006-06-01 05:56:15 -0400 (Thu, 01 Jun 2006)
New Revision: 61359
Added:
branches/mono-1-1-13/mcs/ilasm/errors/err-cattr.il
branches/mono-1-1-13/mcs/ilasm/tests/test-cattr-1.il
Modified:
branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog
branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs
branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs
branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog
branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs
branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs
branches/mono-1-1-13/mcs/ilasm/errors/ChangeLog
branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog
branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay
branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog
Log:
In ilasm/tests:
* test-cattr-1.il: New. Test for custom attributes on return type of
a method.
In ilasm/codegen:
2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
* MethodDef.cs (MethodDef): Use a ParamDef for return type, instead of a
BaseTypeRef.
(MethodDef.ctor): Update.
(MethodDef.AddParamDefaultValue): Remove.
(MethodDef.GetParam): Likewise.
(MethodDef.Resolve): Update to use ret_param instead of ret_type.
2006-05-31 Ankit Jain <[EMAIL PROTECTED]>
* TypeDef.cs (TypeDef.IsValueType): New.
(TypeDef.IsEnumType): New.
(TypeDef.Define): Don't seal System.ValueType or System.Enum .
In ilasm/errors:
* err-cattr.il: New.
In ilasm/parser:
* ILParser.jay (method_decl | D_PARAM ..): Param index is zero-based,
with zero representing the return value.
Update to check CurrentCustomAttrTarget for null before using it.
In class/PEAPI:
* PEAPI.cs (PEFile.AddMethod): Add overload for return type as Param
instead of PEAPI.Type .
* Metadata.cs (MetaDataElement.HasCustomAttr): New. Temporary hack.
(Param.HasMarshalInfo): New.
(ClassDef.AddMethod): Add overload for return type as Param.
(MethodDef.ctor): Change internal .ctor's sig to take Param instead of
PEAPI.Type for return type.
(MethodDef.retType): Remove.
(MethodDef.TypeSig): Update to use ret_param always.
(MethodDef.BuildTables): Add ret_param to Param table only if it has
marshal info or custom attributes.
Modified: branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/class/PEAPI/ChangeLog 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -1,3 +1,17 @@
+2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
+
+ * PEAPI.cs (PEFile.AddMethod): Add overload for return type as Param
+ instead of PEAPI.Type .
+ * Metadata.cs (MetaDataElement.HasCustomAttr): New. Temporary hack.
+ (Param.HasMarshalInfo): New.
+ (ClassDef.AddMethod): Add overload for return type as Param.
+ (MethodDef.ctor): Change internal .ctor's sig to take Param instead of
+ PEAPI.Type for return type.
+ (MethodDef.retType): Remove.
+ (MethodDef.TypeSig): Update to use ret_param always.
+ (MethodDef.BuildTables): Add ret_param to Param table only if it has
+ marshal info or custom attributes.
+
2006-05-26 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (DeclSecurity): Rename to ..
Modified: branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/class/PEAPI/Metadata.cs 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -242,6 +242,8 @@
protected bool done = false;
protected MDTable tabIx;
protected bool sortTable = false;
+ //Temporary hack..
+ private bool has_custom_attrs = false;
internal MetaDataElement() { }
@@ -254,6 +256,11 @@
}
}
+ public bool HasCustomAttr {
+ get { return has_custom_attrs; }
+ set { has_custom_attrs = value; }
+ }
+
internal virtual uint GetCodedIx(CIx code) { return 0; }
/// <summary>
@@ -1328,6 +1335,10 @@
tabIx = MDTable.Param;
}
+ public bool HasMarshalInfo {
+ get { return marshalInfo != null; }
+ }
+
/// <summary>
/// Add a default value to this parameter
/// </summary>
@@ -1689,8 +1700,13 @@
/// <returns>a descriptor for this new method</returns>
public MethodDef AddMethod(string name, Type retType, Param[]
pars)
{
+ return AddMethod (name, new Param (ParamAttr.Default,
"", retType), pars);
+ }
+
+ public MethodDef AddMethod (string name, Param ret_param, Param
[] pars)
+ {
// Console.WriteLine("Adding method " + name + " to
class " + this.name);
- MethodDef meth = new MethodDef(metaData,name,retType,
pars);
+ MethodDef meth = new MethodDef(metaData,name,
ret_param, pars);
methods.Add(meth);
return meth;
}
@@ -1705,9 +1721,9 @@
/// <param name="pars">parameters</param>
/// <returns>a descriptor for this new method</returns>
public MethodDef AddMethod(MethAttr mAtts, ImplAttr iAtts,
string name,
- Type retType, Param[] pars) {
+ Param ret_param, Param [] pars) {
// Console.WriteLine("Adding method " + name + " to
class " + this.name);
- MethodDef meth = new
MethodDef(metaData,mAtts,iAtts,name,retType,pars);
+ MethodDef meth = new MethodDef (metaData, mAtts, iAtts,
name, ret_param, pars);
methods.Add(meth);
return meth;
}
@@ -3800,7 +3816,6 @@
// 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;
@@ -3817,21 +3832,23 @@
ImplMap pinvokeImpl;
Param ret_param;
-
- internal MethodDef(MetaData md, string name, Type retType,
Param[] pars) : base (name)
+ internal MethodDef (MetaData md, string name, Param ret_param,
Param [] pars)
+ : this (md, 0, 0, name, ret_param, pars)
{
- this.retType = retType;
- metaData = md;
- parList = pars;
- if (parList != null) numPars = parList.Length;
- tabIx = MDTable.Method;
}
internal MethodDef (MetaData md, MethAttr mAttrSet, ImplAttr
iAttrSet, string name,
- Type retType, Param [] pars) : this (md, name,
retType, pars)
+ Param ret_param, Param [] pars)
+ : base (name)
{
methFlags = (ushort)mAttrSet;
implFlags = (ushort)iAttrSet;
+ this.ret_param = ret_param;
+ metaData = md;
+ parList = pars;
+ if (parList != null)
+ numPars = parList.Length;
+ tabIx = MDTable.Method;
}
internal Param[] GetPars()
@@ -3917,7 +3934,6 @@
/* Add Marshal info for return type */
public void AddRetTypeMarshallInfo (NativeType marshallType)
{
- ret_param = new Param (ParamAttr.HasFieldMarshal, "",
retType);
ret_param.AddMarshallInfo (marshallType);
}
@@ -3952,7 +3968,7 @@
for (int i=0; i < numPars; i++) {
pars[i] = parList[i].GetParType();
}
- varArgSig = new
MethodRef(this,name,retType,pars,true,optPars, 0);
+ varArgSig = new MethodRef (this, name,
ret_param.GetParType (), pars, true, optPars, 0);
if (varArgSigList == null)
varArgSigList = new ArrayList ();
@@ -3966,9 +3982,9 @@
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);
+
+ ret_param.seqNo = 0;
+ ret_param.TypeSig (sig);
for (ushort i=0; i < numPars; i++) {
parList[i].seqNo = (ushort)(i+1);
parList[i].TypeSig(sig);
@@ -3997,7 +4013,7 @@
nameIx = md.AddToStringsHeap(name);
sigIx = GetSigIx(md);
parIx = md.TableIndex(MDTable.Param);
- if (ret_param != null) {
+ if (ret_param.HasMarshalInfo ||
ret_param.HasCustomAttr) {
md.AddToTable(MDTable.Param, ret_param);
ret_param.BuildTables(md);
}
Modified: branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs
===================================================================
--- branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/class/PEAPI/PEAPI.cs 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -760,9 +760,14 @@
/// <param name="retType">return type</param>
/// <param name="pars">method parameters</param>
/// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod (string name, Param ret_param, Param
[] pars)
+ {
+ return moduleClass.AddMethod (name, ret_param, pars);
+ }
+
public MethodDef AddMethod(string name, Type retType, Param[]
pars)
{
- return moduleClass.AddMethod(name,retType,pars);
+ return AddMethod (name, new Param (ParamAttr.Default,
"", retType), pars);
}
/// <summary>
@@ -774,9 +779,14 @@
/// <param name="retType">return type</param>
/// <param name="pars">method parameters</param>
/// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod (MethAttr mAtts, ImplAttr iAtts,
string name, Param ret_param, Param [] pars)
+ {
+ return moduleClass.AddMethod (mAtts, iAtts, name,
ret_param, pars);
+ }
+
public MethodDef AddMethod(MethAttr mAtts, ImplAttr iAtts,
string name, Type retType, Param[] pars)
{
- return
moduleClass.AddMethod(mAtts,iAtts,name,retType,pars);
+ return AddMethod (mAtts, iAtts, name, new Param
(ParamAttr.Default, "", retType), pars);
}
public MethodRef AddMethodToTypeSpec (Type item, string name,
Type retType, Type[] pars)
@@ -922,6 +932,7 @@
public void AddCustomAttribute (Method meth, byte [] data,
MetaDataElement element)
{
metaData.AddCustomAttribute (new CustomAttribute
(element, meth, data));
+ element.HasCustomAttr = true;
}
public void AddDeclSecurity (SecurityAction sec_action, byte []
data, MetaDataElement element)
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/ChangeLog 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -1,3 +1,18 @@
+2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
+
+ * MethodDef.cs (MethodDef): Use a ParamDef for return type, instead of a
+ BaseTypeRef.
+ (MethodDef.ctor): Update.
+ (MethodDef.AddParamDefaultValue): Remove.
+ (MethodDef.GetParam): Likewise.
+ (MethodDef.Resolve): Update to use ret_param instead of ret_type.
+
+2006-05-31 Ankit Jain <[EMAIL PROTECTED]>
+
+ * TypeDef.cs (TypeDef.IsValueType): New.
+ (TypeDef.IsEnumType): New.
+ (TypeDef.Define): Don't seal System.ValueType or System.Enum .
+
2006-05-26 Ankit Jain <[EMAIL PROTECTED]>
* Assembly.cs: New. Represents a '.assembly {}' (assembly manifest).
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/MethodDef.cs 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -23,7 +23,7 @@
private string name;
private string signature;
private Hashtable vararg_sig_table;
- private BaseTypeRef ret_type;
+ private ParamDef ret_param;
private ArrayList param_list;
private ArrayList inst_list;
private ArrayList customattr_list;
@@ -45,7 +45,6 @@
private string pinvoke_name;
private PEAPI.PInvokeAttr pinvoke_attr;
private SourceMethod source;
- private PEAPI.NativeType ret_native_type;
private TypeDef type_def;
private GenericParameters gen_params;
@@ -58,10 +57,10 @@
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;
this.gen_params = gen_params;
+ this.ret_param = new ParamDef
(PEAPI.ParamAttr.Default, "", ret_type);
inst_list = new ArrayList ();
label_table = new Hashtable ();
@@ -96,7 +95,7 @@
}
public BaseTypeRef RetType {
- get { return ret_type; }
+ get { return ret_param.Type; }
}
public PEAPI.CallConv CallConv {
@@ -185,13 +184,6 @@
return gen_params.GetGenericParamNum (id);
}
- public void AddParamDefaultValue (int index, PEAPI.Constant
defval)
- {
- if (param_list [index] != null) {
- ((ParamDef)param_list [index]).AddDefaultValue
(defval);
- }
- }
-
public void AddCustomAttribute (CustomAttr customattr)
{
if (customattr_list == null)
@@ -202,7 +194,7 @@
public void AddRetTypeMarshalInfo (PEAPI.NativeType
native_type)
{
- this.ret_native_type = native_type;
+ this.ret_param.AddMarshalInfo (native_type);
}
public void AddLocals (ArrayList local_list)
@@ -249,8 +241,19 @@
return pos;
}
+ /* index - 0: return type
+ * 1: params start from this
+ */
public ParamDef GetParam (int index)
{
+ if (index == 0)
+ return ret_param;
+
+ if ((param_list == null) || (index < 0) || (index >
param_list.Count))
+ return null;
+
+ index --; /* param_list has params zero-based */
+
if (param_list [index] != null)
return (ParamDef)param_list [index];
else
@@ -305,7 +308,7 @@
if (gen_params != null)
gen_params.ResolveConstraints (type_params,
gen_params);
- BaseGenericTypeRef gtr = ret_type as BaseGenericTypeRef;
+ BaseGenericTypeRef gtr = RetType as BaseGenericTypeRef;
if (gtr != null)
gtr.Resolve (type_params, gen_params);
@@ -331,20 +334,17 @@
PEAPI.Param [] param_array = GenerateParams (code_gen);
FixAttributes ();
- ret_type.Resolve (code_gen);
+ ret_param.Define (code_gen);
if (classdef == null)
methoddef = code_gen.PEFile.AddMethod
(meth_attr, impl_attr,
- name, ret_type.PeapiType,
param_array);
+ name, ret_param.PeapiParam,
param_array);
else
methoddef = classdef.AddMethod (meth_attr,
impl_attr,
- name, ret_type.PeapiType,
param_array);
+ name, ret_param.PeapiParam,
param_array);
methoddef.AddCallConv (call_conv);
- if (ret_native_type != null)
- methoddef.AddRetTypeMarshallInfo
(ret_native_type);
-
is_resolved = true;
return methoddef;
Modified: branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/codegen/TypeDef.cs 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -291,6 +291,16 @@
}
}
+ private bool IsValueType (string ns, string name)
+ {
+ return (ns == "System" && name == "ValueType");
+ }
+
+ private bool IsEnumType (string ns, string name)
+ {
+ return (ns == "System" && name == "Enum");
+ }
+
public void Define (CodeGen code_gen)
{
if (is_defined)
@@ -306,7 +316,6 @@
if (vis == PEAPI.TypeAttr.Private || vis ==
PEAPI.TypeAttr.Public) {
/* Nested class, but attr not set
accordingly. */
- //FIXME: 'report' warning here
Console.WriteLine ("Warning -- Nested
class '{0}' has non-nested visibility, set to such.", NestedFullName);
attr = attr ^ vis;
attr |= (vis == PEAPI.TypeAttr.Public ?
PEAPI.TypeAttr.NestedPublic : PEAPI.TypeAttr.NestedPrivate);
@@ -323,17 +332,14 @@
+ parent);
}
- if (parent.PeapiClass.nameSpace != null &&
- parent.PeapiClass.nameSpace.CompareTo
("System") == 0) {
-
- if (parent.PeapiClass.name.CompareTo
("ValueType") == 0)
- is_value_class = true;
- else
- if (parent.PeapiClass.name.CompareTo
("Enum") == 0 )
- is_enum_class = true;
- }
+ if (IsValueType (parent.PeapiClass.nameSpace,
parent.PeapiClass.name))
+ is_value_class = true;
+ else if (IsEnumType
(parent.PeapiClass.nameSpace, parent.PeapiClass.name))
+ is_enum_class = true;
- if (is_value_class && (attr &
PEAPI.TypeAttr.Sealed) == 0) {
+ if (!IsValueType (name_space, name) &&
!IsEnumType (name_space, name) &&
+ is_value_class && (attr &
PEAPI.TypeAttr.Sealed) == 0) {
+
Console.WriteLine ("Warning --
Non-sealed value class, made sealed.");
attr |= PEAPI.TypeAttr.Sealed;
}
Modified: branches/mono-1-1-13/mcs/ilasm/errors/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/errors/ChangeLog 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/errors/ChangeLog 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -1,3 +1,7 @@
+2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
+
+ * err-cattr.il: New.
+
2006-05-09 Ankit Jain <[EMAIL PROTECTED]>
* err-dup-label.il: New.
Added: branches/mono-1-1-13/mcs/ilasm/errors/err-cattr.il
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/errors/err-cattr.il 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/errors/err-cattr.il 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -0,0 +1,49 @@
+// Test for custom attributes for method params, with
+// invalid indices
+// The generated assembly will have no custom attributes
+// on method params.
+
+.assembly extern mscorlib
+{
+}
+.assembly bb
+{
+ .custom instance void
[mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32)
= ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module bb.exe
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit foo
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig static void
+ abc () cil managed
+ {
+ .param [-1]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .param [2]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .entrypoint
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+}
Modified: branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/parser/ChangeLog 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -1,3 +1,9 @@
+2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
+
+ * ILParser.jay (method_decl | D_PARAM ..): Param index is zero-based,
+ with zero representing the return value.
+ Update to check CurrentCustomAttrTarget for null before using it.
+
2006-05-26 Ankit Jain <[EMAIL PROTECTED]>
* ILParser.jay: Update to use new Assembly class.
Modified: branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/parser/ILParser.jay 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -874,7 +874,8 @@
| extsource_spec
| customattr_decl
{
-
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ if (codegen.CurrentCustomAttrTarget != null)
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| param_type_decl
| D_SIZE int32
@@ -2136,8 +2137,16 @@
| scope_block
| 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);
+ int index = (int) $3;
+ ParamDef param =
codegen.CurrentMethodDef.GetParam (index);
+ codegen.CurrentCustomAttrTarget = param;
+
+ if (param == null) {
+ Console.Error.WriteLine ("{0} Warning
-- invalid param index ({1}) with .param", tokenizer.Location, index);
+ break;
+ }
+ if ($5 != null)
+ param.AddDefaultValue ((Constant) $5);
}
| param_type_decl
| id COLON
@@ -2154,7 +2163,8 @@
| language_decl
| customattr_decl
{
-
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ if (codegen.CurrentCustomAttrTarget != null)
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| data_decl
;
@@ -2669,7 +2679,8 @@
}
| customattr_decl
{
-
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ if (codegen.CurrentCustomAttrTarget != null)
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| extsource_spec
| language_decl
@@ -2730,7 +2741,8 @@
}
| customattr_decl
{
-
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ if (codegen.CurrentCustomAttrTarget != null)
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
| extsource_spec
| language_decl
@@ -3141,7 +3153,8 @@
}
| customattr_decl
{
-
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
+ if (codegen.CurrentCustomAttrTarget != null)
+
codegen.CurrentCustomAttrTarget.AddCustomAttribute ((CustomAttr) $1);
}
;
Modified: branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog 2006-06-01 09:33:05 UTC
(rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/tests/ChangeLog 2006-06-01 09:56:15 UTC
(rev 61359)
@@ -1,3 +1,8 @@
+2006-06-01 Ankit Jain <[EMAIL PROTECTED]>
+
+ * test-cattr-1.il: New. Test for custom attributes on return type of
+ a method.
+
2006-05-26 Ankit Jain <[EMAIL PROTECTED]>
* test-perm_pass-3.il: New. Test for 2.0 style declarative security
Added: branches/mono-1-1-13/mcs/ilasm/tests/test-cattr-1.il
===================================================================
--- branches/mono-1-1-13/mcs/ilasm/tests/test-cattr-1.il 2006-06-01
09:33:05 UTC (rev 61358)
+++ branches/mono-1-1-13/mcs/ilasm/tests/test-cattr-1.il 2006-06-01
09:56:15 UTC (rev 61359)
@@ -0,0 +1,43 @@
+//Test for custom attributes on return type of a method
+
+.assembly extern mscorlib
+{
+}
+.assembly bb
+{
+ .custom instance void
[mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32)
= ( 01 00 08 00 00 00 00 00 )
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module bb.exe
+
+.class private auto ansi beforefieldinit GenParAttribute
+ extends [mscorlib]System.Attribute
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Attribute::.ctor()
+ IL_0006: ret
+ }
+
+}
+
+.class private auto ansi beforefieldinit foo
+ extends [mscorlib]System.Object
+{
+
+ .method public hidebysig static void
+ abc () cil managed
+ {
+ .param [0]
+ .custom instance void GenParAttribute::.ctor() = ( 01 00 00 00 )
+
+ .entrypoint
+ .maxstack 8
+ IL_0000: nop
+ IL_0001: ret
+ }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches