public static MonoFundamentalType Create(MonoSymbolFile corlib, TargetMemoryAccess memory, FundamentalKind kind) { MonoFundamentalType fundamental; TargetAddress klass; switch (kind) { case FundamentalKind.Boolean: klass = corlib.MonoLanguage.MetadataHelper.GetBooleanClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Boolean"), "bool", kind, 1); break; case FundamentalKind.Char: klass = corlib.MonoLanguage.MetadataHelper.GetCharClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Char"), "char", kind, 2); break; case FundamentalKind.SByte: klass = corlib.MonoLanguage.MetadataHelper.GetSByteClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.SByte"), "sbyte", kind, 1); break; case FundamentalKind.Byte: klass = corlib.MonoLanguage.MetadataHelper.GetByteClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Byte"), "byte", kind, 1); break; case FundamentalKind.Int16: klass = corlib.MonoLanguage.MetadataHelper.GetInt16Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Int16"), "short", kind, 2); break; case FundamentalKind.UInt16: klass = corlib.MonoLanguage.MetadataHelper.GetUInt16Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.UInt16"), "ushort", kind, 2); break; case FundamentalKind.Int32: klass = corlib.MonoLanguage.MetadataHelper.GetInt32Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Int32"), "int", kind, 4); break; case FundamentalKind.UInt32: klass = corlib.MonoLanguage.MetadataHelper.GetUInt32Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.UInt32"), "uint", kind, 4); break; case FundamentalKind.Int64: klass = corlib.MonoLanguage.MetadataHelper.GetInt64Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Int64"), "long", kind, 8); break; case FundamentalKind.UInt64: klass = corlib.MonoLanguage.MetadataHelper.GetUInt64Class (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.UInt64"), "ulong", kind, 8); break; case FundamentalKind.Single: klass = corlib.MonoLanguage.MetadataHelper.GetSingleClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Single"), "float", kind, 4); break; case FundamentalKind.Double: klass = corlib.MonoLanguage.MetadataHelper.GetDoubleClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Double"), "double", kind, 8); break; case FundamentalKind.IntPtr: klass = corlib.MonoLanguage.MetadataHelper.GetIntPtrClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.IntPtr"), "System.IntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize); break; case FundamentalKind.UIntPtr: klass = corlib.MonoLanguage.MetadataHelper.GetUIntPtrClass (memory); fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.UIntPtr"), "System.UIntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize); break; case FundamentalKind.Decimal: fundamental = new MonoFundamentalType ( corlib, corlib.ModuleDefinition.GetType ("System.Decimal"), "decimal", kind, Marshal.SizeOf (typeof (Decimal))); return fundamental; default: throw new InternalError (); } fundamental.create_type (memory, klass); return fundamental; }
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); }
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); }
public static MonoFundamentalType Create(MonoSymbolFile corlib, TargetMemoryAccess memory, FundamentalKind kind) { MonoFundamentalType fundamental; TargetAddress klass; switch (kind) { case FundamentalKind.Boolean: klass = corlib.MonoLanguage.MetadataHelper.GetBooleanClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Boolean"), "bool", kind, 1); break; case FundamentalKind.Char: klass = corlib.MonoLanguage.MetadataHelper.GetCharClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Char"), "char", kind, 2); break; case FundamentalKind.SByte: klass = corlib.MonoLanguage.MetadataHelper.GetSByteClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.SByte"), "sbyte", kind, 1); break; case FundamentalKind.Byte: klass = corlib.MonoLanguage.MetadataHelper.GetByteClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Byte"), "byte", kind, 1); break; case FundamentalKind.Int16: klass = corlib.MonoLanguage.MetadataHelper.GetInt16Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Int16"), "short", kind, 2); break; case FundamentalKind.UInt16: klass = corlib.MonoLanguage.MetadataHelper.GetUInt16Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.UInt16"), "ushort", kind, 2); break; case FundamentalKind.Int32: klass = corlib.MonoLanguage.MetadataHelper.GetInt32Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Int32"), "int", kind, 4); break; case FundamentalKind.UInt32: klass = corlib.MonoLanguage.MetadataHelper.GetUInt32Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.UInt32"), "uint", kind, 4); break; case FundamentalKind.Int64: klass = corlib.MonoLanguage.MetadataHelper.GetInt64Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Int64"), "long", kind, 8); break; case FundamentalKind.UInt64: klass = corlib.MonoLanguage.MetadataHelper.GetUInt64Class(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.UInt64"), "ulong", kind, 8); break; case FundamentalKind.Single: klass = corlib.MonoLanguage.MetadataHelper.GetSingleClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Single"), "float", kind, 4); break; case FundamentalKind.Double: klass = corlib.MonoLanguage.MetadataHelper.GetDoubleClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Double"), "double", kind, 8); break; case FundamentalKind.IntPtr: klass = corlib.MonoLanguage.MetadataHelper.GetIntPtrClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.IntPtr"), "System.IntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize); break; case FundamentalKind.UIntPtr: klass = corlib.MonoLanguage.MetadataHelper.GetUIntPtrClass(memory); fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.UIntPtr"), "System.UIntPtr", kind, memory.TargetMemoryInfo.TargetAddressSize); break; case FundamentalKind.Decimal: fundamental = new MonoFundamentalType( corlib, corlib.ModuleDefinition.GetType("System.Decimal"), "decimal", kind, Marshal.SizeOf(typeof(Decimal))); return(fundamental); default: throw new InternalError(); } fundamental.create_type(memory, klass); return(fundamental); }