2 // parameter.cs: Parameter definition.
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 // Marek Safar (marek.safar@seznam.cz)
7 // Dual licensed under the terms of the MIT X11 or GNU GPL
9 // Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
10 // Copyright 2003-2008 Novell, Inc.
14 using System.Reflection;
15 using System.Reflection.Emit;
16 using System.Collections;
19 namespace Mono.CSharp {
22 /// Abstract Base class for parameters of a method.
24 public abstract class ParameterBase : Attributable {
26 protected ParameterBuilder builder;
28 protected ParameterBase (Attributes attrs)
33 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
36 if (a.Type == pa.MarshalAs) {
37 UnmanagedMarshal marshal = a.GetMarshal (this);
38 if (marshal != null) {
39 builder.SetMarshal (marshal);
44 if (a.HasSecurityAttribute) {
45 a.Error_InvalidSecurityParent ();
49 builder.SetCustomAttribute (cb);
52 public override bool IsClsComplianceRequired()
59 /// Class for applying custom attributes on the return type
61 public class ReturnParameter : ParameterBase {
62 public ReturnParameter (MethodBuilder mb, Location location):
66 builder = mb.DefineParameter (0, ParameterAttributes.None, "");
68 catch (ArgumentOutOfRangeException) {
69 Report.RuntimeMissingSupport (location, "custom attributes on the return type");
73 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
75 if (a.Type == pa.CLSCompliant) {
76 Report.Warning (3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead");
79 // This occurs after Warning -28
83 base.ApplyAttributeBuilder (a, cb, pa);
86 public override AttributeTargets AttributeTargets {
88 return AttributeTargets.ReturnValue;
92 public override IResolveContext ResolveContext {
94 throw new NotSupportedException ();
101 public override string[] ValidAttributeTargets {
109 /// Class for applying custom attributes on the implicit parameter type
110 /// of the 'set' method in properties, and the 'add' and 'remove' methods in events.
113 // TODO: should use more code from Parameter.ApplyAttributeBuilder
114 public class ImplicitParameter : ParameterBase {
115 public ImplicitParameter (MethodBuilder mb):
118 builder = mb.DefineParameter (1, ParameterAttributes.None, "value");
121 public override AttributeTargets AttributeTargets {
123 return AttributeTargets.Parameter;
127 public override IResolveContext ResolveContext {
129 throw new NotSupportedException ();
136 public override string[] ValidAttributeTargets {
143 public class ImplicitLambdaParameter : Parameter
145 public ImplicitLambdaParameter (string name, Location loc)
146 : base (null, name, Modifier.NONE, null, loc)
150 public override Type Resolve (IResolveContext ec)
152 if (parameter_type == null)
153 throw new InternalErrorException ("A type of implicit lambda parameter `{0}' is not set",
156 return parameter_type;
160 set { parameter_type = value; }
164 public class ParamsParameter : Parameter {
165 public ParamsParameter (FullNamedExpression type, string name, Attributes attrs, Location loc):
166 base (type, name, Parameter.Modifier.PARAMS, attrs, loc)
170 public override Type Resolve (IResolveContext ec)
172 if (base.Resolve (ec) == null)
175 if (!parameter_type.IsArray || parameter_type.GetArrayRank () != 1) {
176 Report.Error (225, Location, "The params parameter must be a single dimensional array");
180 return parameter_type;
183 public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
185 base.ApplyAttributes (mb, cb, index);
186 PredefinedAttributes.Get.ParamArray.EmitAttribute (builder, Location);
190 public class ArglistParameter : Parameter {
191 // Doesn't have proper type because it's never chosen for better conversion
192 public ArglistParameter (Location loc) :
193 base (null, String.Empty, Parameter.Modifier.ARGLIST, null, loc)
197 public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
202 public override bool CheckAccessibility (InterfaceMemberBase member)
207 public override Type Resolve (IResolveContext ec)
209 return typeof (ArglistParameter);
212 public override string GetSignatureForError ()
218 public interface IParameterData
220 bool HasExtensionMethodModifier { get; }
221 Parameter.Modifier ModFlags { get; }
226 // Parameter information created by parser
228 public class Parameter : ParameterBase, IParameterData, ILocalVariable {
230 public enum Modifier : byte {
232 REF = REFMASK | ISBYREF,
233 OUT = OUTMASK | ISBYREF,
235 // This is a flag which says that it's either REF or OUT.
243 static string[] attribute_targets = new string [] { "param" };
245 protected FullNamedExpression TypeName;
246 readonly Modifier modFlags;
248 protected Type parameter_type;
249 public readonly Location Location;
251 public bool HasAddressTaken;
253 IResolveContext resolve_context;
254 LocalVariableReference expr_tree_variable;
255 static TypeExpr parameter_expr_tree_type;
257 public HoistedVariable HoistedVariableReference;
259 public Parameter (FullNamedExpression type, string name, Modifier mod, Attributes attrs, Location loc)
262 if (type == TypeManager.system_void_expr)
263 Report.Error (1536, loc, "Invalid parameter type `void'");
271 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
273 if (a.Type == pa.In && ModFlags == Modifier.OUT) {
274 Report.Error (36, a.Location, "An out parameter cannot have the `In' attribute");
278 if (a.Type == pa.ParamArray) {
279 Report.Error (674, a.Location, "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead");
283 if (a.Type == PredefinedAttributes.Get.Out && (ModFlags & Modifier.REF) == Modifier.REF &&
284 !OptAttributes.Contains (pa.In)) {
285 Report.Error (662, a.Location,
286 "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither");
290 if (a.Type == pa.CLSCompliant) {
291 Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
294 // TypeManager.default_parameter_value_attribute_type is null if !NET_2_0, or if System.dll is not referenced
295 if (a.Type == pa.DefaultParameterValue) {
296 object val = a.GetParameterDefaultValue ();
298 Type t = val.GetType ();
299 if (t.IsArray || TypeManager.IsSubclassOf (t, TypeManager.type_type)) {
300 if (parameter_type == TypeManager.object_type) {
302 t = TypeManager.type_type;
304 Report.Error (1910, a.Location, "Argument of type `{0}' is not applicable for the DefaultValue attribute",
305 TypeManager.CSharpName (t));
307 Report.Error (1909, a.Location, "The DefaultValue attribute is not applicable on parameters of type `{0}'",
308 TypeManager.CSharpName (parameter_type)); ;
314 if (parameter_type == TypeManager.object_type ||
315 (val == null && !TypeManager.IsGenericParameter (parameter_type) && TypeManager.IsReferenceType (parameter_type)) ||
316 (val != null && TypeManager.TypeToCoreType (val.GetType ()) == parameter_type))
317 builder.SetConstant (val);
319 Report.Error (1908, a.Location, "The type of the default value should match the type of the parameter");
323 base.ApplyAttributeBuilder (a, cb, pa);
326 public virtual bool CheckAccessibility (InterfaceMemberBase member)
328 if (parameter_type == null || TypeManager.IsGenericParameter (parameter_type))
331 return member.IsAccessibleAs (parameter_type);
334 public override IResolveContext ResolveContext {
336 return resolve_context;
341 // Resolve is used in method definitions
343 public virtual Type Resolve (IResolveContext ec)
345 // HACK: to resolve attributes correctly
346 this.resolve_context = ec;
348 if (parameter_type != null)
349 return parameter_type;
351 TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
355 parameter_type = texpr.Type;
357 if ((modFlags & Parameter.Modifier.ISBYREF) != 0 &&
358 TypeManager.IsSpecialType (parameter_type)) {
359 Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'",
360 GetSignatureForError ());
364 var tp = TypeManager.LookupTypeParameter (parameter_type);
366 if ((modFlags & Parameter.Modifier.ISBYREF) != 0) {
367 if (tp.Variance != Variance.None)
368 tp.ErrorInvalidVariance ((MemberCore) ec, Variance.None);
369 } else if (tp.Variance == Variance.Covariant) {
370 tp.ErrorInvalidVariance ((MemberCore) ec, Variance.Contravariant);
373 if ((parameter_type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
374 Report.Error (721, Location, "`{0}': static types cannot be used as parameters",
375 texpr.GetSignatureForError ());
376 return parameter_type;
379 if ((modFlags & Modifier.This) != 0 && parameter_type.IsPointer) {
380 Report.Error (1103, Location, "The type of extension method cannot be `{0}'",
381 TypeManager.CSharpName (parameter_type));
385 return parameter_type;
388 public void ResolveVariable (int idx)
393 public bool HasExtensionMethodModifier {
394 get { return (modFlags & Modifier.This) != 0; }
397 public Modifier ModFlags {
398 get { return modFlags & ~Modifier.This; }
403 set { name = value; }
406 ParameterAttributes Attributes {
407 get { return ParametersCompiled.GetParameterAttribute (modFlags); }
410 public override AttributeTargets AttributeTargets {
412 return AttributeTargets.Parameter;
416 public virtual string GetSignatureForError ()
419 if (parameter_type != null)
420 type_name = TypeManager.CSharpName (parameter_type);
422 type_name = TypeName.GetSignatureForError ();
424 string mod = GetModifierSignature (modFlags);
426 return String.Concat (mod, " ", type_name);
431 public static string GetModifierSignature (Modifier mod)
436 case Modifier.PARAMS:
447 public void IsClsCompliant ()
449 if (AttributeTester.IsClsCompliant (parameter_type))
452 Report.Warning (3001, 1, Location, "Argument type `{0}' is not CLS-compliant", GetSignatureForError ());
455 public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
458 builder = cb.DefineParameter (index, Attributes, Name);
460 builder = mb.DefineParameter (index, Attributes, Name);
462 if (OptAttributes != null)
463 OptAttributes.Emit ();
466 public override string[] ValidAttributeTargets {
468 return attribute_targets;
472 public Parameter Clone ()
474 Parameter p = (Parameter) MemberwiseClone ();
475 if (attributes != null) {
476 p.attributes = attributes.Clone ();
477 p.attributes.AttachTo (p);
483 public ExpressionStatement CreateExpressionTreeVariable (EmitContext ec)
486 // A parameter is not hoisted when used directly as ET
488 HoistedVariableReference = null;
490 if ((modFlags & Modifier.ISBYREF) != 0)
491 Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
493 LocalInfo variable = ec.CurrentBlock.AddTemporaryVariable (
494 ResolveParameterExpressionType (ec, Location), Location);
495 variable.Resolve (ec);
497 expr_tree_variable = new LocalVariableReference (
498 ec.CurrentBlock, variable.Name, Location, variable, false);
500 ArrayList arguments = new ArrayList (2);
501 arguments.Add (new Argument (new TypeOf (
502 new TypeExpression (parameter_type, Location), Location)));
503 arguments.Add (new Argument (new StringConstant (Name, Location)));
504 return new SimpleAssign (ExpressionTreeVariableReference (),
505 Expression.CreateExpressionFactoryCall ("Parameter", null, arguments, Location));
508 public void Emit (EmitContext ec)
514 ParameterReference.EmitLdArg (ec.ig, arg_idx);
517 public void EmitAssign (EmitContext ec)
524 ec.ig.Emit (OpCodes.Starg_S, (byte) arg_idx);
526 ec.ig.Emit (OpCodes.Starg, arg_idx);
529 public void EmitAddressOf (EmitContext ec)
536 bool is_ref = (ModFlags & Modifier.ISBYREF) != 0;
538 ParameterReference.EmitLdArg (ec.ig, arg_idx);
541 ec.ig.Emit (OpCodes.Ldarga_S, (byte) arg_idx);
543 ec.ig.Emit (OpCodes.Ldarga, arg_idx);
547 public Expression ExpressionTreeVariableReference ()
549 return expr_tree_variable;
553 // System.Linq.Expressions.ParameterExpression type
555 public static TypeExpr ResolveParameterExpressionType (EmitContext ec, Location location)
557 if (parameter_expr_tree_type != null)
558 return parameter_expr_tree_type;
560 Type p_type = TypeManager.parameter_expression_type;
561 if (p_type == null) {
562 p_type = TypeManager.CoreLookupType ("System.Linq.Expressions", "ParameterExpression", Kind.Class, true);
563 TypeManager.parameter_expression_type = p_type;
566 parameter_expr_tree_type = new TypeExpression (p_type, location).
567 ResolveAsTypeTerminal (ec, false);
569 return parameter_expr_tree_type;
574 // Imported or resolved parameter information
576 public class ParameterData : IParameterData
578 readonly string name;
579 readonly Parameter.Modifier modifiers;
581 public ParameterData (string name, Parameter.Modifier modifiers)
584 this.modifiers = modifiers;
587 #region IParameterData Members
589 public bool HasExtensionMethodModifier {
590 get { return (modifiers & Parameter.Modifier.This) != 0; }
593 public Parameter.Modifier ModFlags {
594 get { return modifiers & ~Parameter.Modifier.This; }
604 public abstract class AParametersCollection
606 protected bool has_arglist;
607 protected bool has_params;
609 // Null object pattern
610 protected IParameterData [] parameters;
611 protected Type [] types;
614 get { return parameters.Length; }
617 public Type ExtensionMethodType {
622 return FixedParameters [0].HasExtensionMethodModifier ?
627 public IParameterData [] FixedParameters {
633 public static ParameterAttributes GetParameterAttribute (Parameter.Modifier modFlags)
635 return (modFlags & Parameter.Modifier.OUT) == Parameter.Modifier.OUT ?
636 ParameterAttributes.Out : ParameterAttributes.None;
639 public Type [] GetEmitTypes ()
641 Type [] types = null;
644 return Type.EmptyTypes;
646 types = new Type [Count - 1];
647 Array.Copy (Types, types, types.Length);
650 for (int i = 0; i < Count; ++i) {
651 if ((FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) == 0)
655 types = (Type []) Types.Clone ();
657 types [i] = TypeManager.GetReferenceType (types [i]);
666 public string GetSignatureForError ()
668 StringBuilder sb = new StringBuilder ("(");
669 for (int i = 0; i < Count; ++i) {
672 sb.Append (ParameterDesc (i));
675 return sb.ToString ();
678 public bool HasArglist {
679 get { return has_arglist; }
682 public bool HasExtensionMethodType {
687 return FixedParameters [0].HasExtensionMethodModifier;
691 public bool HasParams {
692 get { return has_params; }
695 public bool IsEmpty {
696 get { return parameters.Length == 0; }
699 public string ParameterDesc (int pos)
701 if (types == null || types [pos] == null)
702 return ((Parameter)FixedParameters [pos]).GetSignatureForError ();
704 string type = TypeManager.CSharpName (types [pos]);
705 if (FixedParameters [pos].HasExtensionMethodModifier)
706 return "this " + type;
708 Parameter.Modifier mod = FixedParameters [pos].ModFlags & ~Parameter.Modifier.ARGLIST;
712 return Parameter.GetModifierSignature (mod) + " " + type;
715 public Type[] Types {
716 get { return types; }
717 set { types = value; }
721 public AParametersCollection InflateTypes (Type[] genArguments, Type[] argTypes)
723 AParametersCollection p = (AParametersCollection) MemberwiseClone (); // Clone ();
725 for (int i = 0; i < Count; ++i) {
726 if (types[i].IsGenericType) {
727 Type[] gen_arguments_open = new Type[types[i].GetGenericTypeDefinition ().GetGenericArguments ().Length];
728 Type[] gen_arguments = types[i].GetGenericArguments ();
729 for (int ii = 0; ii < gen_arguments_open.Length; ++ii) {
730 if (gen_arguments[ii].IsGenericParameter) {
731 Type t = argTypes[gen_arguments[ii].GenericParameterPosition];
732 gen_arguments_open[ii] = t;
734 gen_arguments_open[ii] = gen_arguments[ii];
737 p.types[i] = types[i].GetGenericTypeDefinition ().MakeGenericType (gen_arguments_open);
741 if (types[i].IsGenericParameter) {
742 Type gen_argument = argTypes[types[i].GenericParameterPosition];
743 p.types[i] = gen_argument;
754 // A collection of imported or resolved parameters
756 public class ParametersImported : AParametersCollection
758 ParametersImported (AParametersCollection param, Type[] types)
760 this.parameters = param.FixedParameters;
762 has_arglist = param.HasArglist;
763 has_params = param.HasParams;
766 ParametersImported (IParameterData [] parameters, Type [] types, MethodBase method, bool hasParams)
768 this.parameters = parameters;
770 has_arglist = (method.CallingConvention & CallingConventions.VarArgs) != 0;
772 this.parameters = new IParameterData [parameters.Length + 1];
773 parameters.CopyTo (this.parameters, 0);
774 this.parameters [parameters.Length] = new ArglistParameter (Location.Null);
775 this.types = new Type [types.Length + 1];
776 types.CopyTo (this.types, 0);
777 this.types [types.Length] = TypeManager.arg_iterator_type;
779 has_params = hasParams;
782 public ParametersImported (IParameterData [] param, Type[] types)
784 this.parameters = param;
788 public static AParametersCollection Create (MethodBase method)
790 return Create (method.GetParameters (), method);
794 // Generic method parameters importer, param is shared between all instances
796 public static AParametersCollection Create (AParametersCollection param, MethodBase method)
801 ParameterInfo [] pi = method.GetParameters ();
802 Type [] types = new Type [pi.Length];
803 for (int i = 0; i < types.Length; i++) {
804 Type t = pi [i].ParameterType;
806 t = TypeManager.GetElementType (t);
808 types [i] = TypeManager.TypeToCoreType (t);
811 return new ParametersImported (param, types);
815 // Imports SRE parameters
817 public static AParametersCollection Create (ParameterInfo [] pi, MethodBase method)
819 if (pi.Length == 0) {
820 if (method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0)
821 return new ParametersImported (new IParameterData [0], Type.EmptyTypes, method, false);
823 return ParametersCompiled.EmptyReadOnlyParameters;
826 Type [] types = new Type [pi.Length];
827 IParameterData [] par = new IParameterData [pi.Length];
828 bool is_params = false;
829 PredefinedAttribute extension_attr = PredefinedAttributes.Get.Extension;
830 PredefinedAttribute param_attr = PredefinedAttributes.Get.ParamArray;
831 for (int i = 0; i < types.Length; i++) {
832 types [i] = TypeManager.TypeToCoreType (pi [i].ParameterType);
834 ParameterInfo p = pi [i];
835 Parameter.Modifier mod = 0;
836 if (types [i].IsByRef) {
837 if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
838 mod = Parameter.Modifier.OUT;
840 mod = Parameter.Modifier.REF;
843 // Strip reference wrapping
845 types [i] = TypeManager.GetElementType (types [i]);
846 } else if (i == 0 && extension_attr.IsDefined && method != null && method.IsStatic &&
847 (method.DeclaringType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
848 method.IsDefined (extension_attr.Type, false)) {
849 mod = Parameter.Modifier.This;
850 } else if (i >= pi.Length - 2 && types [i].IsArray) {
851 if (p.IsDefined (param_attr.Type, false)) {
852 mod = Parameter.Modifier.PARAMS;
857 par [i] = new ParameterData (p.Name, mod);
860 return method != null ?
861 new ParametersImported (par, types, method, is_params) :
862 new ParametersImported (par, types);
867 /// Represents the methods parameters
869 public class ParametersCompiled : AParametersCollection
871 public static readonly ParametersCompiled EmptyReadOnlyParameters = new ParametersCompiled ();
873 // Used by C# 2.0 delegates
874 public static readonly ParametersCompiled Undefined = new ParametersCompiled ();
876 private ParametersCompiled ()
878 parameters = new Parameter [0];
879 types = Type.EmptyTypes;
882 private ParametersCompiled (Parameter [] parameters, Type [] types)
884 this.parameters = parameters;
888 public ParametersCompiled (params Parameter[] parameters)
890 if (parameters == null)
891 throw new ArgumentException ("Use EmptyReadOnlyParameters");
893 this.parameters = parameters;
894 int count = parameters.Length;
900 has_params = (parameters [0].ModFlags & Parameter.Modifier.PARAMS) != 0;
904 for (int i = 0; i < count; i++){
905 string base_name = parameters [i].Name;
906 has_params |= (parameters [i].ModFlags & Parameter.Modifier.PARAMS) != 0;
908 for (int j = i + 1; j < count; j++){
909 if (base_name != parameters [j].Name)
912 ErrorDuplicateName (parameters [i]);
918 public ParametersCompiled (Parameter [] parameters, bool has_arglist) :
921 this.has_arglist = has_arglist;
924 public static ParametersCompiled CreateFullyResolved (Parameter p, Type type)
926 return new ParametersCompiled (new Parameter [] { p }, new Type [] { type });
929 public static ParametersCompiled CreateFullyResolved (Parameter[] parameters, Type[] types)
931 return new ParametersCompiled (parameters, types);
934 public static ParametersCompiled MergeGenerated (ParametersCompiled userParams, bool checkConflicts, Parameter compilerParams, Type compilerTypes)
936 return MergeGenerated (userParams, checkConflicts,
937 new Parameter [] { compilerParams },
938 new Type [] { compilerTypes });
942 // Use this method when you merge compiler generated parameters with user parameters
944 public static ParametersCompiled MergeGenerated (ParametersCompiled userParams, bool checkConflicts, Parameter[] compilerParams, Type[] compilerTypes)
946 Parameter[] all_params = new Parameter [userParams.Count + compilerParams.Length];
947 userParams.FixedParameters.CopyTo(all_params, 0);
950 if (userParams.types != null) {
951 all_types = new Type [all_params.Length];
952 userParams.Types.CopyTo (all_types, 0);
957 int last_filled = userParams.Count;
959 foreach (Parameter p in compilerParams) {
960 for (int i = 0; i < last_filled; ++i) {
961 while (p.Name == all_params [i].Name) {
962 if (checkConflicts && i < userParams.Count) {
963 Report.Error (316, userParams [i].Location,
964 "The parameter name `{0}' conflicts with a compiler generated name", p.Name);
966 p.Name = '_' + p.Name;
969 all_params [last_filled] = p;
970 if (all_types != null)
971 all_types [last_filled] = compilerTypes [index++];
975 ParametersCompiled parameters = new ParametersCompiled (all_params, all_types);
976 parameters.has_params = userParams.has_params;
980 protected virtual void ErrorDuplicateName (Parameter p)
982 Report.Error (100, p.Location, "The parameter name `{0}' is a duplicate", p.Name);
986 /// Returns the parameter information based on the name
988 public int GetParameterIndexByName (string name)
990 for (int idx = 0; idx < Count; ++idx) {
991 if (parameters [idx].Name == name)
998 public bool Resolve (IResolveContext ec)
1003 types = new Type [Count];
1007 for (int i = 0; i < FixedParameters.Length; ++i) {
1009 Type t = p.Resolve (ec);
1021 public void ResolveVariable ()
1023 for (int i = 0; i < FixedParameters.Length; ++i) {
1024 this [i].ResolveVariable (i);
1028 public CallingConventions CallingConvention
1032 return CallingConventions.VarArgs;
1034 return CallingConventions.Standard;
1038 // Define each type attribute (in/out/ref) and
1039 // the argument names.
1040 public void ApplyAttributes (MethodBase builder)
1045 MethodBuilder mb = builder as MethodBuilder;
1046 ConstructorBuilder cb = builder as ConstructorBuilder;
1048 for (int i = 0; i < Count; i++) {
1049 this [i].ApplyAttributes (mb, cb, i + 1);
1053 public void VerifyClsCompliance ()
1055 foreach (Parameter p in FixedParameters)
1056 p.IsClsCompliant ();
1059 public Parameter this [int pos] {
1060 get { return (Parameter) parameters [pos]; }
1063 public Expression CreateExpressionTree (EmitContext ec, Location loc)
1065 ArrayList initializers = new ArrayList (Count);
1066 foreach (Parameter p in FixedParameters) {
1068 // Each parameter expression is stored to local variable
1069 // to save some memory when referenced later.
1071 StatementExpression se = new StatementExpression (p.CreateExpressionTreeVariable (ec));
1072 if (se.Resolve (ec))
1073 ec.CurrentBlock.AddScopeStatement (se);
1075 initializers.Add (p.ExpressionTreeVariableReference ());
1078 return new ArrayCreation (
1079 Parameter.ResolveParameterExpressionType (ec, loc),
1080 "[]", initializers, loc);
1083 public ParametersCompiled Clone ()
1085 ParametersCompiled p = (ParametersCompiled) MemberwiseClone ();
1087 p.parameters = new IParameterData [parameters.Length];
1088 for (int i = 0; i < Count; ++i)
1089 p.parameters [i] = this [i].Clone ();