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))); }
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)); }
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()); }
public Story WriteByte(ByteAddress address, byte value) { var dynamicMemory = ImmutableBytes.WriteByte(DynamicMemory, address, value); return(new Story(dynamicMemory, StaticMemory)); }