* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / ilasm / codegen / ParamDef.cs
index 9c597f525a002f4501257c9844fd1f71479fd02a..ede5bec5036dd277e80d952fd6ef31ad86b83d63 100644 (file)
@@ -9,6 +9,7 @@
 
 
 using System;
+using System.Collections;
 
 
 namespace Mono.ILASM {
@@ -16,25 +17,47 @@ namespace Mono.ILASM {
         /// <summary>
         ///  Definition of a parameter passed to a method
         /// </summary>
-        public class ParamDef {
+        public class ParamDef : ICustomAttrTarget {
 
                 private PEAPI.ParamAttr attr;
                 private string name;
-                private ITypeRef typeref;
+                private BaseTypeRef typeref;
                 private bool is_defined;
                 private PEAPI.Param peapi_param;
+                private PEAPI.Constant defval;
+                private ArrayList customattr_list;
+                private PEAPI.NativeType native_type;
 
                 public static readonly ParamDef Ellipsis = new ParamDef (new PEAPI.ParamAttr (), "ELLIPSIS", null);
 
                 public ParamDef (PEAPI.ParamAttr attr, string name,
-                                ITypeRef typeref) {
+                                BaseTypeRef typeref) {
                         this.attr = attr;
                         this.name = name;
                         this.typeref = typeref;
                         is_defined = false;
+                        defval = null;
                 }
 
-                public ITypeRef Type {
+                public void AddDefaultValue (PEAPI.Constant cVal)
+                {
+                        defval = cVal;
+                }
+
+                public void AddCustomAttribute (CustomAttr customattr)
+                {
+                        if (customattr_list == null)
+                                customattr_list = new ArrayList ();
+
+                        customattr_list.Add (customattr);
+                }
+
+                public void AddMarshalInfo (PEAPI.NativeType native_type)
+                {
+                        this.native_type = native_type;
+                }
+
+                public BaseTypeRef Type {
                         get { return typeref; }
                 }
 
@@ -52,7 +75,7 @@ namespace Mono.ILASM {
 
                 public bool IsSentinel ()
                 {
-                        return (typeref is SentinelTypeRef);
+                        return (typeref is SentinelTypeRef && this != Ellipsis);
                 }
 
                 public void Define (CodeGen code_gen)
@@ -64,6 +87,16 @@ namespace Mono.ILASM {
 
                         peapi_param = new PEAPI.Param (attr,
                                         name, typeref.PeapiType);
+                        if (defval != null) {
+                                peapi_param.AddDefaultValue (defval);
+                        }
+
+                        if (customattr_list != null)
+                                foreach (CustomAttr customattr in customattr_list)
+                                        customattr.AddTo (code_gen, peapi_param);
+
+                        if (native_type != null)
+                                peapi_param.AddMarshallInfo (native_type);
 
                         is_defined = true;
                 }