Ejemplo n.º 1
0
        /// <inheritdoc />
        public ICliValue LoadElement(int index, TypeMemoryLayout typeLayout, ICliMarshaller marshaller)
        {
            AssertIndexValidity(index);
            var elementValue = this.ReadStruct(index * (int)typeLayout.Size, _memoryAllocator, typeLayout);

            return(marshaller.ToCliValue(elementValue, typeLayout.Type.ToTypeSignature()));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void StoreElement(int index, TypeMemoryLayout typeLayout, ICliValue value, ICliMarshaller marshaller)
        {
            AssertIndexValidity(index);
            var elementValue = marshaller.ToCtsValue(value, typeLayout.Type.ToTypeSignature());

            this.WriteStruct(index * (int)typeLayout.Size, _memoryAllocator, typeLayout, elementValue);
        }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public void StoreElement(int index, TypeMemoryLayout typeLayout, ICliValue value, ICliMarshaller marshaller) =>
     _values[index] = marshaller.ToCtsValue(value, typeLayout.Type.ToTypeSignature());
Ejemplo n.º 4
0
 /// <inheritdoc />
 public ICliValue LoadElement(int index, TypeMemoryLayout typeLayout, ICliMarshaller marshaller) =>
     marshaller.ToCliValue(_values[index], typeLayout.Type.ToTypeSignature());
Ejemplo n.º 5
0
 /// <summary>
 /// Reads a single .NET structure at the provided offset.
 /// </summary>
 /// <param name="self">The base pointer value to read from.</param>
 /// <param name="offset">The offset to start reading.</param>
 /// <param name="valueFactory">The memory allocator responsible for managing type layouts.</param>
 /// <param name="typeLayout">The type layout to read.</param>
 /// <returns>The read structure.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// Occurs when the offset does not fall within the memory range.
 /// </exception>
 public static IConcreteValue ReadStruct(this IMemoryAccessValue self, int offset, IValueFactory valueFactory, TypeMemoryLayout typeLayout)
 {
     return(typeLayout.Type.ToTypeSignature().ElementType switch
     {
         ElementType.Boolean => self.ReadInteger8(offset),
         ElementType.Char => self.ReadInteger16(offset),
         ElementType.I1 => self.ReadInteger8(offset),
         ElementType.U1 => self.ReadInteger8(offset),
         ElementType.I2 => self.ReadInteger16(offset),
         ElementType.U2 => self.ReadInteger16(offset),
         ElementType.I4 => self.ReadInteger32(offset),
         ElementType.U4 => self.ReadInteger32(offset),
         ElementType.I8 => self.ReadInteger64(offset),
         ElementType.U8 => self.ReadInteger64(offset),
         ElementType.R4 => self.ReadFloat32(offset),
         ElementType.R8 => self.ReadFloat64(offset),
         ElementType.ValueType => self.ReadStructSlow(offset, valueFactory, typeLayout),
         ElementType.I => valueFactory.Is32Bit ? (IntegerValue)self.ReadInteger32(offset) : self.ReadInteger64(offset),
         ElementType.U => valueFactory.Is32Bit ? (IntegerValue)self.ReadInteger32(offset) : self.ReadInteger64(offset),
         ElementType.Enum => ReadEnumValue(self, offset, valueFactory, typeLayout),
         _ => new UnknownValue()
     });