Beispiel #1
0
 protected EventVariable(ChelaModule module)
     : base(module)
 {
     this.flags           = MemberFlags.Default;
     this.parentScope     = null;
     this.associatedField = null;
 }
        private static BindingFlags ToBindingFlags(this MemberFlags flags, bool flatten)
        {
            BindingFlags result = default(BindingFlags);

            if (flags.HasMemberFlag(MemberFlags.Instance))
            {
                result |= BindingFlags.Instance;
            }
            if (flags.HasMemberFlag(MemberFlags.Static))
            {
                result |= BindingFlags.Static;
            }
            if (flags.HasMemberFlag(MemberFlags.NonPublic))
            {
                result |= BindingFlags.NonPublic;
            }
            if (flags.HasMemberFlag(MemberFlags.Public))
            {
                result |= BindingFlags.Public;
            }
            if (flatten)
            {
                result |= BindingFlags.FlattenHierarchy;
            }
            return(result);
        }
Beispiel #3
0
        internal static ImmutableArray <MemberDescriptor> InitializeFromStream(Stream stream, string[] nameTable)
        {
            int count = nameTable.Length;

            var builder          = ImmutableArray.CreateBuilder <MemberDescriptor>(count);
            var signatureBuilder = ImmutableArray.CreateBuilder <byte>();

            for (int i = 0; i < count; i++)
            {
                MemberFlags flags           = (MemberFlags)stream.ReadByte();
                short       declaringTypeId = ReadTypeId(stream);
                ushort      arity           = (ushort)stream.ReadByte();

                if ((flags & MemberFlags.Field) != 0)
                {
                    ParseType(signatureBuilder, stream);
                }
                else
                {
                    // Property, PropertyGet, Method or Constructor
                    ParseMethodOrPropertySignature(signatureBuilder, stream);
                }

                builder.Add(new MemberDescriptor(flags, declaringTypeId, nameTable[i], signatureBuilder.ToImmutable(), arity));
                signatureBuilder.Clear();
            }

            return(builder.ToImmutable());
        }
Beispiel #4
0
 public TypeNameMember(MemberFlags flags, string name, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.flags       = flags;
     this.name        = name;
     this.parentScope = parentScope;
 }
Beispiel #5
0
 public TypeNameMember(MemberFlags flags, string name, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.flags = flags;
     this.name = name;
     this.parentScope = parentScope;
 }
Beispiel #6
0
 public PropertyVariable(ChelaModule module)
     : base(module)
 {
     this.flags       = MemberFlags.Default;
     this.indices     = null;
     this.parentScope = null;
 }
        public override AstNode Visit(FieldDefinition node)
        {
            // Add the parent static flag.
            if (currentContainer.IsStatic())
            {
                MemberFlags oldInstance = node.GetFlags() & MemberFlags.InstanceMask;
                if (oldInstance == MemberFlags.Static || oldInstance == MemberFlags.Instanced)
                {
                    MemberFlags flags = node.GetFlags() & ~MemberFlags.InstanceMask;
                    node.SetFlags(flags | MemberFlags.Static);
                }
                else
                {
                    Error(node, "static class member cannot {0}.", oldInstance.ToString().ToLower());
                }
            }

            // Add the parent unsafe flag.
            if (IsUnsafe)
            {
                MemberFlags flags = node.GetFlags() & ~MemberFlags.SecurityMask;
                node.SetFlags(flags | MemberFlags.Unsafe);
            }

            return(node);
        }
Beispiel #8
0
 internal GenericTypeParameterData(string name, Accessibility accessibility, MemberFlags memberFlags, TypeKind typeKind, AssemblyData assembly, System.Reflection.GenericParameterAttributes genericParameterAttributes, int genericParameterPosition)
     : base(name, accessibility, memberFlags, typeKind)
 {
     AssemblyData = assembly;
     GenericParameterAttributes = genericParameterAttributes;
     GenericParameterPosition   = genericParameterPosition;
 }
Beispiel #9
0
 public MakeFunctionPointer(Expression returnType, AstNode arguments, MemberFlags flags, TokenPosition position)
     : base(position)
 {
     this.returnType = returnType;
     this.arguments = arguments;
     this.flags = flags;
 }
