@@ -479,6 +479,55 @@ Return the number of codepoints that were actually consumed.
479479Return a substring of * ` view ` * , starting at the current position of
480480* ` view ` * and continuing for at most * ` codepoints ` * codepoints.
481481
482+ ## Binary encoding
483+
484+ ```
485+ reftype ::= ...
486+ | 0x67 ⇒ stringref ; SLEB128(-0x19)
487+ | 0x66 ⇒ stringview_wtf8 ; SLEB128(-0x1a)
488+ | 0x65 ⇒ stringview_wtf16 ; SLEB128(-0x1b)
489+ | 0x64 ⇒ stringview_iter ; SLEB128(-0x1c)
490+
491+ wtf8_policy ::= 0x00 ⇒ utf8
492+ | 0x01 ⇒ wtf8
493+ | 0x02 ⇒ replace
494+
495+ instr ::= ...
496+ | 0xfc 0x12 $mem:u32 ⇒ string.new_wtf8 $mem
497+ | 0xfc 0x13 $mem:u32 ⇒ string.new_wtf16 $mem
498+ | 0xfc 0x14 $idx:u32 ⇒ string.const $idx
499+ | 0xfc 0x15 ⇒ string.measure_utf8
500+ | 0xfc 0x16 ⇒ string.measure_wtf8
501+ | 0xfc 0x17 ⇒ string.measure_wtf16
502+ | 0xfc 0x18 $mem:u32 $policy:u32 ⇒ string.encode_wtf8 $mem $policy
503+ | 0xfc 0x19 $mem:u32 ⇒ string.encode_wtf16 $mem
504+ | 0xfc 0x1a ⇒ string.concat
505+ | 0xfc 0x1b ⇒ string.eq
506+ | 0xfc 0x1c ⇒ string.is_usv_sequence
507+ | 0xfc 0x1d ⇒ string.as_wtf8
508+ | 0xfc 0x1e ⇒ string.as_wtf16
509+ | 0xfc 0x1f ⇒ string.as_iter
510+ | 0xfc 0x20 ⇒ stringview_wtf8.advance
511+ | 0xfc 0x21 $mem:u32 $policy:u32 ⇒ stringview_wtf8.encode $mem $policy
512+ | 0xfc 0x22 ⇒ stringview_wtf8.slice
513+ | 0xfc 0x23 ⇒ stringview_wtf16.length
514+ | 0xfc 0x24 ⇒ stringview_wtf16.get_codeunit
515+ | 0xfc 0x25 $mem:u32 ⇒ stringview_wtf16.encode $mem
516+ | 0xfc 0x26 ⇒ stringview_wtf16.slice
517+ | 0xfc 0x27 ⇒ stringview_iter.cur
518+ | 0xfc 0x28 ⇒ stringview_iter.advance
519+ | 0xfc 0x29 ⇒ stringview_iter.rewind
520+ | 0xfc 0x2a ⇒ stringview_iter.slice
521+
522+ ;; New section. Could be a data segment instead, but really we would
523+ ;; like for it to come before the code so that we can avoid dynamic
524+ ;; checks in string.const, and before the elem and global sections so
525+ ;; that we can have constant strings. If present, must be present only
526+ ;; once, and right before the globals section (or where the globals
527+ ;; section would be).
528+ stringrefs ::= section_13(vec(vec(u8)))
529+ ```
530+
482531## Examples
483532
484533We assume that the textual syntax for ` string.encode ` and ` string.new `
0 commit comments