Inheritance: TargetClassType, IMonoStructType
 public MonoClassObject(MonoClassType type, MonoClassInfo info,
                        TargetLocation location)
     : base(type, location)
 {
     this.type = type;
     this.info = info;
 }
Example #2
0
        public MonoGenericInstanceType(MonoClassType container, TargetType[] type_args,
                                       TargetAddress class_ptr)
            : base(container.File.MonoLanguage)
        {
            this.Container = container;
            this.type_args = type_args;
            this.class_ptr = class_ptr;

            struct_type = new MonoStructType(container.File, this, container.Type);

            StringBuilder sb = new StringBuilder(container.BaseName);

            sb.Append('<');
            for (int i = 0; i < type_args.Length; i++)
            {
                if (i > 0)
                {
                    sb.Append(',');
                }
                sb.Append(type_args [i].Name);
            }
            sb.Append('>');
            full_name = sb.ToString();

            bool is_compiler_generated;
            DebuggerBrowsableState?browsable_state;

            MonoSymbolFile.CheckCustomAttributes(container.Type,
                                                 out browsable_state,
                                                 out debugger_display,
                                                 out type_proxy,
                                                 out is_compiler_generated);
        }
        public MonoGenericInstanceType(MonoClassType container, TargetType[] type_args,
						TargetAddress class_ptr)
            : base(container.File.MonoLanguage)
        {
            this.Container = container;
            this.type_args = type_args;
            this.class_ptr = class_ptr;

            struct_type = new MonoStructType (container.File, this, container.Type);

            StringBuilder sb = new StringBuilder (container.BaseName);
            sb.Append ('<');
            for (int i = 0; i < type_args.Length; i++) {
                if (i > 0)
                    sb.Append (',');
                sb.Append (type_args [i].Name);
            }
            sb.Append ('>');
            full_name = sb.ToString ();

            bool is_compiler_generated;
            DebuggerBrowsableState? browsable_state;
            MonoSymbolFile.CheckCustomAttributes (container.Type,
                                  out browsable_state,
                                  out debugger_display,
                                  out type_proxy,
                                  out is_compiler_generated);
        }
Example #4
0
        public MonoClassObject(MonoClassType type, MonoClassInfo info,
					TargetLocation location)
            : base(type, location)
        {
            this.type = type;
            this.info = info;
        }
Example #5
0
        public MonoEnumType(MonoSymbolFile file, Cecil.TypeDefinition type)
            : base(file.MonoLanguage)
        {
            this.type = type;
            this.file = file;

            class_type = new MonoClassType(file, type);
        }
Example #6
0
        public MonoEnumType(MonoSymbolFile file, Cecil.TypeDefinition type)
            : base(file.MonoLanguage)
        {
            this.type = type;
            this.file = file;

            class_type = new MonoClassType (file, type);
        }