Beispiel #10
0
 public MakeFunctionPointer(Expression returnType, AstNode arguments, MemberFlags flags, TokenPosition position)
     : base(position)
 {
     this.returnType = returnType;
     this.arguments  = arguments;
     this.flags      = flags;
 }
Beispiel #11
0
 public ClassDefinition(MemberFlags flags, string name,
                        GenericSignature genericSignature,
                        AstNode bases, AstNode children, TokenPosition position)
     : base(flags, name, genericSignature,
            bases, children, position)
 {
 }
Beispiel #12
0
 public Function(string name, MemberFlags flags, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.name = name;
     this.flags = flags;
     this.parentScope = parentScope;
 }
Beispiel #13
0
 public ClassDefinition(MemberFlags flags, string name,
                        GenericSignature genericSignature,
                        AstNode bases, AstNode children, TokenPosition position)
     : base(flags, name, genericSignature,
            bases, children, position)
 {
 }
Beispiel #14
0
 protected EventVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.parentScope = null;
     this.associatedField = null;
 }
        public static MethodInfo GetMethodEx([NotNull] this Type type, string name, MemberFlags flags = MemberFlags.Public | MemberFlags.Static | MemberFlags.Instance)
        {
            Should.NotBeNull(type, nameof(type));
            var bindingFlags = flags.ToBindingFlags(false);
            var method       = type.GetMethod(name, bindingFlags | BindingFlags.FlattenHierarchy);

            if (method != null || !flags.HasMemberFlag(MemberFlags.NonPublic))
            {
                return(method);
            }
            bindingFlags |= BindingFlags.DeclaredOnly;
            type          = type.BaseType;
            while (type != null)
            {
                var result = type.GetMethod(name, bindingFlags);
                if (result != null)
                {
                    if (method != null)
                    {
                        throw new AmbiguousMatchException();
                    }
                    method = result;
                }
                type = type == typeof(object) ? null : type.BaseType;
            }
            return(method);
        }
Beispiel #16
0
        public override void Dump()
        {
            // Get the linkage flags.
            MemberFlags linkage  = GetFlags() & MemberFlags.LinkageMask;
            bool        external = linkage == MemberFlags.External;

            if (GetAttributeCount() != 0)
            {
                Dumper.Printf("[%d]", (int)GetAttributeCount());
            }
            Dumper.Printf("%s function %s %s%s", GetFlagsString(), name,
                          type != null ? type.GetFullName() : "void ()",
                          external ? ";" : "");

            // There isn't content in external functions.
            if (external)
            {
                return;
            }

            Dumper.Printf("{");

            DumpContent();

            Dumper.Printf("}");
        }
Beispiel #17
0
 public PropertyVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.indices = null;
     this.parentScope = null;
 }
Beispiel #18
0
 public Function(string name, MemberFlags flags, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.name        = name;
     this.flags       = flags;
     this.parentScope = parentScope;
 }
Beispiel #19
0
 internal MemberDataBase(ISymbol symbol, MemberFlags memberFlags, DeclaringTypeData declaringType)
 {
     Accessibility  = symbol.DeclaredAccessibility;
     ContainingType = declaringType;
     MemberFlags    = memberFlags;
     Name           = symbol.MetadataName;
 }
        internal static MethodData FindMethod(this ArgumentData target, string methodName, Type[] typeArgs,
                                              IList <ArgumentData> args, IEnumerable <Type> knownTypes, bool staticAccess)
        {
            var type = target.Type;
            const MemberFlags flags = MemberFlags.Public | MemberFlags.Static | MemberFlags.Instance;
            var methods             = new List <MethodInfo>();

            foreach (var info in type.GetMethodsEx(flags))
            {
                if (info.Name == methodName && info.IsStatic == staticAccess)
                {
                    methods.Add(info);
                }
            }
            if (!staticAccess)
            {
                methods.AddRange(GetExtensionsMethods(methodName, knownTypes));
            }
            var method = FindBestMethod(target, methods, args, typeArgs);

            if (method == null)
            {
                throw BindingExceptionManager.InvalidBindingMember(type, methodName);
            }
            return(method);
        }
