summaryrefslogtreecommitdiff
path: root/src/wasm-builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-builder.h')
-rw-r--r--src/wasm-builder.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index 7d4991d9a..cc90a8abe 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -1265,12 +1265,17 @@ public:
return makeRefI31(makeConst(value.geti31()));
}
if (type.isString()) {
- // TODO: more than ascii support
- std::string string;
+ // The string is already WTF-16, but we need to convert from `Literals` to
+ // actual string.
+ std::stringstream wtf16;
for (auto c : value.getGCData()->values) {
- string.push_back(c.getInteger());
+ auto u = c.getInteger();
+ assert(u < 0x10000);
+ wtf16 << uint8_t(u & 0xFF);
+ wtf16 << uint8_t(u >> 8);
}
- return makeStringConst(string);
+ // TODO: Use wtf16.view() once we have C++20.
+ return makeStringConst(wtf16.str());
}
if (type.isRef() && type.getHeapType() == HeapType::ext) {
return makeRefAs(ExternExternalize,