Example #7
0
        public static MonoClassInfo ReadCoreType(MonoSymbolFile file,
                                                 Cecil.TypeDefinition typedef,
                                                 TargetMemoryAccess target,
                                                 TargetAddress klass,
                                                 out MonoClassType type)
        {
            MonoClassInfo info = new MonoClassInfo(file, typedef, target, klass);

            type = new MonoClassType(file, typedef, info);
            ((IMonoStructType)type).ClassInfo = info;
            info.struct_type = type;
            info.type        = type;
            return(info);
        }
        public MonoBuiltinTypeInfo(MonoSymbolFile corlib, TargetMemoryAccess memory)
        {
            this.Corlib = corlib;

            MonoLanguageBackend mono = corlib.MonoLanguage;

            ObjectType = MonoObjectType.Create (corlib, memory);
            VoidType = MonoVoidType.Create (corlib, memory);

            StringType = MonoStringType.Create (corlib, memory);

            BooleanType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Boolean);
            CharType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Char);
            ByteType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Byte);
            SByteType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.SByte);
            Int16Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Int16);
            UInt16Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.UInt16);
            Int32Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Int32);
            UInt32Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.UInt32);
            Int64Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Int64);
            UInt64Type = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.UInt64);
            SingleType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Single);
            DoubleType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Double);

            IntType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.IntPtr);
            UIntType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.UIntPtr);

            DecimalType = MonoFundamentalType.Create (
                corlib, memory, FundamentalKind.Decimal);
            Cecil.TypeDefinition decimal_type = corlib.ModuleDefinition.GetType ("System.Decimal");
            corlib.AddType (decimal_type, DecimalType);

            TargetAddress klass = corlib.MonoLanguage.MetadataHelper.GetArrayClass (memory);
            Cecil.TypeDefinition array_type = corlib.ModuleDefinition.GetType ("System.Array");
            ArrayType = mono.CreateCoreType (corlib, array_type, memory, klass);
            mono.AddCoreType (array_type, ArrayType, ArrayType, klass);

            klass = corlib.MonoLanguage.MetadataHelper.GetDelegateClass (memory);
            Cecil.TypeDefinition delegate_type = corlib.ModuleDefinition.GetType ("System.Delegate");
            DelegateType = new MonoClassType (corlib, delegate_type);
            mono.AddCoreType (delegate_type, DelegateType, DelegateType, klass);

            klass = corlib.MonoLanguage.MetadataHelper.GetExceptionClass (memory);
            Cecil.TypeDefinition exception_type = corlib.ModuleDefinition.GetType ("System.Exception");
            ExceptionType = mono.CreateCoreType (corlib, exception_type, memory, klass);
            mono.AddCoreType (exception_type, ExceptionType, ExceptionType, klass);
        }
Example #9
0
        public static MonoClassInfo ReadClassInfo(MonoLanguageBackend mono,
                                                  TargetMemoryAccess target,
                                                  TargetAddress klass)
        {
            TargetAddress  image = mono.MetadataHelper.MonoClassGetMonoImage(target, klass);
            MonoSymbolFile file  = mono.GetImage(image);

            if (file == null)
            {
                throw new InternalError();
            }

            int token = mono.MetadataHelper.MonoClassGetToken(target, klass);

            if ((token & 0xff000000) != 0x02000000)
            {
                throw new InternalError();
            }

            Cecil.TypeDefinition typedef;
            typedef = (Cecil.TypeDefinition)file.ModuleDefinition.LookupToken(
                new Cecil.MetadataToken(Cecil.TokenType.TypeDef, token & 0x00ffffff));
            if (typedef == null)
            {
                throw new InternalError();
            }

            MonoClassInfo info = new MonoClassInfo(file, typedef, target, klass);

            if ((file == mono.BuiltinTypes.Corlib) &&
                (typedef.FullName == "System.Decimal"))
            {
                MonoFundamentalType ftype = mono.BuiltinTypes.DecimalType;

                if (ftype.ClassType == null)
                {
                    MonoClassType ctype = new MonoClassType(file, typedef, info);
                    ((IMonoStructType)ctype).ClassInfo = info;
                    ftype.SetClass(ctype);
                }

                info.struct_type = (IMonoStructType)ftype.ClassType;
                info.type        = ftype;
            }
            else if (info.IsGenericClass)
            {
                info.struct_type = (IMonoStructType)
                                   file.MonoLanguage.ReadGenericClass(
                    target, info.GenericClass, false);
                info.type = info.struct_type.Type;
            }
            else
            {
                info.type = file.LookupMonoType(typedef);
                if (info.type is TargetClassType)
                {
                    info.struct_type = (IMonoStructType)info.type;
                }
                else
                {
                    info.struct_type = (IMonoStructType)info.type.ClassType;
                }
            }
            info.struct_type.ClassInfo = info;
            return(info);
        }
Example #10
0
            public MonoMethodSource(MonoSymbolFile file, SourceFile source_file,
						 C.MethodEntry method, Cecil.MethodDefinition mdef,
						 MonoClassType klass, MonoFunctionType function)
            {
                this.file = file;
                this.source_file = source_file;
                this.method = method;
                this.mdef = mdef;
                this.function = function;
                this.klass = klass;

                full_name = method.GetRealName ();
                if (full_name == null)
                    full_name = MonoSymbolFile.GetMethodName (mdef);

                C.LineNumberEntry start, end;
                C.LineNumberTable lnt = method.GetLineNumberTable ();
                if (lnt.GetMethodBounds (out start, out end))
                    start_row = start.Row; end_row = end.Row;
            }
 internal void SetClass(MonoClassType info)
 {
     this.class_type = info;
 }