Beispiel #21
0
        public FieldDefinition(MemberFlags flags, Expression typeNode,
		                        FieldDeclaration declarations, TokenPosition position)
            : base(position)
        {
            this.flags = flags;
            this.typeNode = typeNode;
            this.declarations = declarations;
        }
Beispiel #22
0
 public EventVariable(string name, MemberFlags flags, IChelaType type, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags = flags;
     this.parentScope = parentScope;
     this.associatedField = null;
 }
Beispiel #23
0
 public Method(string name, MemberFlags flags, Scope parentScope)
     : base(name, flags, parentScope)
 {
     this.vslot = -1;
     this.ctorLeaf = false;
     this.ctorParent = null;
     this.explicitContract = null;
 }
Beispiel #24
0
 public EnumDefinition(MemberFlags flags, string name, AstNode children,
                       Expression typeExpr, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags    = flags;
     this.typeExpr = typeExpr;
 }
Beispiel #25
0
 public FieldDefinition(MemberFlags flags, Expression typeNode,
                        FieldDeclaration declarations, TokenPosition position)
     : base(position)
 {
     this.flags        = flags;
     this.typeNode     = typeNode;
     this.declarations = declarations;
 }
Beispiel #26
0
 public Method(string name, MemberFlags flags, Scope parentScope)
     : base(name, flags, parentScope)
 {
     this.vslot            = -1;
     this.ctorLeaf         = false;
     this.ctorParent       = null;
     this.explicitContract = null;
 }
Beispiel #27
0
 public PropertyVariable(string name, MemberFlags flags, IChelaType type, IChelaType[] indices, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags       = flags;
     this.indices     = indices;
     this.parentScope = parentScope;
 }
Beispiel #28
0
 private static bool FilterProperty(PropertyInfo property, MemberFlags flags)
 {
     if (property == null)
     {
         return(false);
     }
     return(FilterMethod(property.CanRead ? property.GetMethod : property.SetMethod, flags));
 }
Beispiel #29
0
 public PropertyVariable(string name, MemberFlags flags, IChelaType type, IChelaType[] indices, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags = flags;
     this.indices = indices;
     this.parentScope = parentScope;
 }
Beispiel #30
0
 public EventVariable(string name, MemberFlags flags, IChelaType type, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags           = flags;
     this.parentScope     = parentScope;
     this.associatedField = null;
 }
Beispiel #31
0
 public EnumDefinition(MemberFlags flags, string name, AstNode children,
     Expression typeExpr, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags = flags;
     this.typeExpr = typeExpr;
 }
Beispiel #32
0
 internal TypeDefinitionData(string name, MemberAccessibility accessibility, MemberFlags memberFlags, TypeKind typeKind, AssemblyData assembly, string fullName, TypeDefinitionFlags typeDefinitionFlags, bool delegateReturnTypeIsDynamic)
     : base(name, accessibility, memberFlags, typeKind)
 {
     _assembly = assembly;
     this.DelegateReturnTypeIsDynamic = delegateReturnTypeIsDynamic;
     this.FullName            = fullName;
     this.TypeDefinitionFlags = typeDefinitionFlags;
 }
Beispiel #33
0
 public FunctionPrototype(MemberFlags flags, Expression returnType,
                          FunctionArgument arguments, Expression nameExpression,
                          GenericSignature genericSignature,
                          TokenPosition position)
     : this(flags, returnType, arguments, "", genericSignature, position)
 {
     this.nameExpression = nameExpression;
 }
