diff options
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 80ff47b17..016df2e18 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -76,6 +76,16 @@ Literal::Literal(std::shared_ptr<GCData> gcData, HeapType type) assert((isData() && gcData) || (type.isBottom() && !gcData)); } +Literal::Literal(std::string string) + : gcData(nullptr), type(Type(HeapType::string, NonNullable)) { + // TODO: we could in theory internalize strings + Literals contents; + for (auto c : string) { + contents.push_back(Literal(int32_t(c))); + } + gcData = std::make_shared<GCData>(HeapType::string, contents); +} + Literal::Literal(const Literal& other) : type(other.type) { if (type.isBasic()) { switch (type.getBasic()) { |