diff options
Diffstat (limited to 'src/ir/properties.cpp')
-rw-r--r-- | src/ir/properties.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir/properties.cpp b/src/ir/properties.cpp index 4ade8aa10..b564b3bf1 100644 --- a/src/ir/properties.cpp +++ b/src/ir/properties.cpp @@ -36,6 +36,8 @@ bool isGenerative(Expression* curr, FeatureSet features) { return scanner.generative; } +// Checks an expression in a shallow manner (i.e., does not check children) as +// to whether it is valid in a wasm constant expression. static bool isValidInConstantExpression(Module& wasm, Expression* expr) { if (isSingleConstantExpression(expr) || expr->is<StructNew>() || expr->is<ArrayNew>() || expr->is<ArrayNewFixed>() || expr->is<I31New>() || @@ -43,6 +45,12 @@ static bool isValidInConstantExpression(Module& wasm, Expression* expr) { return true; } + if (auto* refAs = expr->dynCast<RefAs>()) { + if (refAs->op == ExternExternalize || refAs->op == ExternInternalize) { + return true; + } + } + if (auto* get = expr->dynCast<GlobalGet>()) { auto* g = wasm.getGlobalOrNull(get->name); // This is called from the validator, so we have to handle non-existent |