2 // parameter.cs: Parameter definition.
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
11 // FIXME: We should deprecate ParameterCollection as it is mostly slow
12 // to access (it uses an arraylist instead of a hashtable) and exposes
13 // no method to quickly locate parameters by name.
15 // Look at the implementation for GetParameterByName for an example.
22 public class Parameter {
23 public enum Modifier {
30 public readonly string Type;
31 public readonly string Name;
32 public readonly Modifier ModFlags;
34 public Parameter (string type, string name, Modifier mod)
41 string ModSignature ()
53 // This should not happen.
58 // Returns the signature for this parameter evaluating it on the
61 public string GetSignature (TypeContainer tc)
63 Type t = tc.LookupType (Type, false);
68 return ModSignature () + t.FullName;
72 public class Parameters {
73 ParameterCollection fixed_parameters;
74 Parameter array_parameter;
77 public Parameters (ParameterCollection fixed_parameters, Parameter array_parameter)
79 this.fixed_parameters = fixed_parameters;
80 this.array_parameter = array_parameter;
84 // Returns the fixed parameters element
86 public ParameterCollection FixedParameters {
88 return fixed_parameters;
93 // Returns the array parameter.
95 public Parameter ArrayParameter {
97 return array_parameter;
101 public void ComputeSignature (TypeContainer tc)
104 if (fixed_parameters != null){
105 for (int i = 0; i < fixed_parameters.Count; i++){
106 Parameter par = (Parameter) fixed_parameters [i];
108 signature += par.GetSignature (tc);
112 // Note: as per the spec, the `params' arguments (array_parameter)
113 // are not used in the signature computation for a method
118 // Returns the signature of the Parameters evaluated in
119 // the @tc environment
121 public string GetSignature (TypeContainer tc)
123 if (signature == null)
124 ComputeSignature (tc);
130 // Returns the paramenter information based on the name
132 public Parameter GetParameterByName (string name)
134 if (fixed_parameters == null)
137 foreach (Parameter par in fixed_parameters)
138 if (par.Name == name)
145 // Returns the argument types as an array
147 public Type [] GetTypes (TypeContainer tc)
149 int extra = (array_parameter != null) ? 1 : 0;
150 Type [] types = new Type [fixed_parameters.Count + extra];
153 foreach (Parameter p in fixed_parameters){
154 types [i++] = tc.LookupType (p.Name, false);
158 types [i] = Type.GetType ("System.Object");