public static BasicType ExtractType(Cci.INamedTypeReference typeref)
        {
            var name = TypesExtractor.GetTypeName(typeref);
            var type = new BasicType(name);

            return(type);
        }
        public static TypeVariable ExtractType(Cci.IGenericParameterReference typeref)
        {
            var name = TypesExtractor.GetTypeName(typeref);
            var type = new TypeVariable(name);

            return(type);
        }
        public static ArrayType ExtractType(Cci.IArrayTypeReference typeref)
        {
            var elements = TypesExtractor.ExtractType(typeref.ElementType);
            var type     = new ArrayType(elements);

            return(type);
        }
        public static PointerType ExtractType(Cci.IPointerTypeReference typeref)
        {
            var target = TypesExtractor.ExtractType(typeref.TargetType);
            var type   = new PointerType(target);

            return(type);
        }
        public static IType ExtractType(Cci.ITypeReference typeref)
        {
            IType result = null;

            if (typeref is Cci.IArrayTypeReference)
            {
                var atyperef = typeref as Cci.IArrayTypeReference;
                result = TypesExtractor.ExtractType(atyperef);
            }
            else if (typeref is Cci.IPointerTypeReference)
            {
                var ptyperef = typeref as Cci.IPointerTypeReference;
                result = TypesExtractor.ExtractType(ptyperef);
            }
            else if (typeref is Cci.IGenericParameterReference)
            {
                var gptyperef = typeref as Cci.IGenericParameterReference;
                result = TypesExtractor.ExtractType(gptyperef);
            }
            else if (typeref is Cci.IGenericTypeInstanceReference)
            {
                var gtyperef = typeref as Cci.IGenericTypeInstanceReference;
                result = TypesExtractor.ExtractType(gtyperef);
            }
            else if (typeref is Cci.INamedTypeReference)
            {
                var ntyperef = typeref as Cci.INamedTypeReference;
                result = TypesExtractor.ExtractType(ntyperef);
            }

            return(result);
        }
 private static void ExtractGenericType(BasicType type, Cci.IGenericTypeInstanceReference typeref)
 {
     foreach (var argumentref in typeref.GenericArguments)
     {
         var typearg = TypesExtractor.ExtractType(argumentref);
         type.GenericArguments.Add(typearg);
     }
 }
        public static BasicType ExtractType(Cci.IGenericTypeInstanceReference typeref)
        {
            var type = TypesExtractor.ExtractType(typeref.GenericType);

            TypesExtractor.ExtractGenericType(type, typeref);

            return(type);
        }
            private void ExtractInterfaces(IList <BasicType> dest, IEnumerable <Cci.ITypeReference> source)
            {
                foreach (var interfaceref in source)
                {
                    var type = TypesExtractor.ExtractType(interfaceref) as BasicType;

                    dest.Add(type);
                }
            }
            private void ExtractEnum(Cci.INamedTypeDefinition typedef)
            {
                var name = typedef.Name.Value;
                var type = new EnumDefinition(name);

                type.UnderlayingType = TypesExtractor.ExtractType(typedef.UnderlyingType) as BasicType;
                this.ExtractConstants(type.Constants, typedef.Fields);

                types.Add(name, type);
            }
            private void ExtractParameters(IList <IVariable> dest, IEnumerable <Cci.IParameterDefinition> source)
            {
                foreach (var parameterdef in source)
                {
                    var name      = parameterdef.Name.Value;
                    var type      = TypesExtractor.ExtractType(parameterdef.Type);
                    var parameter = new LocalVariable(name, true);

                    dest.Add(parameter);
                }
            }
            private void ExtractFields(IDictionary <string, FieldDefinition> dest, IEnumerable <Cci.IFieldDefinition> source)
            {
                foreach (var fielddef in source)
                {
                    var name  = fielddef.Name.Value;
                    var type  = TypesExtractor.ExtractType(fielddef.Type);
                    var field = new FieldDefinition(name, type);

                    field.IsStatic = fielddef.IsStatic;
                    dest.Add(name, field);
                }
            }
            private void ExtractMethods(IDictionary <string, MethodDefinition> dest, IEnumerable <Cci.IMethodDefinition> source)
            {
                foreach (var methoddef in source)
                {
                    var name   = methoddef.Name.Value;
                    var type   = TypesExtractor.ExtractType(methoddef.Type);
                    var method = new MethodDefinition(name, type);

                    this.ExtractGenericParameters(method.GenericParameters, methoddef.GenericParameters);
                    this.ExtractParameters(method.Parameters, methoddef.Parameters);

                    method.IsStatic      = methoddef.IsStatic;
                    method.IsConstructor = methoddef.IsConstructor;
                    dest.Add(name, method);
                }
            }
            private void ExtractClass(Cci.INamedTypeDefinition typedef)
            {
                var name = typedef.Name.Value;
                var type = new ClassDefinition(name);

                Cci.ITypeReference basedef = Cci.TypeHelper.BaseClass(typedef);

                if (basedef == null)
                {
                    basedef = host.PlatformType.SystemObject;
                }

                type.Base = TypesExtractor.ExtractType(basedef) as BasicType;

                this.ExtractGenericParameters(type.GenericParameters, typedef.GenericParameters);
                this.ExtractInterfaces(type.Interfaces, typedef.Interfaces);
                this.ExtractFields(type.Fields, typedef.Fields);
                this.ExtractMethods(type.Methods, typedef.Methods);

                types.Add(name, type);
            }