From d0b17c6a5f5a4f67d10620448718db355a84b413 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Thu, 12 Nov 2020 02:27:27 +0100 Subject: [PATCH] stuff --- .../modules/sections/imprt/ImportSection.java | 43 ----- src/main/java/disassembly/values/WName.java | 39 ----- .../disassembly/InvalidOpCodeException.java | 2 +- .../{ => wasm}/disassembly/WASMOpCode.java | 2 +- .../disassembly/conventions/Assembler.java | 2 +- .../disassembly/conventions/Creator.java | 5 +- .../disassembly/conventions/CustomVector.java | 6 +- .../disassembly/conventions/Vector.java | 8 +- .../disassembly/instructions/Expression.java | 6 +- .../disassembly/instructions/Instr.java | 7 +- .../instructions/InstrFactory.java | 18 +-- .../instructions/InstrSupplier.java | 4 +- .../disassembly/instructions/InstrType.java | 4 +- .../instructions/control/BlockInstr.java | 11 +- .../instructions/control/BlockType.java | 10 +- .../instructions/control/BranchInstr.java | 10 +- .../control/BranchTableInstr.java | 13 +- .../control/CallIndirectInstr.java | 11 +- .../instructions/control/CallInstr.java | 10 +- .../instructions/control/IfElseInstr.java | 10 +- .../instructions/memory/Mem0Instr.java | 8 +- .../instructions/memory/MemArg.java | 8 +- .../instructions/memory/MemInstr.java | 8 +- .../instructions/misc/SingleByteInstr.java | 6 +- .../numeric/NumericF32ConstInstr.java | 10 +- .../numeric/NumericF64ConstInstr.java | 10 +- .../numeric/NumericI32ConstInstr.java | 10 +- .../numeric/NumericI64ConstInstr.java | 10 +- .../instructions/numeric/NumericInstr.java | 6 +- .../instructions/numeric/TruncSatInstr.java | 10 +- .../variable/GlobalVariableInstr.java | 10 +- .../variable/LocalVariableInstr.java | 10 +- .../{ => wasm}/disassembly/modules/Magic.java | 6 +- .../disassembly/modules/Module.java | 147 ++++++++++++++++-- .../disassembly/modules/Version.java | 6 +- .../disassembly/modules/indices/FuncIdx.java | 19 ++- .../modules/indices/GlobalIdx.java | 8 +- .../disassembly/modules/indices/LabelIdx.java | 8 +- .../disassembly/modules/indices/LocalIdx.java | 8 +- .../disassembly/modules/indices/MemIdx.java | 8 +- .../disassembly/modules/indices/TableIdx.java | 8 +- .../disassembly/modules/indices/TypeIdx.java | 8 +- .../disassembly/modules/sections/Section.java | 8 +- .../modules/sections/SectionSupplier.java | 4 +- .../modules/sections/code/Code.java | 8 +- .../modules/sections/code/CodeSection.java | 10 +- .../modules/sections/code/Func.java | 10 +- .../modules/sections/code/Locals.java | 10 +- .../sections/custom/CustomSection.java | 18 +-- .../sections/custom/CustomSectionFactory.java | 10 +- .../custom/UnImplementedCustomSection.java | 15 +- .../modules/sections/data/Data.java | 12 +- .../modules/sections/data/DataSection.java | 10 +- .../modules/sections/element/Elem.java | 14 +- .../sections/element/ElementSection.java | 10 +- .../modules/sections/export/Export.java | 21 ++- .../modules/sections/export/ExportDesc.java | 14 +- .../sections/export/ExportSection.java | 10 +- .../sections/function/FunctionSection.java | 10 +- .../modules/sections/global/Global.java | 10 +- .../sections/global/GlobalSection.java | 10 +- .../modules/sections/imprt/Import.java | 31 ++-- .../modules/sections/imprt/ImportDesc.java | 14 +- .../modules/sections/imprt/ImportSection.java | 51 ++++++ .../modules/sections/memory/Mem.java | 8 +- .../sections/memory/MemorySection.java | 10 +- .../modules/sections/start/Start.java | 8 +- .../modules/sections/start/StartSection.java | 8 +- .../modules/sections/table/Table.java | 8 +- .../modules/sections/table/TableSection.java | 12 +- .../modules/sections/type/TypeSection.java | 10 +- .../disassembly/types/ElemType.java | 2 +- .../disassembly/types/FuncType.java | 7 +- .../disassembly/types/GlobalType.java | 7 +- .../{ => wasm}/disassembly/types/Limits.java | 8 +- .../{ => wasm}/disassembly/types/MemType.java | 7 +- .../disassembly/types/Mutability.java | 2 +- .../disassembly/types/ResultType.java | 9 +- .../disassembly/types/TableType.java | 7 +- .../{ => wasm}/disassembly/types/ValType.java | 4 +- .../{ => wasm}/disassembly/values/WByte.java | 5 +- .../disassembly/values/WDouble.java | 2 +- .../{ => wasm}/disassembly/values/WFloat.java | 3 +- .../java/wasm/disassembly/values/WName.java | 25 +++ .../disassembly/values/WSignedInt.java | 4 +- .../disassembly/values/WSignedLong.java | 6 +- .../disassembly/values/WUnsignedInt.java | 4 +- .../disassembly/values/WUnsignedLong.java | 6 +- 88 files changed, 555 insertions(+), 480 deletions(-) delete mode 100644 src/main/java/disassembly/modules/sections/imprt/ImportSection.java delete mode 100644 src/main/java/disassembly/values/WName.java rename src/main/java/{ => wasm}/disassembly/InvalidOpCodeException.java (84%) rename src/main/java/{ => wasm}/disassembly/WASMOpCode.java (85%) rename src/main/java/{ => wasm}/disassembly/conventions/Assembler.java (80%) rename src/main/java/{ => wasm}/disassembly/conventions/Creator.java (63%) rename src/main/java/{ => wasm}/disassembly/conventions/CustomVector.java (89%) rename src/main/java/{ => wasm}/disassembly/conventions/Vector.java (85%) rename src/main/java/{ => wasm}/disassembly/instructions/Expression.java (89%) rename src/main/java/{ => wasm}/disassembly/instructions/Instr.java (82%) rename src/main/java/{ => wasm}/disassembly/instructions/InstrFactory.java (85%) rename src/main/java/{ => wasm}/disassembly/instructions/InstrSupplier.java (69%) rename src/main/java/{ => wasm}/disassembly/instructions/InstrType.java (98%) rename src/main/java/{ => wasm}/disassembly/instructions/control/BlockInstr.java (86%) rename src/main/java/{ => wasm}/disassembly/instructions/control/BlockType.java (87%) rename src/main/java/{ => wasm}/disassembly/instructions/control/BranchInstr.java (77%) rename src/main/java/{ => wasm}/disassembly/instructions/control/BranchTableInstr.java (79%) rename src/main/java/{ => wasm}/disassembly/instructions/control/CallIndirectInstr.java (79%) rename src/main/java/{ => wasm}/disassembly/instructions/control/CallInstr.java (76%) rename src/main/java/{ => wasm}/disassembly/instructions/control/IfElseInstr.java (90%) rename src/main/java/{ => wasm}/disassembly/instructions/memory/Mem0Instr.java (73%) rename src/main/java/{ => wasm}/disassembly/instructions/memory/MemArg.java (84%) rename src/main/java/{ => wasm}/disassembly/instructions/memory/MemInstr.java (80%) rename src/main/java/{ => wasm}/disassembly/instructions/misc/SingleByteInstr.java (72%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/NumericF32ConstInstr.java (78%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/NumericF64ConstInstr.java (78%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/NumericI32ConstInstr.java (78%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/NumericI64ConstInstr.java (78%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/NumericInstr.java (71%) rename src/main/java/{ => wasm}/disassembly/instructions/numeric/TruncSatInstr.java (79%) rename src/main/java/{ => wasm}/disassembly/instructions/variable/GlobalVariableInstr.java (78%) rename src/main/java/{ => wasm}/disassembly/instructions/variable/LocalVariableInstr.java (77%) rename src/main/java/{ => wasm}/disassembly/modules/Magic.java (85%) rename src/main/java/{ => wasm}/disassembly/modules/Module.java (59%) rename src/main/java/{ => wasm}/disassembly/modules/Version.java (85%) rename src/main/java/{ => wasm}/disassembly/modules/indices/FuncIdx.java (59%) rename src/main/java/{ => wasm}/disassembly/modules/indices/GlobalIdx.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/indices/LabelIdx.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/indices/LocalIdx.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/indices/MemIdx.java (77%) rename src/main/java/{ => wasm}/disassembly/modules/indices/TableIdx.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/indices/TypeIdx.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/sections/Section.java (87%) rename src/main/java/{ => wasm}/disassembly/modules/sections/SectionSupplier.java (67%) rename src/main/java/{ => wasm}/disassembly/modules/sections/code/Code.java (84%) rename src/main/java/{ => wasm}/disassembly/modules/sections/code/CodeSection.java (80%) rename src/main/java/{ => wasm}/disassembly/modules/sections/code/Func.java (83%) rename src/main/java/{ => wasm}/disassembly/modules/sections/code/Locals.java (82%) rename src/main/java/{ => wasm}/disassembly/modules/sections/custom/CustomSection.java (58%) rename src/main/java/{ => wasm}/disassembly/modules/sections/custom/CustomSectionFactory.java (62%) rename src/main/java/{ => wasm}/disassembly/modules/sections/custom/UnImplementedCustomSection.java (60%) rename src/main/java/{ => wasm}/disassembly/modules/sections/data/Data.java (83%) rename src/main/java/{ => wasm}/disassembly/modules/sections/data/DataSection.java (80%) rename src/main/java/{ => wasm}/disassembly/modules/sections/element/Elem.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/element/ElementSection.java (81%) rename src/main/java/{ => wasm}/disassembly/modules/sections/export/Export.java (66%) rename src/main/java/{ => wasm}/disassembly/modules/sections/export/ExportDesc.java (83%) rename src/main/java/{ => wasm}/disassembly/modules/sections/export/ExportSection.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/function/FunctionSection.java (80%) rename src/main/java/{ => wasm}/disassembly/modules/sections/global/Global.java (82%) rename src/main/java/{ => wasm}/disassembly/modules/sections/global/GlobalSection.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/imprt/Import.java (61%) rename src/main/java/{ => wasm}/disassembly/modules/sections/imprt/ImportDesc.java (84%) create mode 100644 src/main/java/wasm/disassembly/modules/sections/imprt/ImportSection.java rename src/main/java/{ => wasm}/disassembly/modules/sections/memory/Mem.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/memory/MemorySection.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/start/Start.java (78%) rename src/main/java/{ => wasm}/disassembly/modules/sections/start/StartSection.java (80%) rename src/main/java/{ => wasm}/disassembly/modules/sections/table/Table.java (79%) rename src/main/java/{ => wasm}/disassembly/modules/sections/table/TableSection.java (74%) rename src/main/java/{ => wasm}/disassembly/modules/sections/type/TypeSection.java (81%) rename src/main/java/{ => wasm}/disassembly/types/ElemType.java (93%) rename src/main/java/{ => wasm}/disassembly/types/FuncType.java (90%) rename src/main/java/{ => wasm}/disassembly/types/GlobalType.java (88%) rename src/main/java/{ => wasm}/disassembly/types/Limits.java (89%) rename src/main/java/{ => wasm}/disassembly/types/MemType.java (83%) rename src/main/java/{ => wasm}/disassembly/types/Mutability.java (93%) rename src/main/java/{ => wasm}/disassembly/types/ResultType.java (86%) rename src/main/java/{ => wasm}/disassembly/types/TableType.java (89%) rename src/main/java/{ => wasm}/disassembly/types/ValType.java (89%) rename src/main/java/{ => wasm}/disassembly/values/WByte.java (85%) rename src/main/java/{ => wasm}/disassembly/values/WDouble.java (94%) rename src/main/java/{ => wasm}/disassembly/values/WFloat.java (90%) create mode 100644 src/main/java/wasm/disassembly/values/WName.java rename src/main/java/{ => wasm}/disassembly/values/WSignedInt.java (95%) rename src/main/java/{ => wasm}/disassembly/values/WSignedLong.java (92%) rename src/main/java/{ => wasm}/disassembly/values/WUnsignedInt.java (93%) rename src/main/java/{ => wasm}/disassembly/values/WUnsignedLong.java (92%) diff --git a/src/main/java/disassembly/modules/sections/imprt/ImportSection.java b/src/main/java/disassembly/modules/sections/imprt/ImportSection.java deleted file mode 100644 index cf5895d..0000000 --- a/src/main/java/disassembly/modules/sections/imprt/ImportSection.java +++ /dev/null @@ -1,43 +0,0 @@ -package disassembly.modules.sections.imprt; - -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -public class ImportSection extends Section { - - public static final int IMPORT_SECTION_ID = 2; - - private Vector functionTypes; - - - public ImportSection(BufferedInputStream in) throws IOException, InvalidOpCodeException { - super(in, IMPORT_SECTION_ID); - functionTypes = new Vector<>(in, Import::new); - } - - public ImportSection(List functionTypes) { - super(IMPORT_SECTION_ID); - this.functionTypes = new Vector<>(functionTypes); - } - - @Override - protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException { - functionTypes.assemble(out); - } - - public List getFunctionTypes() { - return functionTypes.getElements(); - } - - public void setFunctionTypes(List functionTypes) { - this.functionTypes = new Vector<>(functionTypes); - } -} diff --git a/src/main/java/disassembly/values/WName.java b/src/main/java/disassembly/values/WName.java deleted file mode 100644 index b32547f..0000000 --- a/src/main/java/disassembly/values/WName.java +++ /dev/null @@ -1,39 +0,0 @@ -package disassembly.values; - -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; - -public class WName extends WASMOpCode { - - private String value; - - public WName(BufferedInputStream in) throws IOException, InvalidOpCodeException { - long length = WUnsignedInt.read(in, 32); - byte[] arr = new byte[(int)length]; - in.read(arr); - value = new String(arr, StandardCharsets.UTF_8); - } - - public WName(String value) { - this.value = value; - } - - public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { - byte[] bytes = value.getBytes(StandardCharsets.UTF_8); - WUnsignedInt.write(bytes.length, out, 32); - out.write(bytes); - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/src/main/java/disassembly/InvalidOpCodeException.java b/src/main/java/wasm/disassembly/InvalidOpCodeException.java similarity index 84% rename from src/main/java/disassembly/InvalidOpCodeException.java rename to src/main/java/wasm/disassembly/InvalidOpCodeException.java index 1dfb4d6..e2b0a17 100644 --- a/src/main/java/disassembly/InvalidOpCodeException.java +++ b/src/main/java/wasm/disassembly/InvalidOpCodeException.java @@ -1,4 +1,4 @@ -package disassembly; +package wasm.disassembly; public class InvalidOpCodeException extends Exception { diff --git a/src/main/java/disassembly/WASMOpCode.java b/src/main/java/wasm/disassembly/WASMOpCode.java similarity index 85% rename from src/main/java/disassembly/WASMOpCode.java rename to src/main/java/wasm/disassembly/WASMOpCode.java index ad0be3d..686f71b 100644 --- a/src/main/java/disassembly/WASMOpCode.java +++ b/src/main/java/wasm/disassembly/WASMOpCode.java @@ -1,4 +1,4 @@ -package disassembly; +package wasm.disassembly; import java.io.*; diff --git a/src/main/java/disassembly/conventions/Assembler.java b/src/main/java/wasm/disassembly/conventions/Assembler.java similarity index 80% rename from src/main/java/disassembly/conventions/Assembler.java rename to src/main/java/wasm/disassembly/conventions/Assembler.java index fcf2f47..a340ff2 100644 --- a/src/main/java/disassembly/conventions/Assembler.java +++ b/src/main/java/wasm/disassembly/conventions/Assembler.java @@ -1,4 +1,4 @@ -package disassembly.conventions; +package wasm.disassembly.conventions; import java.io.IOException; import java.io.OutputStream; diff --git a/src/main/java/disassembly/conventions/Creator.java b/src/main/java/wasm/disassembly/conventions/Creator.java similarity index 63% rename from src/main/java/disassembly/conventions/Creator.java rename to src/main/java/wasm/disassembly/conventions/Creator.java index 4fb45cf..761171a 100644 --- a/src/main/java/disassembly/conventions/Creator.java +++ b/src/main/java/wasm/disassembly/conventions/Creator.java @@ -1,10 +1,9 @@ -package disassembly.conventions; +package wasm.disassembly.conventions; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; public interface Creator { diff --git a/src/main/java/disassembly/conventions/CustomVector.java b/src/main/java/wasm/disassembly/conventions/CustomVector.java similarity index 89% rename from src/main/java/disassembly/conventions/CustomVector.java rename to src/main/java/wasm/disassembly/conventions/CustomVector.java index 969d3d3..3fdd548 100644 --- a/src/main/java/disassembly/conventions/CustomVector.java +++ b/src/main/java/wasm/disassembly/conventions/CustomVector.java @@ -1,7 +1,7 @@ -package disassembly.conventions; +package wasm.disassembly.conventions; -import disassembly.InvalidOpCodeException; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/conventions/Vector.java b/src/main/java/wasm/disassembly/conventions/Vector.java similarity index 85% rename from src/main/java/disassembly/conventions/Vector.java rename to src/main/java/wasm/disassembly/conventions/Vector.java index 9fe844a..33bd12b 100644 --- a/src/main/java/disassembly/conventions/Vector.java +++ b/src/main/java/wasm/disassembly/conventions/Vector.java @@ -1,8 +1,8 @@ -package disassembly.conventions; +package wasm.disassembly.conventions; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/Expression.java b/src/main/java/wasm/disassembly/instructions/Expression.java similarity index 89% rename from src/main/java/disassembly/instructions/Expression.java rename to src/main/java/wasm/disassembly/instructions/Expression.java index 906060c..ecbf34a 100644 --- a/src/main/java/disassembly/instructions/Expression.java +++ b/src/main/java/wasm/disassembly/instructions/Expression.java @@ -1,7 +1,7 @@ -package disassembly.instructions; +package wasm.disassembly.instructions; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/Instr.java b/src/main/java/wasm/disassembly/instructions/Instr.java similarity index 82% rename from src/main/java/disassembly/instructions/Instr.java rename to src/main/java/wasm/disassembly/instructions/Instr.java index c12f848..30aedd7 100644 --- a/src/main/java/disassembly/instructions/Instr.java +++ b/src/main/java/wasm/disassembly/instructions/Instr.java @@ -1,9 +1,8 @@ -package disassembly.instructions; +package wasm.disassembly.instructions; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; -import java.io.BufferedInputStream; import java.io.IOException; import java.io.OutputStream; diff --git a/src/main/java/disassembly/instructions/InstrFactory.java b/src/main/java/wasm/disassembly/instructions/InstrFactory.java similarity index 85% rename from src/main/java/disassembly/instructions/InstrFactory.java rename to src/main/java/wasm/disassembly/instructions/InstrFactory.java index c586620..8e6dfae 100644 --- a/src/main/java/disassembly/instructions/InstrFactory.java +++ b/src/main/java/wasm/disassembly/instructions/InstrFactory.java @@ -1,13 +1,13 @@ -package disassembly.instructions; +package wasm.disassembly.instructions; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.control.*; -import disassembly.instructions.memory.Mem0Instr; -import disassembly.instructions.memory.MemInstr; -import disassembly.instructions.misc.SingleByteInstr; -import disassembly.instructions.numeric.*; -import disassembly.instructions.variable.GlobalVariableInstr; -import disassembly.instructions.variable.LocalVariableInstr; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.control.*; +import wasm.disassembly.instructions.memory.Mem0Instr; +import wasm.disassembly.instructions.memory.MemInstr; +import wasm.disassembly.instructions.misc.SingleByteInstr; +import wasm.disassembly.instructions.numeric.*; +import wasm.disassembly.instructions.variable.GlobalVariableInstr; +import wasm.disassembly.instructions.variable.LocalVariableInstr; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/InstrSupplier.java b/src/main/java/wasm/disassembly/instructions/InstrSupplier.java similarity index 69% rename from src/main/java/disassembly/instructions/InstrSupplier.java rename to src/main/java/wasm/disassembly/instructions/InstrSupplier.java index 44881f2..2a8a135 100644 --- a/src/main/java/disassembly/instructions/InstrSupplier.java +++ b/src/main/java/wasm/disassembly/instructions/InstrSupplier.java @@ -1,6 +1,6 @@ -package disassembly.instructions; +package wasm.disassembly.instructions; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/InstrType.java b/src/main/java/wasm/disassembly/instructions/InstrType.java similarity index 98% rename from src/main/java/disassembly/instructions/InstrType.java rename to src/main/java/wasm/disassembly/instructions/InstrType.java index 2b34dda..da1e0a0 100644 --- a/src/main/java/disassembly/instructions/InstrType.java +++ b/src/main/java/wasm/disassembly/instructions/InstrType.java @@ -1,6 +1,4 @@ -package disassembly.instructions; - -import disassembly.types.ElemType; +package wasm.disassembly.instructions; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/disassembly/instructions/control/BlockInstr.java b/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java similarity index 86% rename from src/main/java/disassembly/instructions/control/BlockInstr.java rename to src/main/java/wasm/disassembly/instructions/control/BlockInstr.java index f9dfffc..9f3caba 100644 --- a/src/main/java/disassembly/instructions/control/BlockInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/BlockInstr.java @@ -1,10 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrFactory; -import disassembly.instructions.InstrType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrFactory; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/BlockType.java b/src/main/java/wasm/disassembly/instructions/control/BlockType.java similarity index 87% rename from src/main/java/disassembly/instructions/control/BlockType.java rename to src/main/java/wasm/disassembly/instructions/control/BlockType.java index 54049ff..b8058b9 100644 --- a/src/main/java/disassembly/instructions/control/BlockType.java +++ b/src/main/java/wasm/disassembly/instructions/control/BlockType.java @@ -1,9 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.types.ValType; -import disassembly.values.WSignedLong; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.types.ValType; +import wasm.disassembly.values.WSignedLong; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/BranchInstr.java b/src/main/java/wasm/disassembly/instructions/control/BranchInstr.java similarity index 77% rename from src/main/java/disassembly/instructions/control/BranchInstr.java rename to src/main/java/wasm/disassembly/instructions/control/BranchInstr.java index c13292b..2a4438d 100644 --- a/src/main/java/disassembly/instructions/control/BranchInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/BranchInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.LabelIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.LabelIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/BranchTableInstr.java b/src/main/java/wasm/disassembly/instructions/control/BranchTableInstr.java similarity index 79% rename from src/main/java/disassembly/instructions/control/BranchTableInstr.java rename to src/main/java/wasm/disassembly/instructions/control/BranchTableInstr.java index 4a5d0d1..b266075 100644 --- a/src/main/java/disassembly/instructions/control/BranchTableInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/BranchTableInstr.java @@ -1,11 +1,10 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.conventions.Creator; -import disassembly.conventions.Vector; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.LabelIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.LabelIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/CallIndirectInstr.java b/src/main/java/wasm/disassembly/instructions/control/CallIndirectInstr.java similarity index 79% rename from src/main/java/disassembly/instructions/control/CallIndirectInstr.java rename to src/main/java/wasm/disassembly/instructions/control/CallIndirectInstr.java index 8f66678..78dd091 100644 --- a/src/main/java/disassembly/instructions/control/CallIndirectInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/CallIndirectInstr.java @@ -1,10 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.FuncIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.FuncIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/CallInstr.java b/src/main/java/wasm/disassembly/instructions/control/CallInstr.java similarity index 76% rename from src/main/java/disassembly/instructions/control/CallInstr.java rename to src/main/java/wasm/disassembly/instructions/control/CallInstr.java index 40898b6..2253a35 100644 --- a/src/main/java/disassembly/instructions/control/CallInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/CallInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.FuncIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.FuncIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/control/IfElseInstr.java b/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java similarity index 90% rename from src/main/java/disassembly/instructions/control/IfElseInstr.java rename to src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java index e8aa85d..150f730 100644 --- a/src/main/java/disassembly/instructions/control/IfElseInstr.java +++ b/src/main/java/wasm/disassembly/instructions/control/IfElseInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.control; +package wasm.disassembly.instructions.control; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrFactory; -import disassembly.instructions.InstrType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrFactory; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/memory/Mem0Instr.java b/src/main/java/wasm/disassembly/instructions/memory/Mem0Instr.java similarity index 73% rename from src/main/java/disassembly/instructions/memory/Mem0Instr.java rename to src/main/java/wasm/disassembly/instructions/memory/Mem0Instr.java index ab95830..ca444b2 100644 --- a/src/main/java/disassembly/instructions/memory/Mem0Instr.java +++ b/src/main/java/wasm/disassembly/instructions/memory/Mem0Instr.java @@ -1,8 +1,8 @@ -package disassembly.instructions.memory; +package wasm.disassembly.instructions.memory; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/memory/MemArg.java b/src/main/java/wasm/disassembly/instructions/memory/MemArg.java similarity index 84% rename from src/main/java/disassembly/instructions/memory/MemArg.java rename to src/main/java/wasm/disassembly/instructions/memory/MemArg.java index 8e745e1..02d8fcd 100644 --- a/src/main/java/disassembly/instructions/memory/MemArg.java +++ b/src/main/java/wasm/disassembly/instructions/memory/MemArg.java @@ -1,8 +1,8 @@ -package disassembly.instructions.memory; +package wasm.disassembly.instructions.memory; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/memory/MemInstr.java b/src/main/java/wasm/disassembly/instructions/memory/MemInstr.java similarity index 80% rename from src/main/java/disassembly/instructions/memory/MemInstr.java rename to src/main/java/wasm/disassembly/instructions/memory/MemInstr.java index 4505fda..9a992c6 100644 --- a/src/main/java/disassembly/instructions/memory/MemInstr.java +++ b/src/main/java/wasm/disassembly/instructions/memory/MemInstr.java @@ -1,8 +1,8 @@ -package disassembly.instructions.memory; +package wasm.disassembly.instructions.memory; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/misc/SingleByteInstr.java b/src/main/java/wasm/disassembly/instructions/misc/SingleByteInstr.java similarity index 72% rename from src/main/java/disassembly/instructions/misc/SingleByteInstr.java rename to src/main/java/wasm/disassembly/instructions/misc/SingleByteInstr.java index 5f266f7..02f3e9d 100644 --- a/src/main/java/disassembly/instructions/misc/SingleByteInstr.java +++ b/src/main/java/wasm/disassembly/instructions/misc/SingleByteInstr.java @@ -1,7 +1,7 @@ -package disassembly.instructions.misc; +package wasm.disassembly.instructions.misc; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/NumericF32ConstInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/NumericF32ConstInstr.java similarity index 78% rename from src/main/java/disassembly/instructions/numeric/NumericF32ConstInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/NumericF32ConstInstr.java index 5a53f3c..6b71935 100644 --- a/src/main/java/disassembly/instructions/numeric/NumericF32ConstInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/NumericF32ConstInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.values.WFloat; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.values.WFloat; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/NumericF64ConstInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/NumericF64ConstInstr.java similarity index 78% rename from src/main/java/disassembly/instructions/numeric/NumericF64ConstInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/NumericF64ConstInstr.java index c9612e3..135630f 100644 --- a/src/main/java/disassembly/instructions/numeric/NumericF64ConstInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/NumericF64ConstInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.values.WDouble; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.values.WDouble; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/NumericI32ConstInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/NumericI32ConstInstr.java similarity index 78% rename from src/main/java/disassembly/instructions/numeric/NumericI32ConstInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/NumericI32ConstInstr.java index 70ad9bd..b15fb8b 100644 --- a/src/main/java/disassembly/instructions/numeric/NumericI32ConstInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/NumericI32ConstInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.values.WSignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.values.WSignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/NumericI64ConstInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/NumericI64ConstInstr.java similarity index 78% rename from src/main/java/disassembly/instructions/numeric/NumericI64ConstInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/NumericI64ConstInstr.java index 171ac1d..761d5ae 100644 --- a/src/main/java/disassembly/instructions/numeric/NumericI64ConstInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/NumericI64ConstInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.values.WSignedLong; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.values.WSignedLong; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/NumericInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/NumericInstr.java similarity index 71% rename from src/main/java/disassembly/instructions/numeric/NumericInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/NumericInstr.java index 613bada..c921a99 100644 --- a/src/main/java/disassembly/instructions/numeric/NumericInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/NumericInstr.java @@ -1,7 +1,7 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/numeric/TruncSatInstr.java b/src/main/java/wasm/disassembly/instructions/numeric/TruncSatInstr.java similarity index 79% rename from src/main/java/disassembly/instructions/numeric/TruncSatInstr.java rename to src/main/java/wasm/disassembly/instructions/numeric/TruncSatInstr.java index 9c5ed7a..3da20fa 100644 --- a/src/main/java/disassembly/instructions/numeric/TruncSatInstr.java +++ b/src/main/java/wasm/disassembly/instructions/numeric/TruncSatInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.numeric; +package wasm.disassembly.instructions.numeric; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/variable/GlobalVariableInstr.java b/src/main/java/wasm/disassembly/instructions/variable/GlobalVariableInstr.java similarity index 78% rename from src/main/java/disassembly/instructions/variable/GlobalVariableInstr.java rename to src/main/java/wasm/disassembly/instructions/variable/GlobalVariableInstr.java index 19d15bd..f75751f 100644 --- a/src/main/java/disassembly/instructions/variable/GlobalVariableInstr.java +++ b/src/main/java/wasm/disassembly/instructions/variable/GlobalVariableInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.variable; +package wasm.disassembly.instructions.variable; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.GlobalIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.GlobalIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/instructions/variable/LocalVariableInstr.java b/src/main/java/wasm/disassembly/instructions/variable/LocalVariableInstr.java similarity index 77% rename from src/main/java/disassembly/instructions/variable/LocalVariableInstr.java rename to src/main/java/wasm/disassembly/instructions/variable/LocalVariableInstr.java index 24d8021..dacfff7 100644 --- a/src/main/java/disassembly/instructions/variable/LocalVariableInstr.java +++ b/src/main/java/wasm/disassembly/instructions/variable/LocalVariableInstr.java @@ -1,9 +1,9 @@ -package disassembly.instructions.variable; +package wasm.disassembly.instructions.variable; -import disassembly.InvalidOpCodeException; -import disassembly.instructions.Instr; -import disassembly.instructions.InstrType; -import disassembly.modules.indices.LocalIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.instructions.Instr; +import wasm.disassembly.instructions.InstrType; +import wasm.disassembly.modules.indices.LocalIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/Magic.java b/src/main/java/wasm/disassembly/modules/Magic.java similarity index 85% rename from src/main/java/disassembly/modules/Magic.java rename to src/main/java/wasm/disassembly/modules/Magic.java index 8681f85..5fcc8ea 100644 --- a/src/main/java/disassembly/modules/Magic.java +++ b/src/main/java/wasm/disassembly/modules/Magic.java @@ -1,7 +1,7 @@ -package disassembly.modules; +package wasm.disassembly.modules; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/Module.java b/src/main/java/wasm/disassembly/modules/Module.java similarity index 59% rename from src/main/java/disassembly/modules/Module.java rename to src/main/java/wasm/disassembly/modules/Module.java index 1013806..028a6db 100644 --- a/src/main/java/disassembly/modules/Module.java +++ b/src/main/java/wasm/disassembly/modules/Module.java @@ -1,21 +1,21 @@ -package disassembly.modules; +package wasm.disassembly.modules; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.sections.Section; -import disassembly.modules.sections.code.CodeSection; -import disassembly.modules.sections.custom.CustomSection; -import disassembly.modules.sections.custom.CustomSectionFactory; -import disassembly.modules.sections.data.DataSection; -import disassembly.modules.sections.element.ElementSection; -import disassembly.modules.sections.export.ExportSection; -import disassembly.modules.sections.function.FunctionSection; -import disassembly.modules.sections.global.GlobalSection; -import disassembly.modules.sections.imprt.ImportSection; -import disassembly.modules.sections.memory.MemorySection; -import disassembly.modules.sections.start.StartSection; -import disassembly.modules.sections.table.TableSection; -import disassembly.modules.sections.type.TypeSection; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.modules.sections.Section; +import wasm.disassembly.modules.sections.code.CodeSection; +import wasm.disassembly.modules.sections.custom.CustomSection; +import wasm.disassembly.modules.sections.custom.CustomSectionFactory; +import wasm.disassembly.modules.sections.data.DataSection; +import wasm.disassembly.modules.sections.element.ElementSection; +import wasm.disassembly.modules.sections.export.ExportSection; +import wasm.disassembly.modules.sections.function.FunctionSection; +import wasm.disassembly.modules.sections.global.GlobalSection; +import wasm.disassembly.modules.sections.imprt.ImportSection; +import wasm.disassembly.modules.sections.memory.MemorySection; +import wasm.disassembly.modules.sections.start.StartSection; +import wasm.disassembly.modules.sections.table.TableSection; +import wasm.disassembly.modules.sections.type.TypeSection; import java.io.BufferedInputStream; import java.io.IOException; @@ -143,4 +143,117 @@ public class Module extends WASMOpCode { section.assemble(out); } } + + + public Magic getMagic() { + return magic; + } + + public void setMagic(Magic magic) { + this.magic = magic; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } + + public TypeSection getTypeSection() { + return typeSection; + } + + public void setTypeSection(TypeSection typeSection) { + this.typeSection = typeSection; + } + + public ImportSection getImportSection() { + return importSection; + } + + public void setImportSection(ImportSection importSection) { + this.importSection = importSection; + } + + public FunctionSection getFunctionSection() { + return functionSection; + } + + public void setFunctionSection(FunctionSection functionSection) { + this.functionSection = functionSection; + } + + public TableSection getTableSection() { + return tableSection; + } + + public void setTableSection(TableSection tableSection) { + this.tableSection = tableSection; + } + + public MemorySection getMemorySection() { + return memorySection; + } + + public void setMemorySection(MemorySection memorySection) { + this.memorySection = memorySection; + } + + public GlobalSection getGlobalSection() { + return globalSection; + } + + public void setGlobalSection(GlobalSection globalSection) { + this.globalSection = globalSection; + } + + public ExportSection getExportSection() { + return exportSection; + } + + public void setExportSection(ExportSection exportSection) { + this.exportSection = exportSection; + } + + public StartSection getStartSection() { + return startSection; + } + + public void setStartSection(StartSection startSection) { + this.startSection = startSection; + } + + public ElementSection getElementSection() { + return elementSection; + } + + public void setElementSection(ElementSection elementSection) { + this.elementSection = elementSection; + } + + public CodeSection getCodeSection() { + return codeSection; + } + + public void setCodeSection(CodeSection codeSection) { + this.codeSection = codeSection; + } + + public DataSection getDataSection() { + return dataSection; + } + + public void setDataSection(DataSection dataSection) { + this.dataSection = dataSection; + } + + public List> getCustomSectionsList() { + return customSectionsList; + } + + public void setCustomSectionsList(List> customSectionsList) { + this.customSectionsList = customSectionsList; + } } diff --git a/src/main/java/disassembly/modules/Version.java b/src/main/java/wasm/disassembly/modules/Version.java similarity index 85% rename from src/main/java/disassembly/modules/Version.java rename to src/main/java/wasm/disassembly/modules/Version.java index d3f1dc6..7d01e96 100644 --- a/src/main/java/disassembly/modules/Version.java +++ b/src/main/java/wasm/disassembly/modules/Version.java @@ -1,7 +1,7 @@ -package disassembly.modules; +package wasm.disassembly.modules; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/FuncIdx.java b/src/main/java/wasm/disassembly/modules/indices/FuncIdx.java similarity index 59% rename from src/main/java/disassembly/modules/indices/FuncIdx.java rename to src/main/java/wasm/disassembly/modules/indices/FuncIdx.java index 6c887f8..90cb9d4 100644 --- a/src/main/java/disassembly/modules/indices/FuncIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/FuncIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; @@ -10,6 +10,9 @@ import java.io.OutputStream; public class FuncIdx extends WASMOpCode { + + public static int OFFSET = 0; + private long x; public FuncIdx(BufferedInputStream in) throws IOException, InvalidOpCodeException { @@ -17,19 +20,19 @@ public class FuncIdx extends WASMOpCode { } public FuncIdx(long x) { - this.x = x; + this.x = x - OFFSET; } @Override public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { - WUnsignedInt.write(x, out, 32); + WUnsignedInt.write(x + OFFSET, out, 32); } public long getX() { - return x; + return x + OFFSET; } public void setX(long x) { - this.x = x; + this.x = x - OFFSET; } } diff --git a/src/main/java/disassembly/modules/indices/GlobalIdx.java b/src/main/java/wasm/disassembly/modules/indices/GlobalIdx.java similarity index 78% rename from src/main/java/disassembly/modules/indices/GlobalIdx.java rename to src/main/java/wasm/disassembly/modules/indices/GlobalIdx.java index e0ec6b7..6769733 100644 --- a/src/main/java/disassembly/modules/indices/GlobalIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/GlobalIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/LabelIdx.java b/src/main/java/wasm/disassembly/modules/indices/LabelIdx.java similarity index 78% rename from src/main/java/disassembly/modules/indices/LabelIdx.java rename to src/main/java/wasm/disassembly/modules/indices/LabelIdx.java index 37b86ba..7808d8f 100644 --- a/src/main/java/disassembly/modules/indices/LabelIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/LabelIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/LocalIdx.java b/src/main/java/wasm/disassembly/modules/indices/LocalIdx.java similarity index 78% rename from src/main/java/disassembly/modules/indices/LocalIdx.java rename to src/main/java/wasm/disassembly/modules/indices/LocalIdx.java index 42d4b1f..6abc781 100644 --- a/src/main/java/disassembly/modules/indices/LocalIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/LocalIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/MemIdx.java b/src/main/java/wasm/disassembly/modules/indices/MemIdx.java similarity index 77% rename from src/main/java/disassembly/modules/indices/MemIdx.java rename to src/main/java/wasm/disassembly/modules/indices/MemIdx.java index 2852512..20311d6 100644 --- a/src/main/java/disassembly/modules/indices/MemIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/MemIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/TableIdx.java b/src/main/java/wasm/disassembly/modules/indices/TableIdx.java similarity index 78% rename from src/main/java/disassembly/modules/indices/TableIdx.java rename to src/main/java/wasm/disassembly/modules/indices/TableIdx.java index c86a337..4113c83 100644 --- a/src/main/java/disassembly/modules/indices/TableIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/TableIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/indices/TypeIdx.java b/src/main/java/wasm/disassembly/modules/indices/TypeIdx.java similarity index 78% rename from src/main/java/disassembly/modules/indices/TypeIdx.java rename to src/main/java/wasm/disassembly/modules/indices/TypeIdx.java index df705d2..2358cdf 100644 --- a/src/main/java/disassembly/modules/indices/TypeIdx.java +++ b/src/main/java/wasm/disassembly/modules/indices/TypeIdx.java @@ -1,8 +1,8 @@ -package disassembly.modules.indices; +package wasm.disassembly.modules.indices; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/Section.java b/src/main/java/wasm/disassembly/modules/sections/Section.java similarity index 87% rename from src/main/java/disassembly/modules/sections/Section.java rename to src/main/java/wasm/disassembly/modules/sections/Section.java index 9f6be00..6e014fd 100644 --- a/src/main/java/disassembly/modules/sections/Section.java +++ b/src/main/java/wasm/disassembly/modules/sections/Section.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections; +package wasm.disassembly.modules.sections; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/disassembly/modules/sections/SectionSupplier.java b/src/main/java/wasm/disassembly/modules/sections/SectionSupplier.java similarity index 67% rename from src/main/java/disassembly/modules/sections/SectionSupplier.java rename to src/main/java/wasm/disassembly/modules/sections/SectionSupplier.java index 9087164..a1d37e0 100644 --- a/src/main/java/disassembly/modules/sections/SectionSupplier.java +++ b/src/main/java/wasm/disassembly/modules/sections/SectionSupplier.java @@ -1,6 +1,6 @@ -package disassembly.modules.sections; +package wasm.disassembly.modules.sections; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/code/Code.java b/src/main/java/wasm/disassembly/modules/sections/code/Code.java similarity index 84% rename from src/main/java/disassembly/modules/sections/code/Code.java rename to src/main/java/wasm/disassembly/modules/sections/code/Code.java index 8f8a2f8..3de1a53 100644 --- a/src/main/java/disassembly/modules/sections/code/Code.java +++ b/src/main/java/wasm/disassembly/modules/sections/code/Code.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.code; +package wasm.disassembly.modules.sections.code; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/disassembly/modules/sections/code/CodeSection.java b/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java similarity index 80% rename from src/main/java/disassembly/modules/sections/code/CodeSection.java rename to src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java index 09ccc69..e67cb6d 100644 --- a/src/main/java/disassembly/modules/sections/code/CodeSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/code/CodeSection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.code; +package wasm.disassembly.modules.sections.code; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/code/Func.java b/src/main/java/wasm/disassembly/modules/sections/code/Func.java similarity index 83% rename from src/main/java/disassembly/modules/sections/code/Func.java rename to src/main/java/wasm/disassembly/modules/sections/code/Func.java index 59eec64..10f5e4c 100644 --- a/src/main/java/disassembly/modules/sections/code/Func.java +++ b/src/main/java/wasm/disassembly/modules/sections/code/Func.java @@ -1,9 +1,9 @@ -package disassembly.modules.sections.code; +package wasm.disassembly.modules.sections.code; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.instructions.Expression; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.instructions.Expression; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/code/Locals.java b/src/main/java/wasm/disassembly/modules/sections/code/Locals.java similarity index 82% rename from src/main/java/disassembly/modules/sections/code/Locals.java rename to src/main/java/wasm/disassembly/modules/sections/code/Locals.java index 8791080..949dd96 100644 --- a/src/main/java/disassembly/modules/sections/code/Locals.java +++ b/src/main/java/wasm/disassembly/modules/sections/code/Locals.java @@ -1,9 +1,9 @@ -package disassembly.modules.sections.code; +package wasm.disassembly.modules.sections.code; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.types.ValType; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.types.ValType; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/custom/CustomSection.java b/src/main/java/wasm/disassembly/modules/sections/custom/CustomSection.java similarity index 58% rename from src/main/java/disassembly/modules/sections/custom/CustomSection.java rename to src/main/java/wasm/disassembly/modules/sections/custom/CustomSection.java index b4a3410..b555c2b 100644 --- a/src/main/java/disassembly/modules/sections/custom/CustomSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/custom/CustomSection.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.custom; +package wasm.disassembly.modules.sections.custom; -import disassembly.InvalidOpCodeException; -import disassembly.modules.sections.Section; -import disassembly.values.WName; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.modules.sections.Section; +import wasm.disassembly.values.WName; import java.io.IOException; import java.io.OutputStream; @@ -12,26 +12,26 @@ public abstract class CustomSection extends Section { public static final int CUSTOM_SECTION_ID = 0; - private WName name; + private String name; - public CustomSection(long size, WName name) throws IOException, InvalidOpCodeException { + public CustomSection(long size, String name) throws IOException, InvalidOpCodeException { super(CUSTOM_SECTION_ID, size); this.name = name; } @Override protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException { - out.write(name.getValue().getBytes(StandardCharsets.UTF_8)); + WName.write(name, out); assemble3(out); } protected abstract void assemble3(OutputStream out) throws IOException, InvalidOpCodeException; - public WName getName() { + public String getName() { return name; } - public void setName(WName name) { + public void setName(String name) { this.name = name; } } diff --git a/src/main/java/disassembly/modules/sections/custom/CustomSectionFactory.java b/src/main/java/wasm/disassembly/modules/sections/custom/CustomSectionFactory.java similarity index 62% rename from src/main/java/disassembly/modules/sections/custom/CustomSectionFactory.java rename to src/main/java/wasm/disassembly/modules/sections/custom/CustomSectionFactory.java index 6aeb8d1..88eab61 100644 --- a/src/main/java/disassembly/modules/sections/custom/CustomSectionFactory.java +++ b/src/main/java/wasm/disassembly/modules/sections/custom/CustomSectionFactory.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.custom; +package wasm.disassembly.modules.sections.custom; -import disassembly.InvalidOpCodeException; -import disassembly.values.WName; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.values.WName; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; @@ -11,7 +11,7 @@ public class CustomSectionFactory { public static CustomSection get(BufferedInputStream in) throws IOException, InvalidOpCodeException { long size = WUnsignedInt.read(in, 32); - WName name = new WName(in); + String name = WName.read(in); // select implementation diff --git a/src/main/java/disassembly/modules/sections/custom/UnImplementedCustomSection.java b/src/main/java/wasm/disassembly/modules/sections/custom/UnImplementedCustomSection.java similarity index 60% rename from src/main/java/disassembly/modules/sections/custom/UnImplementedCustomSection.java rename to src/main/java/wasm/disassembly/modules/sections/custom/UnImplementedCustomSection.java index a39123b..e086c35 100644 --- a/src/main/java/disassembly/modules/sections/custom/UnImplementedCustomSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/custom/UnImplementedCustomSection.java @@ -1,9 +1,10 @@ -package disassembly.modules.sections.custom; +package wasm.disassembly.modules.sections.custom; -import disassembly.InvalidOpCodeException; -import disassembly.values.WName; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.values.WName; import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; @@ -12,9 +13,13 @@ public class UnImplementedCustomSection extends CustomSection { private byte[] bytes; - public UnImplementedCustomSection(BufferedInputStream in, long size, WName name) throws IOException, InvalidOpCodeException { + public UnImplementedCustomSection(BufferedInputStream in, long size, String name) throws IOException, InvalidOpCodeException { super(size, name); - bytes = new byte[(int)size - name.getValue().getBytes(StandardCharsets.UTF_8).length]; + + ByteArrayOutputStream nameOut = new ByteArrayOutputStream(); + WName.write(name, nameOut); + + bytes = new byte[(int)size - nameOut.toByteArray().length]; in.read(bytes); } diff --git a/src/main/java/disassembly/modules/sections/data/Data.java b/src/main/java/wasm/disassembly/modules/sections/data/Data.java similarity index 83% rename from src/main/java/disassembly/modules/sections/data/Data.java rename to src/main/java/wasm/disassembly/modules/sections/data/Data.java index 60c1db8..1bd68f3 100644 --- a/src/main/java/disassembly/modules/sections/data/Data.java +++ b/src/main/java/wasm/disassembly/modules/sections/data/Data.java @@ -1,10 +1,10 @@ -package disassembly.modules.sections.data; +package wasm.disassembly.modules.sections.data; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.instructions.Expression; -import disassembly.modules.indices.MemIdx; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.instructions.Expression; +import wasm.disassembly.modules.indices.MemIdx; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/data/DataSection.java b/src/main/java/wasm/disassembly/modules/sections/data/DataSection.java similarity index 80% rename from src/main/java/disassembly/modules/sections/data/DataSection.java rename to src/main/java/wasm/disassembly/modules/sections/data/DataSection.java index eddcbbc..c31b81f 100644 --- a/src/main/java/disassembly/modules/sections/data/DataSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/data/DataSection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.data; +package wasm.disassembly.modules.sections.data; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/element/Elem.java b/src/main/java/wasm/disassembly/modules/sections/element/Elem.java similarity index 79% rename from src/main/java/disassembly/modules/sections/element/Elem.java rename to src/main/java/wasm/disassembly/modules/sections/element/Elem.java index fcfefce..eb2277c 100644 --- a/src/main/java/disassembly/modules/sections/element/Elem.java +++ b/src/main/java/wasm/disassembly/modules/sections/element/Elem.java @@ -1,11 +1,11 @@ -package disassembly.modules.sections.element; +package wasm.disassembly.modules.sections.element; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.instructions.Expression; -import disassembly.modules.indices.FuncIdx; -import disassembly.modules.indices.TableIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.instructions.Expression; +import wasm.disassembly.modules.indices.FuncIdx; +import wasm.disassembly.modules.indices.TableIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/element/ElementSection.java b/src/main/java/wasm/disassembly/modules/sections/element/ElementSection.java similarity index 81% rename from src/main/java/disassembly/modules/sections/element/ElementSection.java rename to src/main/java/wasm/disassembly/modules/sections/element/ElementSection.java index 4e08e67..ab5c439 100644 --- a/src/main/java/disassembly/modules/sections/element/ElementSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/element/ElementSection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.element; +package wasm.disassembly.modules.sections.element; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/export/Export.java b/src/main/java/wasm/disassembly/modules/sections/export/Export.java similarity index 66% rename from src/main/java/disassembly/modules/sections/export/Export.java rename to src/main/java/wasm/disassembly/modules/sections/export/Export.java index 00d976d..02c5150 100644 --- a/src/main/java/disassembly/modules/sections/export/Export.java +++ b/src/main/java/wasm/disassembly/modules/sections/export/Export.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.export; +package wasm.disassembly.modules.sections.export; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WName; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WName; import java.io.BufferedInputStream; import java.io.IOException; @@ -10,31 +10,30 @@ import java.io.OutputStream; public class Export extends WASMOpCode { - private WName name; + private String name; private ExportDesc exportDesc; public Export(BufferedInputStream in) throws IOException, InvalidOpCodeException { - name = new WName(in); + name = WName.read(in); exportDesc = new ExportDesc(in); } - public Export(WName name, ExportDesc exportDesc) { + public Export(String name, ExportDesc exportDesc) { this.name = name; this.exportDesc = exportDesc; } @Override public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { - name.assemble(out); + WName.write(name, out); exportDesc.assemble(out); } - - public WName getName() { + public String getName() { return name; } - public void setName(WName name) { + public void setName(String name) { this.name = name; } diff --git a/src/main/java/disassembly/modules/sections/export/ExportDesc.java b/src/main/java/wasm/disassembly/modules/sections/export/ExportDesc.java similarity index 83% rename from src/main/java/disassembly/modules/sections/export/ExportDesc.java rename to src/main/java/wasm/disassembly/modules/sections/export/ExportDesc.java index cfd552e..22210d6 100644 --- a/src/main/java/disassembly/modules/sections/export/ExportDesc.java +++ b/src/main/java/wasm/disassembly/modules/sections/export/ExportDesc.java @@ -1,11 +1,11 @@ -package disassembly.modules.sections.export; +package wasm.disassembly.modules.sections.export; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.indices.FuncIdx; -import disassembly.modules.indices.GlobalIdx; -import disassembly.modules.indices.MemIdx; -import disassembly.modules.indices.TableIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.modules.indices.FuncIdx; +import wasm.disassembly.modules.indices.GlobalIdx; +import wasm.disassembly.modules.indices.MemIdx; +import wasm.disassembly.modules.indices.TableIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/export/ExportSection.java b/src/main/java/wasm/disassembly/modules/sections/export/ExportSection.java similarity index 79% rename from src/main/java/disassembly/modules/sections/export/ExportSection.java rename to src/main/java/wasm/disassembly/modules/sections/export/ExportSection.java index c6595d2..2ebb9b8 100644 --- a/src/main/java/disassembly/modules/sections/export/ExportSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/export/ExportSection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.export; +package wasm.disassembly.modules.sections.export; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/function/FunctionSection.java b/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java similarity index 80% rename from src/main/java/disassembly/modules/sections/function/FunctionSection.java rename to src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java index db129aa..5e41c5f 100644 --- a/src/main/java/disassembly/modules/sections/function/FunctionSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/function/FunctionSection.java @@ -1,9 +1,9 @@ -package disassembly.modules.sections.function; +package wasm.disassembly.modules.sections.function; -import disassembly.InvalidOpCodeException; -import disassembly.conventions.Vector; -import disassembly.modules.indices.TypeIdx; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.indices.TypeIdx; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/global/Global.java b/src/main/java/wasm/disassembly/modules/sections/global/Global.java similarity index 82% rename from src/main/java/disassembly/modules/sections/global/Global.java rename to src/main/java/wasm/disassembly/modules/sections/global/Global.java index b6838fd..66e5656 100644 --- a/src/main/java/disassembly/modules/sections/global/Global.java +++ b/src/main/java/wasm/disassembly/modules/sections/global/Global.java @@ -1,9 +1,9 @@ -package disassembly.modules.sections.global; +package wasm.disassembly.modules.sections.global; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.instructions.Expression; -import disassembly.types.GlobalType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.instructions.Expression; +import wasm.disassembly.types.GlobalType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/global/GlobalSection.java b/src/main/java/wasm/disassembly/modules/sections/global/GlobalSection.java similarity index 79% rename from src/main/java/disassembly/modules/sections/global/GlobalSection.java rename to src/main/java/wasm/disassembly/modules/sections/global/GlobalSection.java index c9dde30..beabe70 100644 --- a/src/main/java/disassembly/modules/sections/global/GlobalSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/global/GlobalSection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.global; +package wasm.disassembly.modules.sections.global; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/imprt/Import.java b/src/main/java/wasm/disassembly/modules/sections/imprt/Import.java similarity index 61% rename from src/main/java/disassembly/modules/sections/imprt/Import.java rename to src/main/java/wasm/disassembly/modules/sections/imprt/Import.java index d6ffc33..5b09888 100644 --- a/src/main/java/disassembly/modules/sections/imprt/Import.java +++ b/src/main/java/wasm/disassembly/modules/sections/imprt/Import.java @@ -1,9 +1,8 @@ -package disassembly.modules.sections.imprt; +package wasm.disassembly.modules.sections.imprt; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.Module; -import disassembly.values.WName; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WName; import java.io.BufferedInputStream; import java.io.IOException; @@ -11,17 +10,17 @@ import java.io.OutputStream; public class Import extends WASMOpCode { - private WName module; - private WName name; + private String module; + private String name; private ImportDesc importDescription; public Import(BufferedInputStream in) throws IOException, InvalidOpCodeException { - module = new WName(in); - name = new WName(in); + module = WName.read(in); + name = WName.read(in); importDescription = new ImportDesc(in); } - public Import(WName module, WName name, ImportDesc importDescription) { + public Import(String module, String name, ImportDesc importDescription) { this.module = module; this.name = name; this.importDescription = importDescription; @@ -29,24 +28,24 @@ public class Import extends WASMOpCode { @Override public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { - module.assemble(out); - name.assemble(out); + WName.write(module, out); + WName.write(name, out); importDescription.assemble(out); } - public WName getModule() { + public String getModule() { return module; } - public void setModule(WName module) { + public void setModule(String module) { this.module = module; } - public WName getName() { + public String getName() { return name; } - public void setName(WName name) { + public void setName(String name) { this.name = name; } diff --git a/src/main/java/disassembly/modules/sections/imprt/ImportDesc.java b/src/main/java/wasm/disassembly/modules/sections/imprt/ImportDesc.java similarity index 84% rename from src/main/java/disassembly/modules/sections/imprt/ImportDesc.java rename to src/main/java/wasm/disassembly/modules/sections/imprt/ImportDesc.java index 33f3e53..a960049 100644 --- a/src/main/java/disassembly/modules/sections/imprt/ImportDesc.java +++ b/src/main/java/wasm/disassembly/modules/sections/imprt/ImportDesc.java @@ -1,11 +1,11 @@ -package disassembly.modules.sections.imprt; +package wasm.disassembly.modules.sections.imprt; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.indices.TypeIdx; -import disassembly.types.GlobalType; -import disassembly.types.MemType; -import disassembly.types.TableType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.modules.indices.TypeIdx; +import wasm.disassembly.types.GlobalType; +import wasm.disassembly.types.MemType; +import wasm.disassembly.types.TableType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/wasm/disassembly/modules/sections/imprt/ImportSection.java b/src/main/java/wasm/disassembly/modules/sections/imprt/ImportSection.java new file mode 100644 index 0000000..59b95b0 --- /dev/null +++ b/src/main/java/wasm/disassembly/modules/sections/imprt/ImportSection.java @@ -0,0 +1,51 @@ +package wasm.disassembly.modules.sections.imprt; + +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.indices.FuncIdx; +import wasm.disassembly.modules.sections.Section; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +public class ImportSection extends Section { + + public static final int IMPORT_SECTION_ID = 2; + + private Vector imports; + + + public ImportSection(BufferedInputStream in) throws IOException, InvalidOpCodeException { + super(in, IMPORT_SECTION_ID); + imports = new Vector<>(in, Import::new); + } + + public ImportSection(List imports) { + super(IMPORT_SECTION_ID); + this.imports = new Vector<>(imports); + } + + @Override + protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException { + imports.assemble(out); + } + + public List getImports() { + return imports.getElements(); + } + + public void setImports(List imports) { + this.imports = new Vector<>(imports); + } + + public void importFunctions(List functions) { + List newImports = new ArrayList<>(functions); + newImports.addAll(imports.getElements()); + + setImports(newImports); + FuncIdx.OFFSET += functions.size(); + } +} diff --git a/src/main/java/disassembly/modules/sections/memory/Mem.java b/src/main/java/wasm/disassembly/modules/sections/memory/Mem.java similarity index 79% rename from src/main/java/disassembly/modules/sections/memory/Mem.java rename to src/main/java/wasm/disassembly/modules/sections/memory/Mem.java index 6948a94..5f02756 100644 --- a/src/main/java/disassembly/modules/sections/memory/Mem.java +++ b/src/main/java/wasm/disassembly/modules/sections/memory/Mem.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.memory; +package wasm.disassembly.modules.sections.memory; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.types.MemType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.types.MemType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/memory/MemorySection.java b/src/main/java/wasm/disassembly/modules/sections/memory/MemorySection.java similarity index 79% rename from src/main/java/disassembly/modules/sections/memory/MemorySection.java rename to src/main/java/wasm/disassembly/modules/sections/memory/MemorySection.java index bd727a7..d279127 100644 --- a/src/main/java/disassembly/modules/sections/memory/MemorySection.java +++ b/src/main/java/wasm/disassembly/modules/sections/memory/MemorySection.java @@ -1,13 +1,11 @@ -package disassembly.modules.sections.memory; +package wasm.disassembly.modules.sections.memory; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/start/Start.java b/src/main/java/wasm/disassembly/modules/sections/start/Start.java similarity index 78% rename from src/main/java/disassembly/modules/sections/start/Start.java rename to src/main/java/wasm/disassembly/modules/sections/start/Start.java index 70aedfb..bdc38b5 100644 --- a/src/main/java/disassembly/modules/sections/start/Start.java +++ b/src/main/java/wasm/disassembly/modules/sections/start/Start.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.start; +package wasm.disassembly.modules.sections.start; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.indices.FuncIdx; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.modules.indices.FuncIdx; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/start/StartSection.java b/src/main/java/wasm/disassembly/modules/sections/start/StartSection.java similarity index 80% rename from src/main/java/disassembly/modules/sections/start/StartSection.java rename to src/main/java/wasm/disassembly/modules/sections/start/StartSection.java index fa4e30d..4b2ec44 100644 --- a/src/main/java/disassembly/modules/sections/start/StartSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/start/StartSection.java @@ -1,12 +1,10 @@ -package disassembly.modules.sections.start; +package wasm.disassembly.modules.sections.start; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.modules.sections.Section; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class StartSection extends Section { diff --git a/src/main/java/disassembly/modules/sections/table/Table.java b/src/main/java/wasm/disassembly/modules/sections/table/Table.java similarity index 79% rename from src/main/java/disassembly/modules/sections/table/Table.java rename to src/main/java/wasm/disassembly/modules/sections/table/Table.java index 61ae4aa..6fff9f8 100644 --- a/src/main/java/disassembly/modules/sections/table/Table.java +++ b/src/main/java/wasm/disassembly/modules/sections/table/Table.java @@ -1,8 +1,8 @@ -package disassembly.modules.sections.table; +package wasm.disassembly.modules.sections.table; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.types.TableType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.types.TableType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/modules/sections/table/TableSection.java b/src/main/java/wasm/disassembly/modules/sections/table/TableSection.java similarity index 74% rename from src/main/java/disassembly/modules/sections/table/TableSection.java rename to src/main/java/wasm/disassembly/modules/sections/table/TableSection.java index ffd2009..c21904c 100644 --- a/src/main/java/disassembly/modules/sections/table/TableSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/table/TableSection.java @@ -1,15 +1,11 @@ -package disassembly.modules.sections.table; +package wasm.disassembly.modules.sections.table; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.Creator; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; -import disassembly.types.TableType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/modules/sections/type/TypeSection.java b/src/main/java/wasm/disassembly/modules/sections/type/TypeSection.java similarity index 81% rename from src/main/java/disassembly/modules/sections/type/TypeSection.java rename to src/main/java/wasm/disassembly/modules/sections/type/TypeSection.java index de44fd7..5b95c37 100644 --- a/src/main/java/disassembly/modules/sections/type/TypeSection.java +++ b/src/main/java/wasm/disassembly/modules/sections/type/TypeSection.java @@ -1,9 +1,9 @@ -package disassembly.modules.sections.type; +package wasm.disassembly.modules.sections.type; -import disassembly.InvalidOpCodeException; -import disassembly.conventions.Vector; -import disassembly.modules.sections.Section; -import disassembly.types.FuncType; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.conventions.Vector; +import wasm.disassembly.modules.sections.Section; +import wasm.disassembly.types.FuncType; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/types/ElemType.java b/src/main/java/wasm/disassembly/types/ElemType.java similarity index 93% rename from src/main/java/disassembly/types/ElemType.java rename to src/main/java/wasm/disassembly/types/ElemType.java index 7366a8d..c337143 100644 --- a/src/main/java/disassembly/types/ElemType.java +++ b/src/main/java/wasm/disassembly/types/ElemType.java @@ -1,4 +1,4 @@ -package disassembly.types; +package wasm.disassembly.types; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/disassembly/types/FuncType.java b/src/main/java/wasm/disassembly/types/FuncType.java similarity index 90% rename from src/main/java/disassembly/types/FuncType.java rename to src/main/java/wasm/disassembly/types/FuncType.java index 79e8207..683c0eb 100644 --- a/src/main/java/disassembly/types/FuncType.java +++ b/src/main/java/wasm/disassembly/types/FuncType.java @@ -1,11 +1,10 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class FuncType extends WASMOpCode { diff --git a/src/main/java/disassembly/types/GlobalType.java b/src/main/java/wasm/disassembly/types/GlobalType.java similarity index 88% rename from src/main/java/disassembly/types/GlobalType.java rename to src/main/java/wasm/disassembly/types/GlobalType.java index 9601150..6571a4f 100644 --- a/src/main/java/disassembly/types/GlobalType.java +++ b/src/main/java/wasm/disassembly/types/GlobalType.java @@ -1,11 +1,10 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class GlobalType extends WASMOpCode { diff --git a/src/main/java/disassembly/types/Limits.java b/src/main/java/wasm/disassembly/types/Limits.java similarity index 89% rename from src/main/java/disassembly/types/Limits.java rename to src/main/java/wasm/disassembly/types/Limits.java index 39096f0..b3b711f 100644 --- a/src/main/java/disassembly/types/Limits.java +++ b/src/main/java/wasm/disassembly/types/Limits.java @@ -1,8 +1,8 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.values.WUnsignedInt; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.values.WUnsignedInt; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/types/MemType.java b/src/main/java/wasm/disassembly/types/MemType.java similarity index 83% rename from src/main/java/disassembly/types/MemType.java rename to src/main/java/wasm/disassembly/types/MemType.java index 055af78..f4af20e 100644 --- a/src/main/java/disassembly/types/MemType.java +++ b/src/main/java/wasm/disassembly/types/MemType.java @@ -1,11 +1,10 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class MemType extends WASMOpCode { diff --git a/src/main/java/disassembly/types/Mutability.java b/src/main/java/wasm/disassembly/types/Mutability.java similarity index 93% rename from src/main/java/disassembly/types/Mutability.java rename to src/main/java/wasm/disassembly/types/Mutability.java index 80d9caa..fe80511 100644 --- a/src/main/java/disassembly/types/Mutability.java +++ b/src/main/java/wasm/disassembly/types/Mutability.java @@ -1,4 +1,4 @@ -package disassembly.types; +package wasm.disassembly.types; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/disassembly/types/ResultType.java b/src/main/java/wasm/disassembly/types/ResultType.java similarity index 86% rename from src/main/java/disassembly/types/ResultType.java rename to src/main/java/wasm/disassembly/types/ResultType.java index 623c00c..2928ece 100644 --- a/src/main/java/disassembly/types/ResultType.java +++ b/src/main/java/wasm/disassembly/types/ResultType.java @@ -1,12 +1,11 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; -import disassembly.conventions.CustomVector; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; +import wasm.disassembly.conventions.CustomVector; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.util.List; diff --git a/src/main/java/disassembly/types/TableType.java b/src/main/java/wasm/disassembly/types/TableType.java similarity index 89% rename from src/main/java/disassembly/types/TableType.java rename to src/main/java/wasm/disassembly/types/TableType.java index c8d872d..c0ee595 100644 --- a/src/main/java/disassembly/types/TableType.java +++ b/src/main/java/wasm/disassembly/types/TableType.java @@ -1,11 +1,10 @@ -package disassembly.types; +package wasm.disassembly.types; -import disassembly.InvalidOpCodeException; -import disassembly.WASMOpCode; +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class TableType extends WASMOpCode { diff --git a/src/main/java/disassembly/types/ValType.java b/src/main/java/wasm/disassembly/types/ValType.java similarity index 89% rename from src/main/java/disassembly/types/ValType.java rename to src/main/java/wasm/disassembly/types/ValType.java index 7b6d4e4..239d286 100644 --- a/src/main/java/disassembly/types/ValType.java +++ b/src/main/java/wasm/disassembly/types/ValType.java @@ -1,6 +1,4 @@ -package disassembly.types; - -import disassembly.WASMOpCode; +package wasm.disassembly.types; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/disassembly/values/WByte.java b/src/main/java/wasm/disassembly/values/WByte.java similarity index 85% rename from src/main/java/disassembly/values/WByte.java rename to src/main/java/wasm/disassembly/values/WByte.java index 72c200f..81cc320 100644 --- a/src/main/java/disassembly/values/WByte.java +++ b/src/main/java/wasm/disassembly/values/WByte.java @@ -1,10 +1,9 @@ -package disassembly.values; +package wasm.disassembly.values; -import disassembly.WASMOpCode; +import wasm.disassembly.WASMOpCode; import java.io.BufferedInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; public class WByte extends WASMOpCode { diff --git a/src/main/java/disassembly/values/WDouble.java b/src/main/java/wasm/disassembly/values/WDouble.java similarity index 94% rename from src/main/java/disassembly/values/WDouble.java rename to src/main/java/wasm/disassembly/values/WDouble.java index eda219c..05bd15a 100644 --- a/src/main/java/disassembly/values/WDouble.java +++ b/src/main/java/wasm/disassembly/values/WDouble.java @@ -1,4 +1,4 @@ -package disassembly.values; +package wasm.disassembly.values; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/values/WFloat.java b/src/main/java/wasm/disassembly/values/WFloat.java similarity index 90% rename from src/main/java/disassembly/values/WFloat.java rename to src/main/java/wasm/disassembly/values/WFloat.java index 18562dc..d4388f7 100644 --- a/src/main/java/disassembly/values/WFloat.java +++ b/src/main/java/wasm/disassembly/values/WFloat.java @@ -1,9 +1,8 @@ -package disassembly.values; +package wasm.disassembly.values; import java.io.BufferedInputStream; import java.io.IOException; import java.io.OutputStream; -import java.math.BigInteger; import java.nio.ByteBuffer; public class WFloat { diff --git a/src/main/java/wasm/disassembly/values/WName.java b/src/main/java/wasm/disassembly/values/WName.java new file mode 100644 index 0000000..fd97381 --- /dev/null +++ b/src/main/java/wasm/disassembly/values/WName.java @@ -0,0 +1,25 @@ +package wasm.disassembly.values; + +import wasm.disassembly.InvalidOpCodeException; +import wasm.disassembly.WASMOpCode; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; + +public class WName { + + public static String read(BufferedInputStream in) throws IOException, InvalidOpCodeException { + long length = WUnsignedInt.read(in, 32); + byte[] arr = new byte[(int)length]; + in.read(arr); + return new String(arr, StandardCharsets.UTF_8); + } + + public static void write(String value, OutputStream out) throws IOException, InvalidOpCodeException { + byte[] bytes = value.getBytes(StandardCharsets.UTF_8); + WUnsignedInt.write(bytes.length, out, 32); + out.write(bytes); + } +} diff --git a/src/main/java/disassembly/values/WSignedInt.java b/src/main/java/wasm/disassembly/values/WSignedInt.java similarity index 95% rename from src/main/java/disassembly/values/WSignedInt.java rename to src/main/java/wasm/disassembly/values/WSignedInt.java index b5e9469..71d185d 100644 --- a/src/main/java/disassembly/values/WSignedInt.java +++ b/src/main/java/wasm/disassembly/values/WSignedInt.java @@ -1,6 +1,6 @@ -package disassembly.values; +package wasm.disassembly.values; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/values/WSignedLong.java b/src/main/java/wasm/disassembly/values/WSignedLong.java similarity index 92% rename from src/main/java/disassembly/values/WSignedLong.java rename to src/main/java/wasm/disassembly/values/WSignedLong.java index 2ba7849..eeb86fc 100644 --- a/src/main/java/disassembly/values/WSignedLong.java +++ b/src/main/java/wasm/disassembly/values/WSignedLong.java @@ -1,12 +1,10 @@ -package disassembly.values; +package wasm.disassembly.values; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; public class WSignedLong { diff --git a/src/main/java/disassembly/values/WUnsignedInt.java b/src/main/java/wasm/disassembly/values/WUnsignedInt.java similarity index 93% rename from src/main/java/disassembly/values/WUnsignedInt.java rename to src/main/java/wasm/disassembly/values/WUnsignedInt.java index 38503b0..b79ce06 100644 --- a/src/main/java/disassembly/values/WUnsignedInt.java +++ b/src/main/java/wasm/disassembly/values/WUnsignedInt.java @@ -1,6 +1,6 @@ -package disassembly.values; +package wasm.disassembly.values; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; diff --git a/src/main/java/disassembly/values/WUnsignedLong.java b/src/main/java/wasm/disassembly/values/WUnsignedLong.java similarity index 92% rename from src/main/java/disassembly/values/WUnsignedLong.java rename to src/main/java/wasm/disassembly/values/WUnsignedLong.java index 5867eb3..42e83a5 100644 --- a/src/main/java/disassembly/values/WUnsignedLong.java +++ b/src/main/java/wasm/disassembly/values/WUnsignedLong.java @@ -1,13 +1,11 @@ -package disassembly.values; +package wasm.disassembly.values; -import disassembly.InvalidOpCodeException; +import wasm.disassembly.InvalidOpCodeException; import java.io.BufferedInputStream; import java.io.IOException; import java.io.OutputStream; import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; public class WUnsignedLong {