diff options
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r-- | src/wasm/wasm.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 5954dd617..2eed06981 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1104,7 +1104,8 @@ void StructNew::finalize() { if (handleUnreachableOperands(this)) { return; } - type = Type(rtt->type.getHeapType(), /* nullable = */ false); + // TODO: make non-nullable when we support that + type = Type(rtt->type.getHeapType(), /* nullable = */ true); } void StructGet::finalize() { @@ -1123,10 +1124,40 @@ void StructSet::finalize() { } } -// TODO (gc): array.new -// TODO (gc): array.get -// TODO (gc): array.set -// TODO (gc): array.len +void ArrayNew::finalize() { + if (rtt->type == Type::unreachable || size->type == Type::unreachable || + (init && init->type == Type::unreachable)) { + type = Type::unreachable; + return; + } + // TODO: make non-nullable when we support that + type = Type(rtt->type.getHeapType(), /* nullable = */ true); +} + +void ArrayGet::finalize() { + if (ref->type == Type::unreachable || index->type == Type::unreachable) { + type = Type::unreachable; + } else { + type = ref->type.getHeapType().getArray().element.type; + } +} + +void ArraySet::finalize() { + if (ref->type == Type::unreachable || index->type == Type::unreachable || + value->type == Type::unreachable) { + type = Type::unreachable; + } else { + type = Type::none; + } +} + +void ArrayLen::finalize() { + if (ref->type == Type::unreachable) { + type = Type::unreachable; + } else { + type = Type::i32; + } +} size_t Function::getNumParams() { return sig.params.size(); } |