(string)
| 734 | } |
| 735 | |
| 736 | emit_string(string) { |
| 737 | // When testing illegal names, we pass a byte array directly. |
| 738 | if (string instanceof Array) { |
| 739 | this.emit_u32v(string.length); |
| 740 | this.emit_bytes(string); |
| 741 | return; |
| 742 | } |
| 743 | |
| 744 | // This is the hacky way to convert a JavaScript string to a UTF8 encoded |
| 745 | // string only containing single-byte characters. |
| 746 | let string_utf8 = unescape(encodeURIComponent(string)); |
| 747 | this.emit_u32v(string_utf8.length); |
| 748 | for (let i = 0; i < string_utf8.length; i++) { |
| 749 | this.emit_u8(string_utf8.charCodeAt(i)); |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | emit_heap_type(heap_type) { |
| 754 | this.emit_bytes(wasmSignedLeb(heap_type, kMaxVarInt32Size)); |
no test coverage detected