5
// Jb Evain (jbevain@gmail.com)
7
// (C) 2005 - 2007 Jb Evain
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
namespace Mono.Cecil {
33
public class MethodReference : MemberReference, IMethodSignature, IGenericParameterProvider {
35
ParameterDefinitionCollection m_parameters;
36
MethodReturnType m_returnType;
40
MethodCallingConvention m_callConv;
41
GenericParameterCollection m_genparams;
43
public virtual bool HasThis {
44
get { return m_hasThis; }
45
set { m_hasThis = value; }
48
public virtual bool ExplicitThis {
49
get { return m_explicitThis; }
50
set { m_explicitThis = value; }
53
public virtual MethodCallingConvention CallingConvention {
54
get { return m_callConv; }
55
set { m_callConv = value; }
58
public virtual ParameterDefinitionCollection Parameters {
60
if (m_parameters == null)
61
m_parameters = new ParameterDefinitionCollection (this);
66
public GenericParameterCollection GenericParameters {
68
if (m_genparams == null)
69
m_genparams = new GenericParameterCollection (this);
74
public virtual MethodReturnType ReturnType {
75
get { return m_returnType;}
76
set { m_returnType = value; }
79
internal MethodReference (string name, bool hasThis,
80
bool explicitThis, MethodCallingConvention callConv) : this (name)
82
m_parameters = new ParameterDefinitionCollection (this);
84
m_explicitThis = explicitThis;
85
m_callConv = callConv;
88
internal MethodReference (string name) : base (name)
90
m_returnType = new MethodReturnType (null);
93
public MethodReference (string name,
94
TypeReference declaringType, TypeReference returnType,
95
bool hasThis, bool explicitThis, MethodCallingConvention callConv) :
96
this (name, hasThis, explicitThis, callConv)
98
this.DeclaringType = declaringType;
99
this.ReturnType.ReturnType = returnType;
102
public virtual MethodReference GetOriginalMethod ()
107
public int GetSentinel ()
109
for (int i = 0; i < Parameters.Count; i++)
110
if (Parameters [i].ParameterType is SentinelType)
116
public override string ToString ()
118
int sentinel = GetSentinel ();
120
StringBuilder sb = new StringBuilder ();
121
sb.Append (m_returnType.ReturnType.FullName);
123
sb.Append (base.ToString ());
125
for (int i = 0; i < this.Parameters.Count; i++) {
132
sb.Append (this.Parameters [i].ParameterType.FullName);
135
return sb.ToString ();