Exemplo n.º 1
0
        public ISymbolValue VisitPrimitiveType(PrimitiveType t)
        {
            var sz    = ExamHelpers.SizeOf(t.TypeToken, Is64Bit);
            var bytes = Backtrace.BacktraceHelper.ReadBytes(Symbol.Offset, (ulong)sz);

            return(new PrimitiveValue(ExamHelpers.GetNumericValue(bytes, 0, t.TypeToken), t));
        }
Exemplo n.º 2
0
        public ISymbolValue VisitArrayType(ArrayType t)
        {
            var valueType          = DResolver.StripMemberSymbols(t.ValueType);
            var primitiveValueType = valueType as PrimitiveType;

            ulong arraySize;
            ulong firstElement;

            var arrSymb = Symbol as IDBacktraceArraySymbol;

            if (arrSymb != null)
            {
                arraySize    = (ulong)arrSymb.ArrayLength;
                firstElement = arrSymb.FirstElementOffset;
            }
            else
            {
                if (Symbol.Offset == 0)
                {
                    return(new NullValue(t));
                }

                byte[] arrayInfo = Backtrace.BacktraceHelper.ReadBytes(Symbol.Offset, PointerSize * 2);
                arraySize    = PointerSize == 8 ? BitConverter.ToUInt64(arrayInfo, 0) : (ulong)BitConverter.ToUInt32(arrayInfo, 0);
                firstElement = PointerSize == 8 ? BitConverter.ToUInt64(arrayInfo, 8) : BitConverter.ToUInt32(arrayInfo, 4);
            }

            arraySize = Math.Min(arraySize, DLocalExamBacktrace.MaximumArrayChildrenDisplayCount);

            if (firstElement == 0)
            {
                return(new NullValue(t));
            }

            var values = new List <ISymbolValue>();

            if (primitiveValueType != null)
            {
                var tt        = primitiveValueType.TypeToken;
                var sz        = ExamHelpers.SizeOf(tt, Is64Bit);
                var charBytes = Backtrace.BacktraceHelper.ReadBytes(firstElement, sz * arraySize);

                if (DTokens.IsBasicType_Character(tt))
                {
                    return(new ArrayValue(t, ExamHelpers.GetStringValue(charBytes, tt)));
                }

                for (uint i = 0; i < arraySize; i++)
                {
                    values.Add(new PrimitiveValue(ExamHelpers.GetNumericValue(charBytes, (int)i * sz, tt), primitiveValueType));
                }
            }

            return(new ArrayValue(t, values.ToArray()));
        }