/// <summary> /// Gets or sets a value in memory at a particular byte offset. /// </summary> /// <value>A value in memory.</value> public long this[uint offset] { get { LinearMemory.CheckBounds(mem, offset, 8); return((long)mem[(int)offset + 7] << 56 | (long)mem[(int)offset + 6] << 48 | (long)mem[(int)offset + 5] << 40 | (long)mem[(int)offset + 4] << 32 | (long)mem[(int)offset + 3] << 24 | (long)mem[(int)offset + 2] << 16 | (long)mem[(int)offset + 1] << 8 | (long)mem[(int)offset]); } set { LinearMemory.CheckBounds(mem, offset, 8); mem[(int)offset + 7] = (byte)(value >> 56); mem[(int)offset + 6] = (byte)(value >> 48); mem[(int)offset + 5] = (byte)(value >> 40); mem[(int)offset + 4] = (byte)(value >> 32); mem[(int)offset + 3] = (byte)(value >> 24); mem[(int)offset + 2] = (byte)(value >> 16); mem[(int)offset + 1] = (byte)(value >> 8); mem[(int)offset] = (byte)value; } }
public void GrowMemory() { var limits = new ResizableLimits(1, 2); var memory = new LinearMemory(limits); Assert.AreEqual(1, memory.Size); Assert.AreEqual(1, memory.Grow(1)); Assert.AreEqual(2, memory.Size); Assert.AreEqual(-1, memory.Grow(1)); Assert.AreEqual(2, memory.Size); }
public void RoundTripInt64() { var limits = new ResizableLimits(1, 2); var memory = new LinearMemory(limits); uint offset = MemoryType.PageSize / 2; long data = 0x1F2E3D4C5B6A7988; var int64Mem = memory.Int64; int64Mem[offset] = data; Assert.AreEqual((long)data, (long)int64Mem[offset]); }
public void RoundTripInt32() { var limits = new ResizableLimits(1, 2); var memory = new LinearMemory(limits); uint offset = MemoryType.PageSize / 2; int data = 0x1F2E3D4C; var int32Mem = memory.Int32; int32Mem[offset] = data; Assert.AreEqual((int)data, (int)int32Mem[offset]); }
/// <summary> /// Gets or sets a value in memory at a particular byte offset. /// </summary> /// <value>A value in memory.</value> public sbyte this[uint offset] { get { LinearMemory.CheckBounds(mem, offset, 1); return((sbyte)mem[(int)offset]); } set { LinearMemory.CheckBounds(mem, offset, 1); mem[(int)offset] = (byte)value; } }
/// <summary> /// Gets or sets a value in memory at a particular byte offset. /// </summary> /// <value>A value in memory.</value> public short this[uint offset] { get { LinearMemory.CheckBounds(mem, offset, 2); return((short)( (uint)mem[(int)offset + 1] << 8 | (uint)mem[(int)offset])); } set { LinearMemory.CheckBounds(mem, offset, 2); mem[(int)offset + 1] = (byte)(value >> 8); mem[(int)offset] = (byte)value; } }
/// <summary> /// Gets or sets a value in memory at a particular byte offset. /// </summary> /// <value>A value in memory.</value> public int this[uint offset] { get { LinearMemory.CheckBounds(mem, offset, 4); return((int)mem[(int)offset + 3] << 24 | (int)mem[(int)offset + 2] << 16 | (int)mem[(int)offset + 1] << 8 | (int)mem[(int)offset]); } set { LinearMemory.CheckBounds(mem, offset, 4); mem[(int)offset + 3] = (byte)(value >> 24); mem[(int)offset + 2] = (byte)(value >> 16); mem[(int)offset + 1] = (byte)(value >> 8); mem[(int)offset] = (byte)value; } }
/// <summary> /// Maps the given name to the given memory. /// </summary> /// <param name="Name">The name to define.</param> /// <param name="Definition">The memory definition.</param> public void DefineMemory(string Name, LinearMemory Definition) { memDefDict[Name] = Definition; }
/// <summary> /// Maps the given name to the given memory. /// </summary> /// <param name="name">The name to define.</param> /// <param name="definition">The memory definition.</param> public void DefineMemory(string name, LinearMemory definition) { memDefDict[name] = definition; }