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)
36 if (a.Type == TypeManager.marshal_as_attr_type) {
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)
75 if (a.Type == TypeManager.cls_compliant_attribute_type) {
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);
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, "");
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);
187 CustomAttributeBuilder ca = TypeManager.param_array_attr;
189 ConstructorInfo ci = TypeManager.GetPredefinedConstructor (TypeManager.param_array_type, Location, Type.EmptyTypes);
193 ca = new CustomAttributeBuilder (ci, new object [0]);
197 TypeManager.param_array_attr = ca;
200 builder.SetCustomAttribute (ca);
204 public class ArglistParameter : Parameter {
205 // Doesn't have proper type because it's never chosen for better conversion
206 public ArglistParameter (Location loc) :
207 base (null, String.Empty, Parameter.Modifier.ARGLIST, null, loc)
211 public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
216 public override bool CheckAccessibility (InterfaceMemberBase member)
221 public override Type Resolve (IResolveContext ec)
223 return typeof (ArglistParameter);
226 public override string GetSignatureForError ()
232 public interface IParameterData
234 bool HasExtensionMethodModifier { get; }
235 Parameter.Modifier ModFlags { get; }
240 // Parameter information created by parser
242 public class Parameter : ParameterBase, IParameterData, ILocalVariable {
244 public enum Modifier : byte {
246 REF = REFMASK | ISBYREF,
247 OUT = OUTMASK | ISBYREF,
249 // This is a flag which says that it's either REF or OUT.
257 static string[] attribute_targets = new string [] { "param" };
259 protected FullNamedExpression TypeName;
260 readonly Modifier modFlags;
262 protected Type parameter_type;
263 public readonly Location Location;
265 public bool HasAddressTaken;
267 IResolveContext resolve_context;
268 LocalVariableReference expr_tree_variable;
269 static TypeExpr parameter_expr_tree_type;
271 public HoistedVariable HoistedVariableReference;
273 public Parameter (FullNamedExpression type, string name, Modifier mod, Attributes attrs, Location loc)
276 if (type == TypeManager.system_void_expr)
277 Report.Error (1536, loc, "Invalid parameter type `void'");
285 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
287 if (a.Type == TypeManager.in_attribute_type && ModFlags == Modifier.OUT) {
288 Report.Error (36, a.Location, "An out parameter cannot have the `In' attribute");
292 if (a.Type == TypeManager.param_array_type) {
293 Report.Error (674, a.Location, "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead");
297 if (a.Type == TypeManager.out_attribute_type && (ModFlags & Modifier.REF) == Modifier.REF &&
298 TypeManager.in_attribute_type != null && !OptAttributes.Contains (TypeManager.in_attribute_type)) {
299 Report.Error (662, a.Location,
300 "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither");
304 if (a.Type == TypeManager.cls_compliant_attribute_type) {
305 Report.Warning (3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead");
308 // TypeManager.default_parameter_value_attribute_type is null if !NET_2_0, or if System.dll is not referenced
309 if (a.Type == TypeManager.default_parameter_value_attribute_type) {
310 object val = a.GetParameterDefaultValue ();
312 Type t = val.GetType ();
313 if (t.IsArray || TypeManager.IsSubclassOf (t, TypeManager.type_type)) {
314 if (parameter_type == TypeManager.object_type) {
316 t = TypeManager.type_type;
318 Report.Error (1910, a.Location, "Argument of type `{0}' is not applicable for the DefaultValue attribute",
319 TypeManager.CSharpName (t));
321 Report.Error (1909, a.Location, "The DefaultValue attribute is not applicable on parameters of type `{0}'",
322 TypeManager.CSharpName (parameter_type)); ;
328 if (parameter_type == TypeManager.object_type ||
329 (val == null && !TypeManager.IsValueType (parameter_type)) ||
330 (val != null && TypeManager.TypeToCoreType (val.GetType ()) == parameter_type))
331 builder.SetConstant (val);
333 Report.Error (1908, a.Location, "The type of the default value should match the type of the parameter");
337 base.ApplyAttributeBuilder (a, cb);
340 public virtual bool CheckAccessibility (InterfaceMemberBase member)
342 if (parameter_type == null || TypeManager.IsGenericParameter (parameter_type))
345 return member.IsAccessibleAs (parameter_type);
348 public override IResolveContext ResolveContext {
350 return resolve_context;
355 // Resolve is used in method definitions
357 public virtual Type Resolve (IResolveContext ec)
359 // HACK: to resolve attributes correctly
360 this.resolve_context = ec;
362 if (parameter_type != null)
363 return parameter_type;
365 TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
369 parameter_type = texpr.Type;
371 if ((modFlags & Parameter.Modifier.ISBYREF) != 0 &&
372 TypeManager.IsSpecialType (parameter_type)) {
373 Report.Error (1601, Location, "Method or delegate parameter cannot be of type `{0}'",
374 GetSignatureForError ());
379 TypeParameterExpr tparam = texpr as TypeParameterExpr;
380 if (tparam != null) {
381 return parameter_type;
385 if ((parameter_type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
386 Report.Error (721, Location, "`{0}': static types cannot be used as parameters",
387 texpr.GetSignatureForError ());
388 return parameter_type;
391 if ((modFlags & Modifier.This) != 0 && parameter_type.IsPointer) {
392 Report.Error (1103, Location, "The type of extension method cannot be `{0}'",
393 TypeManager.CSharpName (parameter_type));
396 return parameter_type;
399 public void ResolveVariable (int idx)
404 public bool HasExtensionMethodModifier {
405 get { return (modFlags & Modifier.This) != 0; }
408 public Modifier ModFlags {
409 get { return modFlags & ~Modifier.This; }
414 set { name = value; }
417 ParameterAttributes Attributes {
418 get { return Parameters.GetParameterAttribute (modFlags); }
421 public override AttributeTargets AttributeTargets {
423 return AttributeTargets.Parameter;
427 public virtual string GetSignatureForError ()
430 if (parameter_type != null)
431 type_name = TypeManager.CSharpName (parameter_type);
433 type_name = TypeName.GetSignatureForError ();
435 string mod = GetModifierSignature (modFlags);
437 return String.Concat (mod, " ", type_name);
442 public static string GetModifierSignature (Modifier mod)
447 case Modifier.PARAMS:
458 public void IsClsCompliant ()
460 if (AttributeTester.IsClsCompliant (parameter_type))
463 Report.Warning (3001, 1, Location, "Argument type `{0}' is not CLS-compliant", GetSignatureForError ());
466 public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
469 builder = cb.DefineParameter (index, Attributes, Name);
471 builder = mb.DefineParameter (index, Attributes, Name);
473 if (OptAttributes != null)
474 OptAttributes.Emit ();
477 public override string[] ValidAttributeTargets {
479 return attribute_targets;
483 public Parameter Clone ()
485 Parameter p = (Parameter) MemberwiseClone ();
486 if (attributes != null) {
487 p.attributes = attributes.Clone ();
488 p.attributes.AttachTo (p);
494 public ExpressionStatement CreateExpressionTreeVariable (EmitContext ec)
496 if ((modFlags & Modifier.ISBYREF) != 0)
497 Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
499 LocalInfo variable = ec.CurrentBlock.AddTemporaryVariable (
500 ResolveParameterExpressionType (ec, Location), Location);
501 variable.Resolve (ec);
503 expr_tree_variable = new LocalVariableReference (
504 ec.CurrentBlock, variable.Name, Location, variable, false);
506 ArrayList arguments = new ArrayList (2);
507 arguments.Add (new Argument (new TypeOf (
508 new TypeExpression (parameter_type, Location), Location)));
509 arguments.Add (new Argument (new StringConstant (Name, Location)));
510 return new SimpleAssign (ExpressionTreeVariableReference (),
511 Expression.CreateExpressionFactoryCall ("Parameter", null, arguments, Location));
514 public void Emit (EmitContext ec)
520 ParameterReference.EmitLdArg (ec.ig, arg_idx);
523 public void EmitAssign (EmitContext ec)
530 ec.ig.Emit (OpCodes.Starg_S, (byte) arg_idx);
532 ec.ig.Emit (OpCodes.Starg, arg_idx);
535 public void EmitAddressOf (EmitContext ec)
542 bool is_ref = (ModFlags & Modifier.ISBYREF) != 0;
545 ec.ig.Emit (OpCodes.Ldarg_S, (byte) arg_idx);
547 ec.ig.Emit (OpCodes.Ldarg, arg_idx);
550 ec.ig.Emit (OpCodes.Ldarga_S, (byte) arg_idx);
552 ec.ig.Emit (OpCodes.Ldarga, arg_idx);
556 public Expression ExpressionTreeVariableReference ()
558 return expr_tree_variable;
562 // System.Linq.Expressions.ParameterExpression type
564 public static TypeExpr ResolveParameterExpressionType (EmitContext ec, Location location)
566 if (parameter_expr_tree_type != null)
567 return parameter_expr_tree_type;
569 Type p_type = TypeManager.parameter_expression_type;
570 if (p_type == null) {
571 p_type = TypeManager.CoreLookupType ("System.Linq.Expressions", "ParameterExpression", Kind.Class, true);
572 TypeManager.parameter_expression_type = p_type;
575 parameter_expr_tree_type = new TypeExpression (p_type, location).
576 ResolveAsTypeTerminal (ec, false);
578 return parameter_expr_tree_type;
583 // Imported or resolved parameter information
585 public class ParameterData : IParameterData
587 readonly string name;
588 readonly Parameter.Modifier modifiers;
590 public ParameterData (string name, Parameter.Modifier modifiers)
593 this.modifiers = modifiers;
596 #region IParameterData Members
598 public bool HasExtensionMethodModifier {
599 get { return (modifiers & Parameter.Modifier.This) != 0; }
602 public Parameter.Modifier ModFlags {
603 get { return modifiers & ~Parameter.Modifier.This; }
613 public abstract class AParametersCollection
615 protected bool has_arglist;
616 protected bool has_params;
618 // Null object pattern
619 protected IParameterData [] parameters;
620 protected Type [] types;
623 get { return parameters.Length; }
626 public Type ExtensionMethodType {
631 return FixedParameters [0].HasExtensionMethodModifier ?
636 public IParameterData [] FixedParameters {
642 public static ParameterAttributes GetParameterAttribute (Parameter.Modifier modFlags)
644 return (modFlags & Parameter.Modifier.OUT) == Parameter.Modifier.OUT ?
645 ParameterAttributes.Out : ParameterAttributes.None;
648 public Type [] GetEmitTypes ()
650 Type [] types = null;
653 return Type.EmptyTypes;
655 types = new Type [Count - 1];
656 Array.Copy (Types, types, types.Length);
659 for (int i = 0; i < Count; ++i) {
660 if ((FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) == 0)
664 types = (Type []) Types.Clone ();
666 types [i] = TypeManager.GetReferenceType (types [i]);
675 public string GetSignatureForError ()
677 StringBuilder sb = new StringBuilder ("(");
678 for (int i = 0; i < Count; ++i) {
681 sb.Append (ParameterDesc (i));
684 return sb.ToString ();
687 public bool HasArglist {
688 get { return has_arglist; }
691 public bool HasExtensionMethodType {
696 return FixedParameters [0].HasExtensionMethodModifier;
700 public bool HasParams {
701 get { return has_params; }
704 public bool IsEmpty {
705 get { return parameters.Length == 0; }
708 public string ParameterDesc (int pos)
710 if (types == null || types [pos] == null)
711 return ((Parameter)FixedParameters [pos]).GetSignatureForError ();
713 string type = TypeManager.CSharpName (types [pos]);
714 if (FixedParameters [pos].HasExtensionMethodModifier)
715 return "this " + type;
717 Parameter.Modifier mod = FixedParameters [pos].ModFlags & ~Parameter.Modifier.ARGLIST;
721 return Parameter.GetModifierSignature (mod) + " " + type;
724 public Type[] Types {
725 get { return types; }
726 set { types = value; }
731 // A collection of imported or resolved parameters
733 public class ParametersCollection : AParametersCollection
735 ParametersCollection (AParametersCollection param, Type[] types)
737 this.parameters = param.FixedParameters;
739 has_arglist = param.HasArglist;
740 has_params = param.HasParams;
743 ParametersCollection (IParameterData [] parameters, Type [] types, MethodBase method, bool hasParams)
745 this.parameters = parameters;
747 has_arglist = (method.CallingConvention & CallingConventions.VarArgs) != 0;
749 this.parameters = new IParameterData [parameters.Length + 1];
750 parameters.CopyTo (this.parameters, 0);
751 this.parameters [parameters.Length] = new ArglistParameter (Location.Null);
752 this.types = new Type [types.Length + 1];
753 types.CopyTo (this.types, 0);
754 this.types [types.Length] = TypeManager.arg_iterator_type;
756 has_params = hasParams;
759 public ParametersCollection (IParameterData [] param, Type[] types)
761 this.parameters = param;
765 public static AParametersCollection Create (MethodBase method)
767 return Create (method.GetParameters (), method);
771 // Generic method parameters importer, param is shared between all instances
773 public static AParametersCollection Create (AParametersCollection param, MethodBase method)
778 ParameterInfo [] pi = method.GetParameters ();
779 Type [] types = new Type [pi.Length];
780 for (int i = 0; i < types.Length; i++) {
781 Type t = pi [i].ParameterType;
783 t = TypeManager.GetElementType (t);
785 types [i] = TypeManager.TypeToCoreType (t);
788 return new ParametersCollection (param, types);
792 // Imports SRE parameters
794 public static AParametersCollection Create (ParameterInfo [] pi, MethodBase method)
796 if (pi.Length == 0) {
797 if (method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0)
798 return new ParametersCollection (new IParameterData [0], Type.EmptyTypes, method, false);
800 return Parameters.EmptyReadOnlyParameters;
803 Type [] types = new Type [pi.Length];
804 IParameterData [] par = new IParameterData [pi.Length];
805 bool is_params = false;
806 for (int i = 0; i < types.Length; i++) {
807 types [i] = TypeManager.TypeToCoreType (pi [i].ParameterType);
809 ParameterInfo p = pi [i];
810 Parameter.Modifier mod = 0;
811 if (types [i].IsByRef) {
812 if ((p.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
813 mod = Parameter.Modifier.OUT;
815 mod = Parameter.Modifier.REF;
818 // Strip reference wrapping
820 types [i] = TypeManager.GetElementType (types [i]);
821 } else if (i == 0 && TypeManager.extension_attribute_type != null && method != null && method.IsStatic &&
822 (method.DeclaringType.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
823 method.IsDefined (TypeManager.extension_attribute_type, false)) {
824 mod = Parameter.Modifier.This;
825 } else if (i >= pi.Length - 2 && types [i].IsArray) {
826 if (p.IsDefined (TypeManager.param_array_type, false)) {
827 mod = Parameter.Modifier.PARAMS;
832 par [i] = new ParameterData (p.Name, mod);
835 return method != null ?
836 new ParametersCollection (par, types, method, is_params) :
837 new ParametersCollection (par, types);
842 /// Represents the methods parameters
844 public class Parameters : AParametersCollection {
845 public static readonly Parameters EmptyReadOnlyParameters = new Parameters ();
847 private Parameters ()
849 parameters = new Parameter [0];
850 types = Type.EmptyTypes;
853 private Parameters (Parameter [] parameters, Type [] types)
855 this.parameters = parameters;
859 public Parameters (params Parameter[] parameters)
861 if (parameters == null)
862 throw new ArgumentException ("Use EmptyReadOnlyParameters");
864 this.parameters = parameters;
865 int count = parameters.Length;
871 has_params = (parameters [0].ModFlags & Parameter.Modifier.PARAMS) != 0;
875 for (int i = 0; i < count; i++){
876 string base_name = parameters [i].Name;
877 has_params |= (parameters [i].ModFlags & Parameter.Modifier.PARAMS) != 0;
879 for (int j = i + 1; j < count; j++){
880 if (base_name != parameters [j].Name)
883 Report.Error (100, parameters [i].Location,
884 "The parameter name `{0}' is a duplicate", base_name);
890 public Parameters (Parameter [] parameters, bool has_arglist) :
893 this.has_arglist = has_arglist;
896 public static Parameters CreateFullyResolved (Parameter p, Type type)
898 return new Parameters (new Parameter [] { p }, new Type [] { type });
901 public static Parameters CreateFullyResolved (Parameter[] parameters, Type[] types)
903 return new Parameters (parameters, types);
906 public static Parameters MergeGenerated (Parameters userParams, bool checkConflicts, Parameter compilerParams, Type compilerTypes)
908 return MergeGenerated (userParams, checkConflicts,
909 new Parameter [] { compilerParams },
910 new Type [] { compilerTypes });
914 // Use this method when you merge compiler generated parameters with user parameters
916 public static Parameters MergeGenerated (Parameters userParams, bool checkConflicts, Parameter[] compilerParams, Type[] compilerTypes)
918 Parameter[] all_params = new Parameter [userParams.Count + compilerParams.Length];
919 userParams.FixedParameters.CopyTo(all_params, 0);
922 if (userParams.types != null) {
923 all_types = new Type [all_params.Length];
924 userParams.Types.CopyTo (all_types, 0);
929 int last_filled = userParams.Count;
931 foreach (Parameter p in compilerParams) {
932 for (int i = 0; i < last_filled; ++i) {
933 while (p.Name == all_params [i].Name) {
934 if (checkConflicts && i < userParams.Count) {
935 Report.Error (316, userParams [i].Location,
936 "The parameter name `{0}' conflicts with a compiler generated name", p.Name);
938 p.Name = '_' + p.Name;
941 all_params [last_filled] = p;
942 if (all_types != null)
943 all_types [last_filled] = compilerTypes [index++];
947 Parameters parameters = new Parameters (all_params, all_types);
948 parameters.has_params = userParams.has_params;
953 /// Returns the paramenter information based on the name
955 public Parameter GetParameterByName (string name, out int idx)
964 foreach (Parameter par in FixedParameters){
965 if (par.Name == name){
974 public Parameter GetParameterByName (string name)
978 return GetParameterByName (name, out idx);
981 public bool Resolve (IResolveContext ec)
986 types = new Type [Count];
990 for (int i = 0; i < FixedParameters.Length; ++i) {
992 Type t = p.Resolve (ec);
1004 public void ResolveVariable ()
1006 for (int i = 0; i < FixedParameters.Length; ++i) {
1007 this [i].ResolveVariable (i);
1011 public CallingConventions CallingConvention
1015 return CallingConventions.VarArgs;
1017 return CallingConventions.Standard;
1021 // Define each type attribute (in/out/ref) and
1022 // the argument names.
1023 public void ApplyAttributes (MethodBase builder)
1028 MethodBuilder mb = builder as MethodBuilder;
1029 ConstructorBuilder cb = builder as ConstructorBuilder;
1031 for (int i = 0; i < Count; i++) {
1032 this [i].ApplyAttributes (mb, cb, i + 1);
1037 public AParametersCollection InflateTypes (Type[] genArguments, Type[] argTypes)
1039 Parameters p = Clone ();
1040 for (int i = 0; i < Count; ++i) {
1041 if (types[i].IsGenericType) {
1042 Type[] gen_arguments_open = new Type [types[i].GetGenericTypeDefinition ().GetGenericArguments ().Length];
1043 Type[] gen_arguments = types[i].GetGenericArguments ();
1044 for (int ii = 0; ii < gen_arguments_open.Length; ++ii) {
1045 if (gen_arguments[ii].IsGenericParameter) {
1046 Type t = argTypes[gen_arguments[ii].GenericParameterPosition];
1047 gen_arguments_open[ii] = t;
1049 gen_arguments_open[ii] = gen_arguments[ii];
1052 p.types[i] = types[i].GetGenericTypeDefinition ().MakeGenericType (gen_arguments_open);
1056 if (types[i].IsGenericParameter) {
1057 Type gen_argument = argTypes[types[i].GenericParameterPosition];
1058 p.types[i] = gen_argument;
1067 public void VerifyClsCompliance ()
1069 foreach (Parameter p in FixedParameters)
1070 p.IsClsCompliant ();
1073 public Parameter this [int pos] {
1074 get { return (Parameter) parameters [pos]; }
1077 public Expression CreateExpressionTree (EmitContext ec, Location loc)
1079 ArrayList initializers = new ArrayList (Count);
1080 foreach (Parameter p in FixedParameters) {
1082 // Each parameter expression is stored to local variable
1083 // to save some memory when referenced later.
1085 StatementExpression se = new StatementExpression (p.CreateExpressionTreeVariable (ec));
1086 if (se.Resolve (ec))
1087 ec.CurrentBlock.AddScopeStatement (se);
1089 initializers.Add (p.ExpressionTreeVariableReference ());
1092 return new ArrayCreation (
1093 Parameter.ResolveParameterExpressionType (ec, loc),
1094 "[]", initializers, loc);
1097 public Parameters Clone ()
1099 Parameter [] parameters_copy = new Parameter [FixedParameters.Length];
1101 foreach (Parameter p in FixedParameters)
1102 parameters_copy [i++] = p.Clone ();
1103 Parameters ps = new Parameters (parameters_copy, HasArglist);
1105 ps.types = (Type[])types.Clone ();