Exemplo n.º 1
0
        public static BasicType ExtractType(Cci.INamedTypeReference typeref)
        {
            var name = TypesExtractor.GetTypeName(typeref);
            var type = new BasicType(name);

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

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

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

            return(type);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 private static void ExtractGenericType(BasicType type, Cci.IGenericTypeInstanceReference typeref)
 {
     foreach (var argumentref in typeref.GenericArguments)
     {
         var typearg = TypesExtractor.ExtractType(argumentref);
         type.GenericArguments.Add(typearg);
     }
 }
Exemplo n.º 7
0
        public static BasicType ExtractType(Cci.IGenericTypeInstanceReference typeref)
        {
            var type = TypesExtractor.ExtractType(typeref.GenericType);

            TypesExtractor.ExtractGenericType(type, typeref);

            return(type);
        }
Exemplo n.º 8
0
            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);
                }
            }
Exemplo n.º 9
0
            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);
            }
Exemplo n.º 10
0
            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);
                }
            }
Exemplo n.º 11
0
            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);
                }
            }
Exemplo n.º 12
0
            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);
                }
            }
Exemplo n.º 13
0
            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);
            }