示例#1
0
        public DbgDotNetValueImpl(DbgEngineImpl engine, ValueLocation valueLocation, Value value)
        {
            this.engine        = engine ?? throw new ArgumentNullException(nameof(engine));
            this.valueLocation = valueLocation ?? throw new ArgumentNullException(nameof(valueLocation));
            this.value         = value ?? throw new ArgumentNullException(nameof(value));
            Type     = MonoValueTypeCreator.CreateType(engine, value, valueLocation.Type);
            rawValue = new DbgDotNetRawValueFactory(engine).Create(value, Type);

            var flags = ValueFlags.None;

            if (value is PrimitiveValue pv && (pv.Value is null || ((Type.IsPointer || Type.IsFunctionPointer) && boxed0L.Equals(pv.Value))))
            {
                if (Type.IsByRef)
                {
                    flags |= ValueFlags.IsNullByRef;
                }
                else
                {
                    flags |= ValueFlags.IsNull;
                }
            }
示例#2
0
        public DbgDotNetValueImpl(DbgEngineImpl engine, DbgCorValueHolder value)
        {
            this.engine = engine ?? throw new ArgumentNullException(nameof(engine));
            this.value  = value ?? throw new ArgumentNullException(nameof(value));
            Type        = value.Type;
            var corValue = value.CorValue;

            rawValue = new DbgDotNetRawValueFactory(engine).Create(corValue, Type);

            var flags = ValueFlags.None;

            if (corValue.IsNull)
            {
                if (Type.IsByRef)
                {
                    flags |= ValueFlags.IsNullByRef;
                }
                else
                {
                    flags |= ValueFlags.IsNull;
                }
            }
            this.flags = flags;
        }
示例#3
0
 public SyntheticValue(DmdType type, DbgDotNetRawValue rawValue)
 {
     Type          = type ?? throw new ArgumentNullException(nameof(type));
     this.rawValue = rawValue;
 }
        public bool TryFormat(DmdType type, DbgDotNetRawValue rawValue)
        {
            if (!rawValue.HasRawValue)
            {
                return(false);
            }

            if (rawValue.RawValue == null)
            {
                OutputWrite(Keyword_null, DbgTextColor.Keyword);
                return(true);
            }

            if (type.IsEnum && NumberUtils.TryConvertIntegerToUInt64ZeroExtend(rawValue.RawValue, out var enumValue))
            {
                FormatEnum(enumValue, type);
                return(true);
            }

            switch (rawValue.ValueType)
            {
            case DbgSimpleValueType.Other:
                if (rawValue.RawValue is DmdType)
                {
                    // It's a type variable
                    FormatType((DmdType)rawValue.RawValue);
                    return(true);
                }
                return(false);

            case DbgSimpleValueType.Boolean:
                FormatBoolean((bool)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Char1:
                FormatChar((char)(byte)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.CharUtf16:
                FormatChar((char)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Int8:
                FormatSByte((sbyte)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Int16:
                FormatInt16((short)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Int32:
                FormatInt32((int)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Int64:
                FormatInt64((long)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.UInt8:
                FormatByte((byte)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.UInt16:
                FormatUInt16((ushort)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.UInt32:
                FormatUInt32((uint)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.UInt64:
                FormatUInt64((ulong)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Float32:
                FormatSingle((float)rawValue.RawValue, type.AppDomain);
                return(true);

            case DbgSimpleValueType.Float64:
                FormatDouble((double)rawValue.RawValue, type.AppDomain);
                return(true);

            case DbgSimpleValueType.Decimal:
                FormatDecimal((decimal)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Ptr32:
                FormatPointer32((uint)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.Ptr64:
                FormatPointer64((ulong)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.StringUtf16:
                FormatString((string)rawValue.RawValue);
                return(true);

            case DbgSimpleValueType.DateTime:
                FormatDateTime((DateTime)rawValue.RawValue);
                return(true);

            default:
                throw new InvalidOperationException();
            }
        }