summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index e9bee8e08..bf7ebc620 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -3248,37 +3248,43 @@ void FunctionValidator::visitStringNew(StringNew* curr) {
"string operations require reference-types [--enable-strings]");
switch (curr->op) {
+ case StringNewLossyUTF8Array:
case StringNewWTF16Array: {
- auto ptrType = curr->ptr->type;
- if (ptrType == Type::unreachable) {
+ auto refType = curr->ref->type;
+ if (refType == Type::unreachable) {
return;
}
- if (!shouldBeTrue(ptrType.isRef(),
- curr,
- "string.new_wtf16_array input must have string type")) {
+ if (!shouldBeTrue(
+ refType.isRef(), curr, "string.new input must have array type")) {
return;
}
- auto ptrHeapType = ptrType.getHeapType();
- if (!shouldBeTrue(ptrHeapType.isBottom() || ptrHeapType.isArray(),
+ auto heapType = refType.getHeapType();
+ if (!shouldBeTrue(heapType.isBottom() || heapType.isArray(),
curr,
- "string.new_wtf16_array input must be array")) {
+ "string.new input must have array type")) {
return;
}
+ shouldBeEqualOrFirstIsUnreachable(curr->start->type,
+ Type(Type::i32),
+ curr,
+ "string.new start must be i32");
shouldBeEqualOrFirstIsUnreachable(
- curr->start->type,
- Type(Type::i32),
- curr,
- "string.new_wtf16_array start must be i32");
+ curr->end->type, Type(Type::i32), curr, "string.new end must be i32");
+ return;
+ }
+ case StringNewFromCodePoint:
shouldBeEqualOrFirstIsUnreachable(
- curr->end->type,
+ curr->ref->type,
Type(Type::i32),
curr,
- "string.new_wtf16_array end must be i32");
- break;
- }
- default: {
- }
+ "string.from_code_point code point must be i32");
+ shouldBeTrue(
+ !curr->start, curr, "string.from_code_point should not have start");
+ shouldBeTrue(
+ !curr->end, curr, "string.from_code_point should not have end");
+ return;
}
+ WASM_UNREACHABLE("unexpected op");
}
void FunctionValidator::visitStringConst(StringConst* curr) {