Ejemplo n.º 1
0
        public BitWidth StoredWidth(BitWidth bitWidth = BitWidth.Width8)
        {
            if (TypesUtil.IsInline(ValueType))
            {
                return((BitWidth)Math.Max((int)bitWidth, (int)Width));
            }

            return(Width);
        }
Ejemplo n.º 2
0
        public BitWidth ElementWidth(ulong size, int index)
        {
            if (TypesUtil.IsInline(ValueType))
            {
                return(Width);
            }

            for (var i = 0; i < 4; i++)
            {
                var width     = (ulong)1 << i;
                var offsetLoc = size + BitWidthUtil.PaddingSize(size, width) + (ulong)index * width;
                var offset    = offsetLoc - UValue;
                var bitWidth  = BitWidthUtil.Width(offset);
                if ((1UL << (byte)bitWidth) == width)
                {
                    return(bitWidth);
                }
            }
            throw new Exception($"Element with size: {size} and index: {index} is of unknown width");
        }