This instance will be upgraded to Heptapod 0.17.0 on 2020-11-26 at 14:00 UTC+1 (a few minutes of down time)

Commit de80775b authored by Jesse McGrew's avatar Jesse McGrew

Fixed encode_text ignoring the 'start' operand.

Fixed encode_text throwing an exception because it used the wrong buffer size.
parent b56bb512b25e
Array source_table -> 72 101 108 108 111;
Array dest_table -> 6;
[ Main i;
@encode_text source_table 4 1 dest_table;
print (address) dest_table;
];
ello
\ No newline at end of file
......@@ -434,7 +434,7 @@ namespace ZLR.VM
{
int dictStart;
Span<byte> word = stackalloc byte[DictWordSize * 2 / 3];
Span<byte> word = stackalloc byte[DictWordSizeInBytes];
EncodeText(buffer.AsSpan(pos, length), word);
if (userDict != 0)
......@@ -500,7 +500,7 @@ namespace ZLR.VM
{
int dictStart;
var word = EncodeText(buffer, pos, length, DictWordSize);
var word = EncodeText(buffer, pos, length, DictWordSizeInZchars);
if (userDict != 0)
{
......
......@@ -560,28 +560,23 @@ namespace ZLR.VM
}
#if HAVE_SPAN
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "See TODO")]
internal void EncodeTextImpl(ushort buffer, ushort length, ushort start, ushort dest)
{
// BUG: start is ignored
var src = GetSpan(buffer, length);
var destSpan = GetSpan(dest, DictWordSize);
var src = GetSpan(buffer + start, length);
var destSpan = GetSpan(dest, DictWordSizeInBytes);
EncodeText(src, destSpan);
TrapMemory(dest, (ushort)this.DictWordSize);
TrapMemory(dest, (ushort)this.DictWordSizeInBytes);
}
#endif
#if !HAVE_SPAN
internal void EncodeTextImpl(ushort buffer, ushort length, ushort start, ushort dest)
{
// BUG: start is ignored
var text = new byte[length];
for (var i = 0; i < length; i++)
text[i] = GetByte(buffer + i);
text[i] = GetByte(buffer + start + i);
var result = EncodeText(text, 0, length, DictWordSize);
var result = EncodeText(text, 0, length, DictWordSizeInZchars);
for (var i = 0; i < result.Length; i++)
SetByte(dest + i, result[i]);
}
......
......@@ -979,7 +979,8 @@ namespace ZLR.VM
partial class ZMachine
{
private int DictWordSize => zversion >= 4 ? 9 : 6;
private int DictWordSizeInZchars => zversion >= 4 ? 9 : 6;
private int DictWordSizeInBytes => DictWordSizeInZchars * 2 / 3;
#pragma warning disable 0169
internal void PrintZSCII(short zc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment