summaryrefslogtreecommitdiff
path: root/src/literal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/literal.h')
-rw-r--r--src/literal.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/literal.h b/src/literal.h
index 213713a1f..5e449c576 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -48,7 +48,9 @@ class Literal {
// A reference to GC data, either a Struct or an Array. For both of those
// we store the referred data as a Literals object (which is natural for an
// Array, and for a Struct, is just the fields in order). The type is used
- // to indicate whether this is a Struct or an Array, and of what type.
+ // to indicate whether this is a Struct or an Array, and of what type. We
+ // also use this to store String data, as it is similarly stored on the
+ // heap.
std::shared_ptr<GCData> gcData;
// TODO: Literals of type `anyref` can only be `null` currently but we
// will need to represent external values eventually, to
@@ -90,7 +92,10 @@ public:
bool isConcrete() const { return type.isConcrete(); }
bool isNone() const { return type == Type::none; }
bool isFunction() const { return type.isFunction(); }
+ // Whether this is GC data, that is, something stored on the heap (aside from
+ // a null or i31). This includes structs, arrays, and also strings.
bool isData() const { return type.isData(); }
+ bool isString() const { return type.isString(); }
bool isNull() const { return type.isNull(); }
@@ -709,10 +714,10 @@ public:
std::ostream& operator<<(std::ostream& o, wasm::Literal literal);
std::ostream& operator<<(std::ostream& o, wasm::Literals literals);
-// A GC Struct or Array is a set of values with a type saying how it should be
-// interpreted.
+// A GC Struct, Array, or String is a set of values with a type saying how it
+// should be interpreted.
struct GCData {
- // The type of this struct or array.
+ // The type of this struct, array, or string.
HeapType type;
// The element or field values.