Beispiel #34
0
 public FunctionPrototype(MemberFlags flags, Expression returnType,
                        FunctionArgument arguments, Expression nameExpression,
                           GenericSignature genericSignature,
                           TokenPosition position)
     : this(flags, returnType, arguments, "", genericSignature, position)
 {
     this.nameExpression = nameExpression;
 }
        /// <summary>
        ///     Adds a series of instances of <see cref="IValidationElement" /> to the specified dictionary.
        /// </summary>
        protected virtual void FillValidationAttributes(Type type,
                                                        IDictionary <string, IList <IValidationElement> > elements)
        {
            const MemberFlags flags = MemberFlags.Public | MemberFlags.Instance;
            Dictionary <MemberInfo, HashSet <MemberInfo> > originalMembers = type
                                                                             .GetPropertiesEx(flags)
                                                                             .Where(info => info.CanRead && info.GetGetMethod(true).GetParameters().Length == 0)
                                                                             .ToDictionary(info => (MemberInfo)info, info => new HashSet <MemberInfo> {
                info
            });

            foreach (var field in type.GetFieldsEx(flags))
            {
                originalMembers.Add(field, new HashSet <MemberInfo> {
                    field
                });
            }
            ICollection <Type> metadataTypes = GetMetadataTypes(type);

            foreach (Type metadataType in metadataTypes)
            {
                foreach (PropertyInfo metadataProperty in metadataType.GetPropertiesEx(flags))
                {
                    KeyValuePair <MemberInfo, HashSet <MemberInfo> > valuePair = originalMembers
                                                                                 .FirstOrDefault(pair => pair.Key is PropertyInfo && pair.Key.Name == metadataProperty.Name);
                    if (valuePair.Value == null)
                    {
                        throw ExceptionManager.MissingMetadataProperty(type, metadataProperty.Name, metadataProperty.DeclaringType);
                    }
                    valuePair.Value.Add(metadataProperty);
                }

                foreach (FieldInfo metadataField in metadataType.GetFieldsEx(flags))
                {
                    KeyValuePair <MemberInfo, HashSet <MemberInfo> > valuePair = originalMembers
                                                                                 .FirstOrDefault(pair => pair.Key is FieldInfo && pair.Key.Name == metadataField.Name);
                    if (valuePair.Value == null)
                    {
                        throw ExceptionManager.MissingMetadataField(type, metadataField.Name, metadataField.DeclaringType);
                    }
                    valuePair.Value.Add(metadataField);
                }
            }

            foreach (var keyValuePair in originalMembers)
            {
                IList <IValidationElement> list;
                if (!elements.TryGetValue(keyValuePair.Key.Name, out list))
                {
                    list = new List <IValidationElement>();
                    elements[keyValuePair.Key.Name] = list;
                }
                foreach (MemberInfo member in keyValuePair.Value)
                {
                    list.AddRange(GetValidationAttributes(keyValuePair.Key, member));
                }
            }
        }
Beispiel #36
0
 public FieldVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.slot = -1;
     this.initializer = null;
     this.parentScope = null;
     this.position = null;
 }
Beispiel #37
0
 public MemberInfo(InfoBinderInterface binder, string namespaceURI, string localName, int containingTypeIndex, int dataTypeIndex, MemberFlags flags)
 {
     this.namespaceURI        = namespaceURI;
     this.localName           = localName;
     this.binder              = binder;
     this.containingTypeIndex = containingTypeIndex;
     this.dataTypeIndex       = dataTypeIndex;
     this.flags = flags;
 }
Beispiel #38
0
 public TypedefDefinition(MemberFlags flags, Expression typeExpression,
                          string name, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags          = flags;
     this.typeExpression = typeExpression;
     this.expansionScope = null;
 }
Beispiel #39
0
 public TypedefDefinition(MemberFlags flags, Expression typeExpression,
                           string name, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags = flags;
     this.typeExpression = typeExpression;
     this.expansionScope = null;
 }
