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

Method emit_string

deps/v8/test/mjsunit/wasm/wasm-module-builder.js:1189–1204  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

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

Callers 1

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