diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2021-04-05 12:38:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 12:38:16 -0700 |
commit | 3c79f17a7dadb396f955f0912858c3230ed8e10e (patch) | |
tree | d0d997d0c68a6f1b2c4f76557c002d8a7b828169 /src/shared-validator.cc | |
parent | 15a5156b05981c16ba181fae0e35c50418f86df0 (diff) | |
download | wabt-3c79f17a7dadb396f955f0912858c3230ed8e10e.tar.gz wabt-3c79f17a7dadb396f955f0912858c3230ed8e10e.tar.bz2 wabt-3c79f17a7dadb396f955f0912858c3230ed8e10e.zip |
Memory64: support 64-bit data init-expr (#1656)
Diffstat (limited to 'src/shared-validator.cc')
-rw-r--r-- | src/shared-validator.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 354c8e93..9c62bf0f 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -371,7 +371,9 @@ Result SharedValidator::OnDataSegment(const Location& loc, Result SharedValidator::OnDataSegmentInitExpr_Const(const Location& loc, Type type) { - return CheckType(loc, type, Type::I32, "data segment offset"); + auto required = + memories_.empty() ? Type(Type::I32) : memories_[0].limits.IndexType(); + return CheckType(loc, type, required, "data segment offset"); } Result SharedValidator::OnDataSegmentInitExpr_GlobalGet(const Location& loc, @@ -385,14 +387,16 @@ Result SharedValidator::OnDataSegmentInitExpr_GlobalGet(const Location& loc, loc, "initializer expression cannot reference a mutable global"); } - result |= CheckType(loc, ref_global.type, Type::I32, "data segment offset"); + auto required = + memories_.empty() ? Type(Type::I32) : memories_[0].limits.IndexType(); + result |= CheckType(loc, ref_global.type, required, "data segment offset"); return result; } Result SharedValidator::OnDataSegmentInitExpr_Other(const Location& loc) { return PrintError(loc, "invalid data segment offset, must be a constant " - "expression; either i32.const or " + "expression; either iXX.const or " "global.get."); } |