2007-02-06 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / parameter.cs
1 //
2 // parameter.cs: Parameter definition.
3 //
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 //         Marek Safar (marek.safar@seznam.cz)
6 //
7 // Licensed under the terms of the GNU GPL
8 //
9 // (C) 2001 Ximian, Inc (http://www.ximian.com)
10 //
11 //
12 //
13 using System;
14 using System.Reflection;
15 using System.Reflection.Emit;
16 using System.Collections;
17 using System.Text;
18
19 namespace Mono.CSharp {
20
21         /// <summary>
22         ///   Abstract Base class for parameters of a method.
23         /// </summary>
24         public abstract class ParameterBase : Attributable {
25
26                 protected ParameterBuilder builder;
27
28                 protected ParameterBase (Attributes attrs)
29                         : base (attrs)
30                 {
31                 }
32
33                 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
34                 {
35                         if (a.Type == TypeManager.marshal_as_attr_type) {
36                                 UnmanagedMarshal marshal = a.GetMarshal (this);
37                                 if (marshal != null) {
38                                         builder.SetMarshal (marshal);
39                                 }
40                                 return;
41                         }
42
43                         if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
44                                 a.Error_InvalidSecurityParent ();
45                                 return;
46                         }
47
48                         builder.SetCustomAttribute (cb);
49                 }
50
51                 public override bool IsClsComplianceRequired()
52                 {
53                         return false;
54                 }
55         }
56
57         /// <summary>
58         /// Class for applying custom attributes on the return type
59         /// </summary>
60         public class ReturnParameter : ParameterBase {
61                 public ReturnParameter (MethodBuilder mb, Location location):
62                         base (null)
63                 {
64                         try {
65                                 builder = mb.DefineParameter (0, ParameterAttributes.None, "");                 
66                         }
67                         catch (ArgumentOutOfRangeException) {
68                                 Report.RuntimeMissingSupport (location, "custom attributes on the return type");
69                         }
70                 }
71
72                 public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
73                 {
74                         if (a.Type == TypeManager.cls_compliant_attribute_type) {
75                                 Report.Warning (3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
76                         }
77
78                         // This occurs after Warning -28
79                         if (builder == null)
80                                 return;
81
82                         base.ApplyAttributeBuilder (a, cb);
83                 }
84
85                 public override AttributeTargets AttributeTargets {
86                         get {
87                                 return AttributeTargets.ReturnValue;
88                         }
89                 }
90
91                 public override IResolveContext ResolveContext {
92                         get {
93                                 throw new NotSupportedException ();
94                         }
95                 }
96
97                 /// <summary>
98                 /// Is never called
99                 /// </summary>
100                 public override string[] ValidAttributeTargets {
101                         get {
102                                 return null;
103                         }
104                 }
105         }
106
107         /// <summary>
108         /// Class for applying custom attributes on the implicit parameter type
109         /// of the 'set' method in properties, and the 'add' and 'remove' methods in events.
110         /// </summary>
111         /// 
112         // TODO: should use more code from Parameter.ApplyAttributeBuilder
113         public class ImplicitParameter : ParameterBase {
114                 public ImplicitParameter (MethodBuilder mb):
115                         base (null)
116                 {
117                         builder = mb.DefineParameter (1, ParameterAttributes.None, "");                 
118                 }
119
120                 public override AttributeTargets AttributeTargets {
121                         get {
122                                 return AttributeTargets.Parameter;
123                         }
124                 }
125
126                 public override IResolveContext ResolveContext {
127                         get {
128                                 throw new NotSupportedException ();
129                         }
130                 }
131
132                 /// <summary>
133                 /// Is never called
134                 /// </summary>
135                 public override string[] ValidAttributeTargets {
136                         get {
137                                 return null;
138                         }
139                 }
140         }
141
142         public class ParamsParameter : Parameter {
143                 public ParamsParameter (Expression type, string name, Attributes attrs, Location loc):
144                         base (type, name, Parameter.Modifier.PARAMS, attrs, loc)
145                 {
146                 }
147
148                 public override bool Resolve (IResolveContext ec)
149                 {
150                         if (!base.Resolve (ec))
151                                 return false;
152
153                         if (!parameter_type.IsArray || parameter_type.GetArrayRank () != 1) {
154                                 Report.Error (225, Location, "The params parameter must be a single dimensional array");
155                                 return false;
156                         }
157                         return true;
158                 }
159
160                 public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
161                 {
162                         base.ApplyAttributes (mb, cb, index);
163
164                         CustomAttributeBuilder a = new CustomAttributeBuilder (
165                                 TypeManager.ConsParamArrayAttribute, new object [0]);
166                                 
167                         builder.SetCustomAttribute (a);
168                 }
169         }
170
171         public class ArglistParameter : Parameter {
172                 // Doesn't have proper type because it's never choosed for better conversion
173                 public ArglistParameter () :
174                         base (typeof (ArglistParameter), "", Parameter.Modifier.ARGLIST, null, Location.Null)
175                 {
176                 }
177
178                 public override bool Resolve (IResolveContext ec)
179                 {
180                         return true;
181                 }
182
183                 public override string GetSignatureForError ()
184                 {
185                         return "__arglist";
186                 }
187         }
188
189         /// <summary>
190         ///   Represents a single method parameter
191         /// </summary>
192         public class Parameter : ParameterBase {
193                 [Flags]
194                 public enum Modifier : byte {
195                         NONE    = 0,
196                         REF     = REFMASK | ISBYREF,
197                         OUT     = OUTMASK | ISBYREF,
198                         PARAMS  = 4,
199                         // This is a flag which says that it's either REF or OUT.
200                         ISBYREF = 8,
201                         ARGLIST = 16,
202                         REFMASK = 32,
203                         OUTMASK = 64
204                 }
205
206                 static string[] attribute_targets = new string [] { "param" };
207
208                 public Expression TypeName;
209                 public readonly Modifier ModFlags;
210                 public string Name;
211                 public bool IsCaptured;
212                 protected Type parameter_type;
213                 public readonly Location Location;
214
215                 IResolveContext resolve_context;
216
217                 Variable var;
218                 public Variable Variable {
219                         get { return var; }
220                 }
221
222 #if GMCS_SOURCE
223                 GenericConstraints constraints;
224 #endif
225                 
226                 public Parameter (Expression type, string name, Modifier mod, Attributes attrs, Location loc)
227                         : base (attrs)
228                 {
229                         Name = name;
230                         ModFlags = mod;
231                         TypeName = type;
232                         Location = loc;
233                 }
234
235                 public Parameter (Type type, string name, Modifier mod, Attributes attrs, Location loc)
236                         : base (attrs)
237                 {
238                         Name = name;
239                         ModFlags = mod;
240                         parameter_type = type;
241                         Location = loc;
242                 }
243
244                 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
245                 {
246                         if (a.Type == TypeManager.in_attribute_type && ModFlags == Modifier.OUT) {
247                                 Report.Error (36, a.Location, "An out parameter cannot have the `In' attribute");
248                                 return;
249                         }
250
251                         if (a.Type == TypeManager.param_array_type) {
252                                 Report.Error (674, a.Location, "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead");
253                                 return;
254                         }
255
256                         if (a.Type == TypeManager.out_attribute_type && (ModFlags & Modifier.REF) == Modifier.REF &&
257                             !OptAttributes.Contains (TypeManager.in_attribute_type)) {
258                                 Report.Error (662, a.Location,
259                                         "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither");
260                                 return;
261                         }
262
263                         if (a.Type == TypeManager.cls_compliant_attribute_type) {
264                                 Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
265                         }
266
267                         // TypeManager.default_parameter_value_attribute_type is null if !NET_2_0
268                         if (a.Type == TypeManager.default_parameter_value_attribute_type) {
269                                 object val = a.GetParameterDefaultValue ();
270                                 if (val != null) {
271                                         Type t = val.GetType ();
272                                         if (t.IsArray || TypeManager.IsSubclassOf (t, TypeManager.type_type)) {
273                                                 if (parameter_type == TypeManager.object_type) {
274                                                         if (!t.IsArray)
275                                                                 t = TypeManager.type_type;
276
277                                                         Report.Error (1910, a.Location, "Argument of type `{0}' is not applicable for the DefaultValue attribute",
278                                                                 TypeManager.CSharpName (t));
279                                                 } else {
280                                                         Report.Error (1909, a.Location, "The DefaultValue attribute is not applicable on parameters of type `{0}'",
281                                                                 TypeManager.CSharpName (parameter_type)); ;
282                                                 }
283                                                 return;
284                                         }
285                                 }
286
287                                 if (parameter_type == TypeManager.object_type ||
288                                     (val == null && !TypeManager.IsValueType (parameter_type)) ||
289                                     (val != null && TypeManager.TypeToCoreType (val.GetType ()) == parameter_type))
290                                         builder.SetConstant (val);
291                                 else
292                                         Report.Error (1908, a.Location, "The type of the default value should match the type of the parameter");
293                                 return;
294                         }
295
296                         base.ApplyAttributeBuilder (a, cb);
297                 }
298
299                 public override IResolveContext ResolveContext {
300                         get {
301                                 return resolve_context;
302                         }
303                 }
304
305                 // <summary>
306                 //   Resolve is used in method definitions
307                 // </summary>
308                 public virtual bool Resolve (IResolveContext ec)
309                 {
310                         if (parameter_type != null)
311                                 return true;
312
313                         this.resolve_context = ec;
314
315                         TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
316                         if (texpr == null)
317                                 return false;
318
319                         parameter_type = texpr.Type;
320
321 #if GMCS_SOURCE
322                         TypeParameterExpr tparam = texpr as TypeParameterExpr;
323                         if (tparam != null) {
324                                 constraints = tparam.TypeParameter.Constraints;
325                                 return true;
326                         }
327 #endif
328
329                         if ((parameter_type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
330                                 Report.Error (721, Location, "`{0}': static types cannot be used as parameters", GetSignatureForError ());
331                                 return false;
332                         }
333
334                         if (parameter_type == TypeManager.void_type){
335                                 Report.Error (1536, Location, "Invalid parameter type 'void'");
336                                 return false;
337                         }
338
339                         if ((ModFlags & Parameter.Modifier.ISBYREF) != 0){
340                                 if (parameter_type == TypeManager.typed_reference_type ||
341                                     parameter_type == TypeManager.arg_iterator_type){
342                                         Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'",
343                                                 GetSignatureForError ());
344                                         return false;
345                                 }
346                         }
347                         
348                         return true;
349                 }
350
351                 public void ResolveVariable (ToplevelBlock toplevel, int idx)
352                 {
353                         if (toplevel.RootScope != null)
354                                 var = toplevel.RootScope.GetCapturedParameter (this);
355                         if (var == null)
356                                 var = new ParameterVariable (this, idx);
357                 }
358
359                 public Type ExternalType ()
360                 {
361                         if ((ModFlags & Parameter.Modifier.ISBYREF) != 0)
362                                 return TypeManager.GetReferenceType (parameter_type);
363                         
364                         return parameter_type;
365                 }
366
367                 public Type ParameterType {
368                         get {
369                                 return parameter_type;
370                         }
371                 }
372
373 #if GMCS_SOURCE
374                 public GenericConstraints GenericConstraints {
375                         get {
376                                 return constraints;
377                         }
378                 }
379 #endif
380
381                 public ParameterAttributes Attributes {
382                         get {
383                                 switch (ModFlags) {
384                                 case Modifier.NONE:
385                                         return ParameterAttributes.None;
386                                 case Modifier.REF:
387                                         return ParameterAttributes.None;
388                                 case Modifier.OUT:
389                                         return ParameterAttributes.Out;
390                                 case Modifier.PARAMS:
391                                         return 0;
392                                 }
393                                 
394                                 return ParameterAttributes.None;
395                         }
396                 }
397
398                 public static ParameterAttributes GetParameterAttributes (Modifier mod)
399                 {
400                         int flags = ((int) mod) & ~((int) Parameter.Modifier.ISBYREF);
401                         switch ((Modifier) flags) {
402                         case Modifier.NONE:
403                                 return ParameterAttributes.None;
404                         case Modifier.REF:
405                                 return ParameterAttributes.None;
406                         case Modifier.OUT:
407                                 return ParameterAttributes.Out;
408                         case Modifier.PARAMS:
409                                 return 0;
410                         }
411                                 
412                         return ParameterAttributes.None;
413                 }
414                 
415                 public override AttributeTargets AttributeTargets {
416                         get {
417                                 return AttributeTargets.Parameter;
418                         }
419                 }
420
421                 public virtual string GetSignatureForError ()
422                 {
423                         string type_name;
424                         if (parameter_type != null)
425                                 type_name = TypeManager.CSharpName (parameter_type);
426                         else
427                                 type_name = TypeName.GetSignatureForError ();
428
429                         string mod = GetModifierSignature (ModFlags);
430                         if (mod.Length > 0)
431                                 return String.Concat (mod, ' ', type_name);
432
433                         return type_name;
434                 }
435
436                 public static string GetModifierSignature (Modifier mod)
437                 {
438                         switch (mod) {
439                                 case Modifier.OUT:
440                                         return "out";
441                                 case Modifier.PARAMS:
442                                         return "params";
443                                 case Modifier.REF:
444                                         return "ref";
445                                 case Modifier.ARGLIST:
446                                         return "__arglist";
447                                 default:
448                                         return "";
449                         }
450                 }
451
452                 public void IsClsCompliant ()
453                 {
454                         if (AttributeTester.IsClsCompliant (ExternalType ()))
455                                 return;
456
457                         Report.Error (3001, Location, "Argument type `{0}' is not CLS-compliant", GetSignatureForError ());
458                 }
459
460                 public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
461                 {
462 #if !GMCS_SOURCE || !MS_COMPATIBLE
463                         // TODO: It should use mb.DefineGenericParameters
464                         if (mb == null)
465                                 builder = cb.DefineParameter (index, Attributes, Name);
466                         else 
467                                 builder = mb.DefineParameter (index, Attributes, Name);
468 #endif
469
470                         if (OptAttributes != null)
471                                 OptAttributes.Emit ();
472                 }
473
474                 public override string[] ValidAttributeTargets {
475                         get {
476                                 return attribute_targets;
477                         }
478                 }
479
480                 protected class ParameterVariable : Variable
481                 {
482                         public readonly Parameter Parameter;
483                         public readonly int Idx;
484                         public readonly bool IsRef;
485
486                         public ParameterVariable (Parameter par, int idx)
487                         {
488                                 this.Parameter = par;
489                                 this.Idx = idx;
490                                 this.IsRef = (par.ModFlags & Parameter.Modifier.ISBYREF) != 0;
491                         }
492
493                         public override Type Type {
494                                 get { return Parameter.ParameterType; }
495                         }
496
497                         public override bool HasInstance {
498                                 get { return false; }
499                         }
500
501                         public override bool NeedsTemporary {
502                                 get { return false; }
503                         }
504
505                         public override void EmitInstance (EmitContext ec)
506                         {
507                         }
508
509                         public override void Emit (EmitContext ec)
510                         {
511                                 int arg_idx = Idx;
512                                 if (!ec.MethodIsStatic)
513                                         arg_idx++;
514
515                                 ParameterReference.EmitLdArg (ec.ig, arg_idx);
516                         }
517
518                         public override void EmitAssign (EmitContext ec)
519                         {
520                                 int arg_idx = Idx;
521                                 if (!ec.MethodIsStatic)
522                                         arg_idx++;
523
524                                 if (arg_idx <= 255)
525                                         ec.ig.Emit (OpCodes.Starg_S, (byte) arg_idx);
526                                 else
527                                         ec.ig.Emit (OpCodes.Starg, arg_idx);
528                         }
529
530                         public override void EmitAddressOf (EmitContext ec)
531                         {
532                                 int arg_idx = Idx;
533
534                                 if (!ec.MethodIsStatic)
535                                         arg_idx++;
536
537                                 if (IsRef) {
538                                         if (arg_idx <= 255)
539                                                 ec.ig.Emit (OpCodes.Ldarg_S, (byte) arg_idx);
540                                         else
541                                                 ec.ig.Emit (OpCodes.Ldarg, arg_idx);
542                                 } else {
543                                         if (arg_idx <= 255)
544                                                 ec.ig.Emit (OpCodes.Ldarga_S, (byte) arg_idx);
545                                         else
546                                                 ec.ig.Emit (OpCodes.Ldarga, arg_idx);
547                                 }
548                         }
549                 }
550
551                 public Parameter Clone ()
552                 {
553                         Parameter p = new Parameter (TypeName, Name, ModFlags, attributes, Location);
554                         p.parameter_type = parameter_type;
555
556                         return p;
557                 }
558         }
559
560         /// <summary>
561         ///   Represents the methods parameters
562         /// </summary>
563         public class Parameters : ParameterData {
564                 // Null object pattern
565                 public Parameter [] FixedParameters;
566                 public readonly bool HasArglist;
567                 Type [] types;
568                 int count;
569
570                 public static readonly Parameters EmptyReadOnlyParameters = new Parameters ();
571                 static readonly Parameter ArgList = new ArglistParameter ();
572
573 #if GMCS_SOURCE
574                 public readonly TypeParameter[] TypeParameters;
575 #endif
576
577                 private Parameters ()
578                 {
579                         FixedParameters = new Parameter[0];
580                         types = new Type [0];
581                 }
582
583                 public Parameters (Parameter[] parameters, Type[] types)
584                 {
585                         FixedParameters = parameters;
586                         this.types = types;
587                         count = types.Length;
588                 }
589                 
590                 public Parameters (Parameter[] parameters)
591                 {
592                         if (parameters == null)
593                                 throw new ArgumentException ("Use EmptyReadOnlyPatameters");
594
595                         FixedParameters = parameters;
596                         count = parameters.Length;
597                 }
598
599                 public Parameters (Parameter[] parameters, bool has_arglist):
600                         this (parameters)
601                 {
602                         HasArglist = has_arglist;
603                 }
604
605                 /// <summary>
606                 /// Use this method when you merge compiler generated argument with user arguments
607                 /// </summary>
608                 public static Parameters MergeGenerated (Parameters userParams, params Parameter[] compilerParams)
609                 {
610                         Parameter[] all_params = new Parameter [userParams.count + compilerParams.Length];
611                         Type[] all_types = new Type[all_params.Length];
612                         userParams.FixedParameters.CopyTo(all_params, 0);
613                         userParams.Types.CopyTo (all_types, 0);
614
615                         int last_filled = userParams.Count;
616                         foreach (Parameter p in compilerParams) {
617                                 for (int i = 0; i < last_filled; ++i) {
618                                         while (p.Name == all_params [i].Name) {
619                                                 p.Name = '_' + p.Name;
620                                         }
621                                 }
622                                 all_params [last_filled] = p;
623                                 all_types [last_filled] = p.ParameterType;
624                                 ++last_filled;
625                         }
626                         
627                         return new Parameters (all_params, all_types);
628                 }
629
630                 public bool Empty {
631                         get {
632                                 return count == 0;
633                         }
634                 }
635
636                 public int Count {
637                         get {
638                                 return HasArglist ? count + 1 : count;
639                         }
640                 }
641
642                 bool VerifyArgs ()
643                 {
644                         if (count < 2)
645                                 return true;
646
647                         for (int i = 0; i < count; i++){
648                                 string base_name = FixedParameters [i].Name;
649                                 for (int j = i + 1; j < count; j++){
650                                         if (base_name != FixedParameters [j].Name)
651                                                 continue;
652
653                                         Report.Error (100, FixedParameters [i].Location,
654                                                 "The parameter name `{0}' is a duplicate", base_name);
655                                         return false;
656                                 }
657                         }
658                         return true;
659                 }
660                 
661                 
662                 /// <summary>
663                 ///    Returns the paramenter information based on the name
664                 /// </summary>
665                 public Parameter GetParameterByName (string name, out int idx)
666                 {
667                         idx = 0;
668
669                         if (count == 0)
670                                 return null;
671
672                         int i = 0;
673
674                         foreach (Parameter par in FixedParameters){
675                                 if (par.Name == name){
676                                         idx = i;
677                                         return par;
678                                 }
679                                 i++;
680                         }
681                         return null;
682                 }
683
684                 public Parameter GetParameterByName (string name)
685                 {
686                         int idx;
687
688                         return GetParameterByName (name, out idx);
689                 }
690                 
691                 public bool Resolve (IResolveContext ec)
692                 {
693                         if (types != null)
694                                 return true;
695
696                         types = new Type [count];
697                         
698                         if (!VerifyArgs ())
699                                 return false;
700
701                         bool ok = true;
702                         Parameter p;
703                         for (int i = 0; i < FixedParameters.Length; ++i) {
704                                 p = FixedParameters [i];
705                                 if (!p.Resolve (ec)) {
706                                         ok = false;
707                                         continue;
708                                 }
709                                 types [i] = p.ExternalType ();
710                         }
711
712                         return ok;
713                 }
714
715                 public void ResolveVariable (ToplevelBlock toplevel)
716                 {
717                         for (int i = 0; i < FixedParameters.Length; ++i) {
718                                 Parameter p = FixedParameters [i];
719                                 p.ResolveVariable (toplevel, i);
720                         }
721                 }
722
723                 public CallingConventions CallingConvention
724                 {
725                         get {
726                                 if (HasArglist)
727                                         return CallingConventions.VarArgs;
728                                 else
729                                         return CallingConventions.Standard;
730                         }
731                 }
732
733                 // Define each type attribute (in/out/ref) and
734                 // the argument names.
735                 public void ApplyAttributes (MethodBase builder)
736                 {
737                         if (count == 0)
738                                 return;
739
740                         MethodBuilder mb = builder as MethodBuilder;
741                         ConstructorBuilder cb = builder as ConstructorBuilder;
742
743                         for (int i = 0; i < FixedParameters.Length; i++) {
744                                 FixedParameters [i].ApplyAttributes (mb, cb, i + 1);
745                         }
746                 }
747
748                 public void VerifyClsCompliance ()
749                 {
750                         foreach (Parameter p in FixedParameters)
751                                 p.IsClsCompliant ();
752                 }
753
754                 public string GetSignatureForError ()
755                 {
756                         StringBuilder sb = new StringBuilder ("(");
757                         if (count > 0) {
758                                 for (int i = 0; i < FixedParameters.Length; ++i) {
759                                         sb.Append (FixedParameters[i].GetSignatureForError ());
760                                         if (i < FixedParameters.Length - 1)
761                                                 sb.Append (", ");
762                                 }
763                         }
764
765                         if (HasArglist) {
766                                 if (sb.Length > 1)
767                                         sb.Append (", ");
768                                 sb.Append ("__arglist");
769                         }
770
771                         sb.Append (')');
772                         return sb.ToString ();
773                 }
774
775                 public Type[] Types {
776                         get {
777                                 return types;
778                         }
779                 }
780
781                 public Parameter this [int pos]
782                 {
783                         get {
784                                 if (pos >= count && (HasArglist || HasParams)) {
785                                         if (HasArglist && (pos == 0 || pos >= count))
786                                                 return ArgList;
787                                         pos = count - 1;
788                                 }
789
790                                 return FixedParameters [pos];
791                         }
792                 }
793
794                 #region ParameterData Members
795
796                 public Type ParameterType (int pos)
797                 {
798                         return this [pos].ExternalType ();
799                 }
800
801                 public bool HasParams {
802                         get {
803                                 if (count == 0)
804                                         return false;
805
806                                 for (int i = count; i != 0; --i) {
807                                         if ((FixedParameters [i - 1].ModFlags & Parameter.Modifier.PARAMS) != 0)
808                                                 return true;
809                                 }
810                                 return false;
811                         }
812                 }
813
814                 public string ParameterName (int pos)
815                 {
816                         return this [pos].Name;
817                 }
818
819                 public string ParameterDesc (int pos)
820                 {
821                         return this [pos].GetSignatureForError ();
822                 }
823
824                 public Parameter.Modifier ParameterModifier (int pos)
825                 {
826                         return this [pos].ModFlags;
827                 }
828
829                 public Parameters Clone ()
830                 {
831                         Parameter [] parameters_copy = new Parameter [FixedParameters.Length];
832                         int i = 0;
833                         foreach (Parameter p in FixedParameters)
834                                 parameters_copy [i++] = p.Clone ();
835                         return new Parameters (parameters_copy, HasArglist);
836                 }
837                 
838                 #endregion
839         }
840 }