예제 #1
0
 public FunctionPointerType()
     : base(null)
 {
     this.function = new MethodReference ();
     this.function.Name = "method";
     this.etype = MD.ElementType.FnPtr;
 }
예제 #2
0
        internal MethodSpecification(MethodReference method)
        {
            if (method == null)
                throw new ArgumentNullException ("method");

            this.method = method;
            this.token = new MetadataToken (TokenType.MethodSpec);
        }
예제 #3
0
파일: Extensions.cs 프로젝트: ttRevan/cecil
        public static MethodReference MakeGeneric(this MethodReference self, params TypeReference [] arguments)
        {
            var reference = new MethodReference {
                Name = self.Name,
                DeclaringType = self.DeclaringType.MakeGenericType (arguments),
                HasThis = self.HasThis,
                ExplicitThis = self.ExplicitThis,
                ReturnType = self.ReturnType,
                CallingConvention = self.CallingConvention,
            };

            foreach (var parameter in self.Parameters)
                reference.Parameters.Add (new ParameterDefinition (parameter.ParameterType));

            foreach (var generic_parameter in self.GenericParameters)
                reference.GenericParameters.Add (new GenericParameter (generic_parameter.Name, reference));

            return reference;
        }
예제 #4
0
 public GenericInstanceMethod(MethodReference method)
     : base(method)
 {
 }
예제 #5
0
 internal CustomAttribute(uint signature, MethodReference constructor)
 {
     this.signature = signature;
     this.constructor = constructor;
     this.resolved = false;
 }
예제 #6
0
 public CustomAttribute(MethodReference constructor, byte [] blob)
 {
     this.constructor = constructor;
     this.resolved = false;
     this.blob = blob;
 }
예제 #7
0
 public CustomAttribute(MethodReference constructor)
 {
     this.constructor = constructor;
     this.resolved = true;
 }
예제 #8
0
		private static bool IsVarArgCallTo (MethodDefinition method, MethodReference reference)
		{
			if (method.Parameters.Count >= reference.Parameters.Count)
				return false;

			if (reference.GetSentinelPosition () != method.Parameters.Count)
				return false;

			for (int i = 0; i < method.Parameters.Count; i++)
				if (!AreSame (method.Parameters [i].ParameterType, reference.Parameters [i].ParameterType))
					return false;

			return true;
		}
예제 #9
0
		public static MethodDefinition GetMethod (Collection<MethodDefinition> methods, MethodReference reference)
		{
			for (int i = 0; i < methods.Count; i++) {
				var method = methods [i];

				if (method.Name != reference.Name)
					continue;

				if (method.HasGenericParameters != reference.HasGenericParameters)
					continue;

				if (method.HasGenericParameters && method.GenericParameters.Count != reference.GenericParameters.Count)
					continue;

				if (!AreSame (method.ReturnType, reference.ReturnType))
					continue;

				if (method.IsVarArg () != reference.IsVarArg ())
					continue;

				if (method.IsVarArg () && IsVarArgCallTo (method, reference))
					return method;

				if (method.HasParameters != reference.HasParameters)
					continue;

				if (!method.HasParameters && !reference.HasParameters)
					return method;

				if (!AreSame (method.Parameters, reference.Parameters))
					continue;

				return method;
			}

			return null;
		}
예제 #10
0
		MethodDefinition GetMethod (TypeDefinition type, MethodReference reference)
		{
			while (type != null) {
				var method = GetMethod (type.Methods, reference);
				if (method != null)
					return method;

				if (type.BaseType == null)
					return null;

				type = Resolve (type.BaseType);
			}

			return null;
		}
예제 #11
0
		public virtual MethodDefinition Resolve (MethodReference method)
		{
			if (method == null)
				throw new ArgumentNullException ("method");

			var type = Resolve (method.DeclaringType);
			if (type == null)
				return null;

			method = method.GetElementMethod ();

			if (!type.HasMethods)
				return null;

			return GetMethod (type, method);
		}
예제 #12
0
파일: CallSite.cs 프로젝트: ttRevan/cecil
 internal CallSite()
 {
     this.signature = new MethodReference ();
     this.signature.token = new MetadataToken (TokenType.Signature, 0);
 }