5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
12 using System
.Collections
;
15 namespace Mono
.ILASM
{
18 /// Definition of a parameter passed to a method
20 public class ParamDef
: ICustomAttrTarget
{
22 private PEAPI
.ParamAttr attr
;
24 private BaseTypeRef typeref
;
25 private bool is_defined
;
26 private PEAPI
.Param peapi_param
;
27 private PEAPI
.Constant defval
;
28 private ArrayList customattr_list
;
29 private PEAPI
.NativeType native_type
;
31 public static readonly ParamDef Ellipsis
= new ParamDef (new PEAPI
.ParamAttr (), "ELLIPSIS", null);
33 public ParamDef (PEAPI
.ParamAttr attr
, string name
,
34 BaseTypeRef typeref
) {
37 this.typeref
= typeref
;
42 public void AddDefaultValue (PEAPI
.Constant cVal
)
47 public void AddCustomAttribute (CustomAttr customattr
)
49 if (customattr_list
== null)
50 customattr_list
= new ArrayList ();
52 customattr_list
.Add (customattr
);
55 public void AddMarshalInfo (PEAPI
.NativeType native_type
)
57 this.native_type
= native_type
;
60 public BaseTypeRef Type
{
61 get { return typeref; }
64 public string TypeName
{
65 get { return typeref.FullName; }
72 public PEAPI
.Param PeapiParam
{
73 get { return peapi_param; }
76 public bool IsSentinel ()
78 return (typeref
is SentinelTypeRef
&& this != Ellipsis
);
81 public void Define (CodeGen code_gen
)
86 typeref
.Resolve (code_gen
);
88 peapi_param
= new PEAPI
.Param (attr
,
89 name
, typeref
.PeapiType
);
91 peapi_param
.AddDefaultValue (defval
);
94 if (customattr_list
!= null)
95 foreach (CustomAttr customattr
in customattr_list
)
96 customattr
.AddTo (code_gen
, peapi_param
);
98 if (native_type
!= null)
99 peapi_param
.AddMarshallInfo (native_type
);