Mono.Debugger.Backend.Mono.MonoLanguageBackend.LookupMonoType C# (CSharp) Method

LookupMonoType() public method

public LookupMonoType ( Cecil type ) : TargetType
type Cecil
return Mono.Debugger.Languages.TargetType
        public TargetType LookupMonoType(Cecil.TypeReference type)
        {
            MonoSymbolFile file;

            Cecil.TypeDefinition typedef = type as Cecil.TypeDefinition;
            if (typedef != null) {
                file = (MonoSymbolFile) assembly_hash [type.Module.Assembly];
                if (file == null) {
                    Console.WriteLine ("Type `{0}' from unknown assembly `{1}'",
                               type, type.Module.Assembly);
                    return null;
                }

                return file.LookupMonoType (typedef);
            }

            Cecil.ArrayType array = type as Cecil.ArrayType;
            if (array != null) {
                TargetType element_type = LookupMonoType (array.ElementType);
                if (element_type == null)
                    return null;

                return new MonoArrayType (element_type, array.Rank);
            }

            Cecil.ReferenceType reftype = type as Cecil.ReferenceType;
            if (reftype != null) {
                TargetType element_type = LookupMonoType (reftype.ElementType);
                if (element_type == null)
                    return null;

                return new MonoPointerType (element_type);
            }

            Cecil.GenericParameter gen_param = type as Cecil.GenericParameter;
            if (gen_param != null)
                return new MonoGenericParameterType (this, gen_param.Name);

            Cecil.GenericInstanceType gen_inst = type as Cecil.GenericInstanceType;
            if (gen_inst != null) {
                TargetType[] args = new TargetType [gen_inst.GenericArguments.Count];
                for (int i = 0; i < args.Length; i++) {
                    args [i] = LookupMonoType (gen_inst.GenericArguments [i]);
                    if (args [i] == null)
                        return null;
                }

                MonoClassType container = LookupMonoType (gen_inst.ElementType)
                    as MonoClassType;
                if (container == null)
                    return null;

                return new MonoGenericInstanceType (container, args, TargetAddress.Null);
            }

            int rank = 0;

            string full_name = type.FullName;
            int pos = full_name.IndexOf ('[');
            if (pos > 0) {
                string dim = full_name.Substring (pos);
                full_name = full_name.Substring (0, pos);

                if ((dim.Length < 2) || (dim [dim.Length - 1] != ']'))
                    throw new ArgumentException ();
                for (int i = 1; i < dim.Length - 1; i++)
                    if (dim [i] != ',')
                        throw new ArgumentException ();

                rank = dim.Length - 1;
            }

            TargetType mono_type = LookupType (full_name);
            if (mono_type == null)
                return null;

            if (rank > 0)
                return new MonoArrayType (mono_type, rank);
            else
                return mono_type;
        }