From 958ff4115e542ef1d0ae712f4961e342386efe54 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 16 Aug 2024 12:53:52 -0700 Subject: Implement table.init (#6827) Also use TableInit in the interpreter to initialize module's table state, which will now handle traps properly, fixing #6431 --- src/parser/parsers.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/parser/parsers.h') diff --git a/src/parser/parsers.h b/src/parser/parsers.h index 23286bb28..85a1febb5 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -206,6 +206,8 @@ Result<> makeTableFill(Ctx&, Index, const std::vector&); template Result<> makeTableCopy(Ctx&, Index, const std::vector&); template +Result<> makeTableInit(Ctx&, Index, const std::vector&); +template Result<> makeThrow(Ctx&, Index, const std::vector&); template Result<> makeRethrow(Ctx&, Index, const std::vector&); @@ -2067,6 +2069,16 @@ makeTableCopy(Ctx& ctx, Index pos, const std::vector& annotations) { pos, annotations, destTable.getPtr(), srcTable.getPtr()); } +template +Result<> +makeTableInit(Ctx& ctx, Index pos, const std::vector& annotations) { + auto table = maybeTableidx(ctx); + CHECK_ERR(table); + auto elem = elemidx(ctx); + CHECK_ERR(elem); + return ctx.makeTableInit(pos, annotations, table.getPtr(), *elem); +} + template Result<> makeThrow(Ctx& ctx, Index pos, const std::vector& annotations) { -- cgit v1.2.3