Beispiel #40
0
        public override AstNode Visit(UsingStatement node)
        {
            // Visit the using member.
            Expression member = node.GetMember();

            member.Accept(this);

            // Cast the pseudo-scope.
            PseudoScope scope = (PseudoScope)node.GetScope();

            // Get the member type.
            IChelaType memberType = member.GetNodeType();

            if (memberType.IsMetaType())
            {
                // Get the actual type.
                MetaType meta = (MetaType)memberType;
                memberType = meta.GetActualType();

                // Only structure relatives.
                if (memberType.IsStructure() || memberType.IsClass() || memberType.IsInterface())
                {
                    scope.AddAlias(memberType.GetName(), (ScopeMember)memberType);
                }
                else
                {
                    Error(node, "unexpected type.");
                }
            }
            else if (memberType.IsReference())
            {
                // Only static members supported.
                ScopeMember theMember     = (ScopeMember)member.GetNodeValue();
                MemberFlags instanceFlags = MemberFlags.InstanceMask & theMember.GetFlags();
                if (instanceFlags != MemberFlags.Static)
                {
                    Error(node, "unexpected member type.");
                }

                // Store the member.
                scope.AddAlias(theMember.GetName(), theMember);
            }
            else if (memberType.IsNamespace())
            {
                // Set the namespace chain.
                Namespace space = (Namespace)member.GetNodeValue();
                scope.SetChainNamespace(space);
            }
            else
            {
                Error(node, "unsupported object to use.");
            }

            base.Visit(node);

            return(node);
        }
Beispiel #41
0
 public PropertyAccessor(MemberFlags flags, AstNode children, TokenPosition position)
     : base(null, children, position)
 {
     this.flags            = flags;
     this.property         = null;
     this.selfLocal        = null;
     this.indices          = null;
     this.indexerVariables = null;
 }
Beispiel #42
0
 public FieldVariable(ChelaModule module)
     : base(module)
 {
     this.flags       = MemberFlags.Default;
     this.slot        = -1;
     this.initializer = null;
     this.parentScope = null;
     this.position    = null;
 }
Beispiel #43
0
 public PropertyAccessor(MemberFlags flags, AstNode children, TokenPosition position)
     : base(null, children, position)
 {
     this.flags = flags;
     this.property = null;
     this.selfLocal = null;
     this.indices = null;
     this.indexerVariables = null;
 }
Beispiel #44
0
 public FieldVariable(string name, MemberFlags flags, IChelaType type, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags = flags;
     this.parentScope = parentScope;
     this.slot = -1;
     this.initializer = null;
     this.position = null;
 }
Beispiel #45
0
 protected FunctionType(IChelaType returnType, IChelaType[] arguments, bool variableArguments, MemberFlags flags)
 {
     this.returnType        = returnType;
     this.arguments         = arguments;
     this.variableArguments = variableArguments;
     this.flags             = flags;
     this.name        = null;
     this.displayName = null;
     this.fullName    = null;
 }
 public EventAccessorDefinition(MemberFlags flags, string name, AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags = flags;
     this.eventVariable = null;
     this.function = null;
     this.selfLocal = null;
     this.valueLocal = null;
 }
Beispiel #47
0
 public TypeNameMember(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.parentScope = null;
     this.typedefNode = null;
     this.actualType = null;
     this.isExpanding = false;
     this.flags = MemberFlags.Default;
 }
Beispiel #48
0
 public EventAccessorDefinition(MemberFlags flags, string name, AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags         = flags;
     this.eventVariable = null;
     this.function      = null;
     this.selfLocal     = null;
     this.valueLocal    = null;
 }
Beispiel #49
0
 public PropertyDefinition(MemberFlags flags, Expression propertyType,
                           string name, AstNode indices, AstNode accessors, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags = flags;
     this.propertyType = propertyType;
     this.property = null;
     this.indices = indices;
     this.accessors = accessors;
 }
Beispiel #50
0
 public EventDefinition(MemberFlags flags, Expression eventType,
                         string name, AstNode accessors, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags = flags;
     this.eventType = eventType;
     this.eventVariable = null;
     this.accessors = accessors;
     this.delegateType = null;
 }
Beispiel #51
0
 public DelegateDefinition(MemberFlags flags, Expression returnType,
                            AstNode arguments, string name,
                            GenericSignature genericSignature,
                            TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.genericSignature = genericSignature;
     this.flags = flags;
     this.returnType = returnType;
     this.arguments = arguments;
 }
Beispiel #52
0
 public MemberDescriptor(
     MemberFlags Flags,
     byte DeclaringTypeId,
     string Name,
     ImmutableArray<byte> Signature,
     ushort Arity = 0)
 {
     this.Flags = Flags;
     this.DeclaringTypeId = DeclaringTypeId;
     this.Name = Name;
     this.Arity = Arity;
     this.Signature = Signature;
 }
