From 8ba4f9c30b05674f6b5cfb3f4af4de5bc8710453 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 29 Aug 2024 21:24:14 +0200 Subject: [PATCH] wasm gc: fix issue with function numbering in disassembler --- .../backend/wasm/disasm/Disassembler.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/wasm/disasm/Disassembler.java b/core/src/main/java/org/teavm/backend/wasm/disasm/Disassembler.java index cdc493f2c..a3e4ec02c 100644 --- a/core/src/main/java/org/teavm/backend/wasm/disasm/Disassembler.java +++ b/core/src/main/java/org/teavm/backend/wasm/disasm/Disassembler.java @@ -85,15 +85,18 @@ public final class Disassembler { }; } - public Consumer getSectionConsumer(int code, int pos, NameProvider nameProvider) { - var importListener = new ImportSectionListener() { - int count; + ImportListenerImpl importListener = new ImportListenerImpl(); - @Override - public void function(int typeIndex) { - ++count; - } - }; + static class ImportListenerImpl implements ImportSectionListener { + int count; + + @Override + public void function(int typeIndex) { + ++count; + } + } + + public Consumer getSectionConsumer(int code, int pos, NameProvider nameProvider) { if (code == 1) { return bytes -> { writer.write("(; type section size: " + bytes.length + " ;)").eol();