MCPcopy Create free account
hub / github.com/nodejs/node / emit_string

Method emit_string

test/fixtures/wpt/wasm/jsapi/wasm-module-builder.js:736–751  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

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));

Callers 2

stringToBytesMethod · 0.95
toBufferMethod · 0.45

Calls 4

emit_u32vMethod · 0.95
emit_bytesMethod · 0.95
emit_u8Method · 0.95
unescapeFunction · 0.50

Tested by

no test coverage detected