Beispiel #53
0
        public StructDefinition(MemberFlags flags, string name,
                                GenericSignature genericSignature,
		                        AstNode bases, AstNode children,
                                TokenPosition position)
            : base(children, position)
        {
            SetName(name);
            this.flags = flags;
            this.bases = bases;
            this.genericSignature = genericSignature;
            this.defaultConstructor = null;
            this.genericScope = null;
        }
Beispiel #54
0
 public FunctionPrototype(MemberFlags flags, Expression returnType,
                           FunctionArgument arguments, string name,
                           GenericSignature genericSignature,
                           TokenPosition position)
     : base(null, position)
 {
     SetName (name);
     this.flags = flags;
     this.returnType = returnType;
     this.arguments = arguments;
     this.function = null;
     this.ctorInitializer = null;
     this.destructorName = null;
     this.genericSignature = genericSignature;
 }
Beispiel #55
0
 protected Function(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.flags = MemberFlags.Default;
     this.parentScope = null;
     this.basicBlocks = new List<BasicBlock> ();
     this.lexicalScopes = new List<LexicalScope>();
     this.locals = new List<LocalVariable> ();
     this.position = null;
     this.exceptionContext = null;
     this.returnBlock = null;
     this.returningVar = null;
     this.returnValueVar = null;
     this.genericPrototype = GenericPrototype.Empty;
     this.arguments  = null;
 }
		protected MemberWrapper(TypeWrapper declaringType, string name, string sig, Modifiers modifiers, MemberFlags flags)
		{
			Debug.Assert(declaringType != null);
			this.declaringType = declaringType;
			this.name = String.Intern(name);
			this.sig = String.Intern(sig);
			this.modifiers = modifiers;
			this.flags = flags;
		}
		internal MethodWrapper(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
			: base(declaringType, name, sig, modifiers, flags)
		{
			Profiler.Count("MethodWrapper");
			this.method = method;
			Debug.Assert(((returnType == null) == (parameterTypes == null)) || (returnType == PrimitiveTypeWrapper.VOID));
			this.returnTypeWrapper = returnType;
			this.parameterTypeWrappers = parameterTypes;
			if (Intrinsics.IsIntrinsic(this))
			{
				SetIntrinsicFlag();
			}
			UpdateNonPublicTypeInSignatureFlag();
		}
		internal static MethodWrapper Create(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
		{
			Debug.Assert(declaringType != null && name!= null && sig != null && method != null);

			if(declaringType.IsGhost)
			{
				// HACK since our caller isn't aware of the ghost issues, we'll handle the method swapping
				if(method.DeclaringType.IsValueType)
				{
					Type[] types = new Type[parameterTypes.Length];
					for(int i = 0; i < types.Length; i++)
					{
						types[i] = parameterTypes[i].TypeAsSignatureType;
					}
					method = declaringType.TypeAsBaseType.GetMethod(method.Name, types);
				}
				return new GhostMethodWrapper(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags);
			}
			else if(method is ConstructorInfo)
			{
				return new SmartConstructorMethodWrapper(declaringType, name, sig, (ConstructorInfo)method, parameterTypes, modifiers, flags);
			}
			else
			{
				return new SmartCallMethodWrapper(declaringType, name, sig, (MethodInfo)method, returnType, parameterTypes, modifiers, flags, SimpleOpCode.Call, method.IsStatic ? SimpleOpCode.Call : SimpleOpCode.Callvirt);
			}
		}
			internal GhostMethodWrapper(TypeWrapper declaringType, string name, string sig, MethodBase method, TypeWrapper returnType, TypeWrapper[] parameterTypes, Modifiers modifiers, MemberFlags flags)
				: base(declaringType, name, sig, method, returnType, parameterTypes, modifiers, flags)
			{
				// make sure we weren't handed the ghostMethod in the wrapper value type
				Debug.Assert(method == null || method.DeclaringType.IsInterface);
			}
		protected void SetType2FinalField()
		{
			flags |= MemberFlags.Type2FinalField;
		}