PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Mono.Cecil/FunctionPointerType.cs

http://github.com/jbevain/cecil
C# | 111 lines | 81 code | 21 blank | 9 comment | 0 complexity | 1e366e6fb27053f4acaf0be44d198366 MD5 | raw file
  1//
  2// Author:
  3//   Jb Evain (jbevain@gmail.com)
  4//
  5// Copyright (c) 2008 - 2015 Jb Evain
  6// Copyright (c) 2008 - 2011 Novell, Inc.
  7//
  8// Licensed under the MIT/X11 license.
  9//
 10
 11using System;
 12using System.Text;
 13using Mono.Collections.Generic;
 14using MD = Mono.Cecil.Metadata;
 15
 16namespace Mono.Cecil {
 17
 18	public sealed class FunctionPointerType : TypeSpecification, IMethodSignature {
 19
 20		readonly MethodReference function;
 21
 22		public bool HasThis {
 23			get { return function.HasThis; }
 24			set { function.HasThis = value; }
 25		}
 26
 27		public bool ExplicitThis {
 28			get { return function.ExplicitThis; }
 29			set { function.ExplicitThis = value; }
 30		}
 31
 32		public MethodCallingConvention CallingConvention {
 33			get { return function.CallingConvention; }
 34			set { function.CallingConvention = value; }
 35		}
 36
 37		public bool HasParameters {
 38			get { return function.HasParameters; }
 39		}
 40
 41		public Collection<ParameterDefinition> Parameters {
 42			get { return function.Parameters; }
 43		}
 44
 45		public TypeReference ReturnType {
 46			get { return function.MethodReturnType.ReturnType; }
 47			set { function.MethodReturnType.ReturnType = value; }
 48		}
 49
 50		public MethodReturnType MethodReturnType {
 51			get { return function.MethodReturnType; }
 52		}
 53
 54		public override string Name {
 55			get { return function.Name; }
 56			set { throw new InvalidOperationException (); }
 57		}
 58
 59		public override string Namespace {
 60			get { return string.Empty; }
 61			set { throw new InvalidOperationException (); }
 62		}
 63
 64		public override ModuleDefinition Module {
 65			get { return ReturnType.Module; }
 66		}
 67
 68		public override IMetadataScope Scope {
 69			get { return function.ReturnType.Scope; }
 70			set { throw new InvalidOperationException (); }
 71		}
 72
 73		public override bool IsFunctionPointer {
 74			get { return true; }
 75		}
 76
 77		public override bool ContainsGenericParameter {
 78			get { return function.ContainsGenericParameter; }
 79		}
 80
 81		public override string FullName {
 82			get {
 83				var signature = new StringBuilder ();
 84				signature.Append (function.Name);
 85				signature.Append (" ");
 86				signature.Append (function.ReturnType.FullName);
 87				signature.Append (" *");
 88				this.MethodSignatureFullName (signature);
 89				return signature.ToString ();
 90			}
 91		}
 92
 93		public FunctionPointerType ()
 94			: base (null)
 95		{
 96			this.function = new MethodReference ();
 97			this.function.Name = "method";
 98			this.etype = MD.ElementType.FnPtr;
 99		}
100
101		public override TypeDefinition Resolve ()
102		{
103			return null;
104		}
105
106		public override TypeReference GetElementType ()
107		{
108			return this;
109		}
110	}
111}