(string)
| 1187 | } |
| 1188 | |
| 1189 | emit_string(string) { |
| 1190 | // When testing illegal names, we pass a byte array directly. |
| 1191 | if (string instanceof Array) { |
| 1192 | this.emit_u32v(string.length); |
| 1193 | this.emit_bytes(string); |
| 1194 | return; |
| 1195 | } |
| 1196 | |
| 1197 | // This is the hacky way to convert a JavaScript string to a UTF8 encoded |
| 1198 | // string only containing single-byte characters. |
| 1199 | let string_utf8 = unescape(encodeURIComponent(string)); |
| 1200 | this.emit_u32v(string_utf8.length); |
| 1201 | for (let i = 0; i < string_utf8.length; i++) { |
| 1202 | this.emit_u8(string_utf8.charCodeAt(i)); |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | emit_heap_type(heap_type) { |
| 1207 | this.emit_bytes(wasmSignedLeb(heap_type, kMaxVarInt32Size)); |
no test coverage detected