Example #12
0
        public static MonoClassInfo ReadClassInfo(MonoLanguageBackend mono,
							   TargetMemoryAccess target,
							   TargetAddress klass)
        {
            TargetAddress image = mono.MetadataHelper.MonoClassGetMonoImage (target, klass);
            MonoSymbolFile file = mono.GetImage (image);
            if (file == null)
                throw new InternalError ();

            int token = mono.MetadataHelper.MonoClassGetToken (target, klass);
            if ((token & 0xff000000) != 0x02000000)
                throw new InternalError ();

            Cecil.TypeDefinition typedef;
            typedef = (Cecil.TypeDefinition) file.ModuleDefinition.LookupByToken (
                Cecil.Metadata.TokenType.TypeDef, token & 0x00ffffff);
            if (typedef == null)
                throw new InternalError ();

            MonoClassInfo info = new MonoClassInfo (file, typedef, target, klass);
            if ((file == mono.BuiltinTypes.Corlib) &&
                (typedef.FullName == "System.Decimal")) {
                MonoFundamentalType ftype = mono.BuiltinTypes.DecimalType;

                if (ftype.ClassType == null) {
                    MonoClassType ctype = new MonoClassType (file, typedef, info);
                    ((IMonoStructType) ctype).ClassInfo = info;
                    ftype.SetClass (ctype);
                }

                info.struct_type = (IMonoStructType) ftype.ClassType;
                info.type = ftype;
            } else if (info.IsGenericClass) {
                info.struct_type = (IMonoStructType)
                    file.MonoLanguage.ReadGenericClass (
                        target, info.GenericClass, false);
                info.type = info.struct_type.Type;
            } else {
                info.type = file.LookupMonoType (typedef);
                if (info.type is TargetClassType)
                    info.struct_type = (IMonoStructType) info.type;
                else
                    info.struct_type = (IMonoStructType) info.type.ClassType;
            }
            info.struct_type.ClassInfo = info;
            return info;
        }
Example #13
0
        public static MonoClassInfo ReadCoreType(MonoSymbolFile file,
							  Cecil.TypeDefinition typedef,
							  TargetMemoryAccess target,
							  TargetAddress klass,
							  out MonoClassType type)
        {
            MonoClassInfo info = new MonoClassInfo (file, typedef, target, klass);
            type = new MonoClassType (file, typedef, info);
            ((IMonoStructType) type).ClassInfo = info;
            info.struct_type = type;
            info.type = type;
            return info;
        }
Example #14
0
        public TargetType LookupMonoType(Cecil.TypeReference type)
        {
            TargetType result = (TargetType) type_hash [type];
            if (result != null)
                return result;

            if (type is Cecil.ArrayType) {
                Cecil.ArrayType atype = (Cecil.ArrayType) type;
                TargetType element_type = LookupMonoType (atype.ElementType);
                result = new MonoArrayType (element_type, atype.Rank);
            } else if (type is Cecil.TypeDefinition) {
                Cecil.TypeDefinition tdef = (Cecil.TypeDefinition) type;
                if (tdef.IsEnum)
                    result = new MonoEnumType (this, tdef);
                else
                    result = new MonoClassType (this, tdef);
            } else {
                Console.WriteLine ("UNKNOWN TYPE: {0} {1}", type, type.GetType ());
                return null;
            }

            if (!type_hash.Contains (type))
                type_hash.Add (type, result);
            return result;
        }
 internal void SetClass(MonoClassType info)
 {
     this.class_type = info;
 }
 protected void create_type(TargetMemoryAccess memory, TargetAddress klass)
 {
     class_type = file.MonoLanguage.CreateCoreType (file, typedef, memory, klass);
     file.MonoLanguage.AddCoreType (typedef, this, class_type, klass);
 }
 protected void create_type(TargetMemoryAccess memory, TargetAddress klass)
 {
     class_type = file.MonoLanguage.CreateCoreType(file, typedef, memory, klass);
     file.MonoLanguage.AddCoreType(typedef, this, class_type, klass);
 }