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

            this.method = method;
            this.token = new MetadataToken (TokenType.MethodSpec);
        }
Exemple #3
0
        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;
        }
 public GenericInstanceMethod(MethodReference method)
     : base(method)
 {
 }
Exemple #5
0
 internal CustomAttribute(uint signature, MethodReference constructor)
 {
     this.signature = signature;
     this.constructor = constructor;
     this.resolved = false;
 }
Exemple #6
0
 public CustomAttribute(MethodReference constructor, byte [] blob)
 {
     this.constructor = constructor;
     this.resolved = false;
     this.blob = blob;
 }
Exemple #7
0
 public CustomAttribute(MethodReference constructor)
 {
     this.constructor = constructor;
     this.resolved = true;
 }
Exemple #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;
		}
Exemple #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;
		}
Exemple #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;
		}
Exemple #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);
		}
Exemple #12
0
 internal CallSite()
 {
     this.signature = new MethodReference ();
     this.signature.token = new MetadataToken (TokenType.Signature, 0);
 }