Skip to content

Commit 799a7f7

Browse files
committed
Re-sync CanonicalABI.md and canonical_abi/definitions.py
1 parent 67ef9a2 commit 799a7f7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

design/mvp/CanonicalABI.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,21 +493,21 @@ def store_string_into_range(opts, v):
493493
match opts.string_encoding:
494494
case 'utf8':
495495
match src_simple_encoding:
496-
case 'utf8' : return store_string_copy(opts, src, src_code_units, 1, 'utf-8')
496+
case 'utf8' : return store_string_copy(opts, src, src_code_units, 1, 1, 'utf-8')
497497
case 'utf16' : return store_utf16_to_utf8(opts, src, src_code_units)
498498
case 'latin1' : return store_latin1_to_utf8(opts, src, src_code_units)
499499
case 'utf16':
500500
match src_simple_encoding:
501501
case 'utf8' : return store_utf8_to_utf16(opts, src, src_code_units)
502-
case 'utf16' : return store_string_copy(opts, src, src_code_units, 2, 'utf-16-le')
503-
case 'latin1' : return store_string_copy(opts, src, src_code_units, 2, 'utf-16-le')
502+
case 'utf16' : return store_string_copy(opts, src, src_code_units, 2, 2, 'utf-16-le')
503+
case 'latin1' : return store_string_copy(opts, src, src_code_units, 2, 2, 'utf-16-le')
504504
case 'latin1+utf16':
505505
match src_encoding:
506506
case 'utf8' : return store_string_to_latin1_or_utf16(opts, src, src_code_units)
507507
case 'utf16' : return store_string_to_latin1_or_utf16(opts, src, src_code_units)
508508
case 'latin1+utf16' :
509509
match src_simple_encoding:
510-
case 'latin1' : return store_string_copy(opts, src, src_code_units, 1, 'latin-1')
510+
case 'latin1' : return store_string_copy(opts, src, src_code_units, 1, 2, 'latin-1')
511511
case 'utf16' : return store_probably_utf16_to_latin1_or_utf16(opts, src, src_code_units)
512512
```
513513

@@ -517,10 +517,10 @@ byte after every Latin-1 byte).
517517
```python
518518
MAX_STRING_BYTE_LENGTH = (1 << 31) - 1
519519

520-
def store_string_copy(opts, src, src_code_units, dst_code_unit_size, dst_encoding):
520+
def store_string_copy(opts, src, src_code_units, dst_code_unit_size, dst_alignment, dst_encoding):
521521
dst_byte_length = dst_code_unit_size * src_code_units
522522
trap_if(dst_byte_length > MAX_STRING_BYTE_LENGTH)
523-
ptr = opts.realloc(0, 0, dst_code_unit_size, dst_byte_length)
523+
ptr = opts.realloc(0, 0, dst_alignment, dst_byte_length)
524524
encoded = src.encode(dst_encoding)
525525
assert(dst_byte_length == len(encoded))
526526
opts.memory[ptr : ptr+len(encoded)] = encoded
@@ -863,7 +863,7 @@ def lift_flat_signed(vi, core_width, t_width):
863863
assert(0 <= i < (1 << core_width))
864864
i %= (1 << t_width)
865865
if i >= (1 << (t_width - 1)):
866-
return i - (1 << (t_width - 1))
866+
return i - (1 << t_width)
867867
return i
868868
```
869869

design/mvp/canonical-abi/definitions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def store_utf8_to_utf16(opts, src, src_code_units):
492492

493493
def store_string_to_latin1_or_utf16(opts, src, src_code_units):
494494
assert(src_code_units <= MAX_STRING_BYTE_LENGTH)
495-
ptr = opts.realloc(0, 0, 1, src_code_units)
495+
ptr = opts.realloc(0, 0, 2, src_code_units)
496496
dst_byte_length = 0
497497
for usv in src:
498498
if ord(usv) < (1 << 8):
@@ -512,7 +512,7 @@ def store_string_to_latin1_or_utf16(opts, src, src_code_units):
512512
tagged_code_units = int(len(encoded) / 2) | UTF16_TAG
513513
return (ptr, tagged_code_units)
514514
if dst_byte_length < src_code_units:
515-
ptr = opts.realloc(ptr, src_code_units, 1, dst_byte_length)
515+
ptr = opts.realloc(ptr, src_code_units, 2, dst_byte_length)
516516
return (ptr, dst_byte_length)
517517

518518
#

0 commit comments

Comments
 (0)