Пример #1
0
        public static ImmutableBytes WriteByte(
            ImmutableBytes bytes,
            ByteAddress address,
            byte value)
        {
            if (address.IsOutOfRange(bytes.Size))
            {
                throw new InvalidOperationException("out of range");
            }

            return(new ImmutableBytes(bytes.OriginalBytes, bytes.Edits.Add(address.Value, value)));
        }
Пример #2
0
        public byte ReadByte(ByteAddress address)
        {
            var dynamicSize = DynamicMemory.Size;

            if (address.IsInRange(dynamicSize))
            {
                return(ImmutableBytes.ReadByte(DynamicMemory, address));
            }

            var staticAddress = address.DecrementBy(dynamicSize);

            return(staticAddress.DereferenceBytes(StaticMemory));
        }
Пример #3
0
        public static byte ReadByte(ImmutableBytes bytes, ByteAddress address)
        {
            if (address.IsOutOfRange(bytes.Size))
            {
                throw new InvalidOperationException("out of range");
            }

            if (bytes.Edits.TryGetValue(address.Value, out var recordedEdit))
            {
                return(recordedEdit);
            }

            return(bytes.OriginalBytes[address.Value]);
        }
Пример #4
0
 public override string ToString()
 {
     return(ByteAddress.ToString() + "." + BitAddress.ToString());
 }
Пример #5
0
        public Story WriteByte(ByteAddress address, byte value)
        {
            var dynamicMemory = ImmutableBytes.WriteByte(DynamicMemory, address, value);

            return(new Story(dynamicMemory, StaticMemory));
        }