示例#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]);
        }
 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));
        }