Esempio n. 1
0
 /// <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;
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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]);
        }
Esempio n. 4
0
        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]);
        }
Esempio n. 5
0
 /// <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;
     }
 }
Esempio n. 6
0
 /// <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;
     }
 }
Esempio n. 7
0
 /// <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;
     }
 }
Esempio n. 8
0
 /// <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;
 }
Esempio n. 9
0
 /// <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;
 }