This commit is contained in:
sirjonasxx 2020-11-12 02:27:27 +01:00
parent 198cea9968
commit d0b17c6a5f
88 changed files with 555 additions and 480 deletions

View File

@ -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<Import> functionTypes;
public ImportSection(BufferedInputStream in) throws IOException, InvalidOpCodeException {
super(in, IMPORT_SECTION_ID);
functionTypes = new Vector<>(in, Import::new);
}
public ImportSection(List<Import> functionTypes) {
super(IMPORT_SECTION_ID);
this.functionTypes = new Vector<>(functionTypes);
}
@Override
protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException {
functionTypes.assemble(out);
}
public List<Import> getFunctionTypes() {
return functionTypes.getElements();
}
public void setFunctionTypes(List<Import> functionTypes) {
this.functionTypes = new Vector<>(functionTypes);
}
}

View File

@ -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;
}
}

View File

@ -1,4 +1,4 @@
package disassembly; package wasm.disassembly;
public class InvalidOpCodeException extends Exception { public class InvalidOpCodeException extends Exception {

View File

@ -1,4 +1,4 @@
package disassembly; package wasm.disassembly;
import java.io.*; import java.io.*;

View File

@ -1,4 +1,4 @@
package disassembly.conventions; package wasm.disassembly.conventions;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
public interface Creator<B> { public interface Creator<B> {

View File

@ -1,7 +1,7 @@
package disassembly.conventions; package wasm.disassembly.conventions;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.conventions; package wasm.disassembly.conventions;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,7 +1,7 @@
package disassembly.instructions; package wasm.disassembly.instructions;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,8 @@
package disassembly.instructions; package wasm.disassembly.instructions;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;

View File

@ -1,13 +1,13 @@
package disassembly.instructions; package wasm.disassembly.instructions;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.control.*; import wasm.disassembly.instructions.control.*;
import disassembly.instructions.memory.Mem0Instr; import wasm.disassembly.instructions.memory.Mem0Instr;
import disassembly.instructions.memory.MemInstr; import wasm.disassembly.instructions.memory.MemInstr;
import disassembly.instructions.misc.SingleByteInstr; import wasm.disassembly.instructions.misc.SingleByteInstr;
import disassembly.instructions.numeric.*; import wasm.disassembly.instructions.numeric.*;
import disassembly.instructions.variable.GlobalVariableInstr; import wasm.disassembly.instructions.variable.GlobalVariableInstr;
import disassembly.instructions.variable.LocalVariableInstr; import wasm.disassembly.instructions.variable.LocalVariableInstr;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,6 +1,4 @@
package disassembly.instructions; package wasm.disassembly.instructions;
import disassembly.types.ElemType;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -1,10 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.InstrFactory;
import disassembly.instructions.InstrFactory; import wasm.disassembly.instructions.InstrType;
import disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.types.ValType; import wasm.disassembly.types.ValType;
import disassembly.values.WSignedLong; import wasm.disassembly.values.WSignedLong;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.modules.indices.LabelIdx; import wasm.disassembly.modules.indices.LabelIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,11 +1,10 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.conventions.Creator; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.InstrType;
import disassembly.instructions.InstrType; import wasm.disassembly.modules.indices.LabelIdx;
import disassembly.modules.indices.LabelIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,10 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.InstrType;
import disassembly.instructions.InstrType; import wasm.disassembly.modules.indices.FuncIdx;
import disassembly.modules.indices.FuncIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.modules.indices.FuncIdx; import wasm.disassembly.modules.indices.FuncIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.control; package wasm.disassembly.instructions.control;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrFactory; import wasm.disassembly.instructions.InstrFactory;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.instructions.memory; package wasm.disassembly.instructions.memory;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.instructions.memory; package wasm.disassembly.instructions.memory;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.instructions.memory; package wasm.disassembly.instructions.memory;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,7 +1,7 @@
package disassembly.instructions.misc; package wasm.disassembly.instructions.misc;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.values.WFloat; import wasm.disassembly.values.WFloat;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.values.WDouble; import wasm.disassembly.values.WDouble;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.values.WSignedInt; import wasm.disassembly.values.WSignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.values.WSignedLong; import wasm.disassembly.values.WSignedLong;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,7 +1,7 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.numeric; package wasm.disassembly.instructions.numeric;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.variable; package wasm.disassembly.instructions.variable;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.modules.indices.GlobalIdx; import wasm.disassembly.modules.indices.GlobalIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.instructions.variable; package wasm.disassembly.instructions.variable;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.instructions.Instr; import wasm.disassembly.instructions.Instr;
import disassembly.instructions.InstrType; import wasm.disassembly.instructions.InstrType;
import disassembly.modules.indices.LocalIdx; import wasm.disassembly.modules.indices.LocalIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,7 +1,7 @@
package disassembly.modules; package wasm.disassembly.modules;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,21 +1,21 @@
package disassembly.modules; package wasm.disassembly.modules;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.modules.sections.Section; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.code.CodeSection; import wasm.disassembly.modules.sections.code.CodeSection;
import disassembly.modules.sections.custom.CustomSection; import wasm.disassembly.modules.sections.custom.CustomSection;
import disassembly.modules.sections.custom.CustomSectionFactory; import wasm.disassembly.modules.sections.custom.CustomSectionFactory;
import disassembly.modules.sections.data.DataSection; import wasm.disassembly.modules.sections.data.DataSection;
import disassembly.modules.sections.element.ElementSection; import wasm.disassembly.modules.sections.element.ElementSection;
import disassembly.modules.sections.export.ExportSection; import wasm.disassembly.modules.sections.export.ExportSection;
import disassembly.modules.sections.function.FunctionSection; import wasm.disassembly.modules.sections.function.FunctionSection;
import disassembly.modules.sections.global.GlobalSection; import wasm.disassembly.modules.sections.global.GlobalSection;
import disassembly.modules.sections.imprt.ImportSection; import wasm.disassembly.modules.sections.imprt.ImportSection;
import disassembly.modules.sections.memory.MemorySection; import wasm.disassembly.modules.sections.memory.MemorySection;
import disassembly.modules.sections.start.StartSection; import wasm.disassembly.modules.sections.start.StartSection;
import disassembly.modules.sections.table.TableSection; import wasm.disassembly.modules.sections.table.TableSection;
import disassembly.modules.sections.type.TypeSection; import wasm.disassembly.modules.sections.type.TypeSection;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -143,4 +143,117 @@ public class Module extends WASMOpCode {
section.assemble(out); 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<List<CustomSection>> getCustomSectionsList() {
return customSectionsList;
}
public void setCustomSectionsList(List<List<CustomSection>> customSectionsList) {
this.customSectionsList = customSectionsList;
}
} }

View File

@ -1,7 +1,7 @@
package disassembly.modules; package wasm.disassembly.modules;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -10,6 +10,9 @@ import java.io.OutputStream;
public class FuncIdx extends WASMOpCode { public class FuncIdx extends WASMOpCode {
public static int OFFSET = 0;
private long x; private long x;
public FuncIdx(BufferedInputStream in) throws IOException, InvalidOpCodeException { public FuncIdx(BufferedInputStream in) throws IOException, InvalidOpCodeException {
@ -17,19 +20,19 @@ public class FuncIdx extends WASMOpCode {
} }
public FuncIdx(long x) { public FuncIdx(long x) {
this.x = x; this.x = x - OFFSET;
} }
@Override @Override
public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { public void assemble(OutputStream out) throws IOException, InvalidOpCodeException {
WUnsignedInt.write(x, out, 32); WUnsignedInt.write(x + OFFSET, out, 32);
} }
public long getX() { public long getX() {
return x; return x + OFFSET;
} }
public void setX(long x) { public void setX(long x) {
this.x = x; this.x = x - OFFSET;
} }
} }

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.indices; package wasm.disassembly.modules.indices;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections; package wasm.disassembly.modules.sections;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.code; package wasm.disassembly.modules.sections.code;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.code; package wasm.disassembly.modules.sections.code;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,9 @@
package disassembly.modules.sections.code; package wasm.disassembly.modules.sections.code;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.conventions.Vector; import wasm.disassembly.conventions.Vector;
import disassembly.instructions.Expression; import wasm.disassembly.instructions.Expression;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.modules.sections.code; package wasm.disassembly.modules.sections.code;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.types.ValType; import wasm.disassembly.types.ValType;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.custom; package wasm.disassembly.modules.sections.custom;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.modules.sections.Section; import wasm.disassembly.modules.sections.Section;
import disassembly.values.WName; import wasm.disassembly.values.WName;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -12,26 +12,26 @@ public abstract class CustomSection extends Section {
public static final int CUSTOM_SECTION_ID = 0; 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); super(CUSTOM_SECTION_ID, size);
this.name = name; this.name = name;
} }
@Override @Override
protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException { protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException {
out.write(name.getValue().getBytes(StandardCharsets.UTF_8)); WName.write(name, out);
assemble3(out); assemble3(out);
} }
protected abstract void assemble3(OutputStream out) throws IOException, InvalidOpCodeException; protected abstract void assemble3(OutputStream out) throws IOException, InvalidOpCodeException;
public WName getName() { public String getName() {
return name; return name;
} }
public void setName(WName name) { public void setName(String name) {
this.name = name; this.name = name;
} }
} }

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.custom; package wasm.disassembly.modules.sections.custom;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.values.WName; import wasm.disassembly.values.WName;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -11,7 +11,7 @@ public class CustomSectionFactory {
public static CustomSection get(BufferedInputStream in) throws IOException, InvalidOpCodeException { public static CustomSection get(BufferedInputStream in) throws IOException, InvalidOpCodeException {
long size = WUnsignedInt.read(in, 32); long size = WUnsignedInt.read(in, 32);
WName name = new WName(in); String name = WName.read(in);
// select implementation // select implementation

View File

@ -1,9 +1,10 @@
package disassembly.modules.sections.custom; package wasm.disassembly.modules.sections.custom;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.values.WName; import wasm.disassembly.values.WName;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -12,9 +13,13 @@ public class UnImplementedCustomSection extends CustomSection {
private byte[] bytes; 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); 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); in.read(bytes);
} }

View File

@ -1,10 +1,10 @@
package disassembly.modules.sections.data; package wasm.disassembly.modules.sections.data;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.instructions.Expression; import wasm.disassembly.instructions.Expression;
import disassembly.modules.indices.MemIdx; import wasm.disassembly.modules.indices.MemIdx;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.data; package wasm.disassembly.modules.sections.data;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,11 +1,11 @@
package disassembly.modules.sections.element; package wasm.disassembly.modules.sections.element;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.conventions.Vector; import wasm.disassembly.conventions.Vector;
import disassembly.instructions.Expression; import wasm.disassembly.instructions.Expression;
import disassembly.modules.indices.FuncIdx; import wasm.disassembly.modules.indices.FuncIdx;
import disassembly.modules.indices.TableIdx; import wasm.disassembly.modules.indices.TableIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.element; package wasm.disassembly.modules.sections.element;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.export; package wasm.disassembly.modules.sections.export;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WName; import wasm.disassembly.values.WName;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -10,31 +10,30 @@ import java.io.OutputStream;
public class Export extends WASMOpCode { public class Export extends WASMOpCode {
private WName name; private String name;
private ExportDesc exportDesc; private ExportDesc exportDesc;
public Export(BufferedInputStream in) throws IOException, InvalidOpCodeException { public Export(BufferedInputStream in) throws IOException, InvalidOpCodeException {
name = new WName(in); name = WName.read(in);
exportDesc = new ExportDesc(in); exportDesc = new ExportDesc(in);
} }
public Export(WName name, ExportDesc exportDesc) { public Export(String name, ExportDesc exportDesc) {
this.name = name; this.name = name;
this.exportDesc = exportDesc; this.exportDesc = exportDesc;
} }
@Override @Override
public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { public void assemble(OutputStream out) throws IOException, InvalidOpCodeException {
name.assemble(out); WName.write(name, out);
exportDesc.assemble(out); exportDesc.assemble(out);
} }
public String getName() {
public WName getName() {
return name; return name;
} }
public void setName(WName name) { public void setName(String name) {
this.name = name; this.name = name;
} }

View File

@ -1,11 +1,11 @@
package disassembly.modules.sections.export; package wasm.disassembly.modules.sections.export;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.modules.indices.FuncIdx; import wasm.disassembly.modules.indices.FuncIdx;
import disassembly.modules.indices.GlobalIdx; import wasm.disassembly.modules.indices.GlobalIdx;
import disassembly.modules.indices.MemIdx; import wasm.disassembly.modules.indices.MemIdx;
import disassembly.modules.indices.TableIdx; import wasm.disassembly.modules.indices.TableIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.export; package wasm.disassembly.modules.sections.export;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,9 @@
package disassembly.modules.sections.function; package wasm.disassembly.modules.sections.function;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.conventions.Vector; import wasm.disassembly.conventions.Vector;
import disassembly.modules.indices.TypeIdx; import wasm.disassembly.modules.indices.TypeIdx;
import disassembly.modules.sections.Section; import wasm.disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,9 @@
package disassembly.modules.sections.global; package wasm.disassembly.modules.sections.global;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.instructions.Expression; import wasm.disassembly.instructions.Expression;
import disassembly.types.GlobalType; import wasm.disassembly.types.GlobalType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.global; package wasm.disassembly.modules.sections.global;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,8 @@
package disassembly.modules.sections.imprt; package wasm.disassembly.modules.sections.imprt;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.modules.Module; import wasm.disassembly.values.WName;
import disassembly.values.WName;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -11,17 +10,17 @@ import java.io.OutputStream;
public class Import extends WASMOpCode { public class Import extends WASMOpCode {
private WName module; private String module;
private WName name; private String name;
private ImportDesc importDescription; private ImportDesc importDescription;
public Import(BufferedInputStream in) throws IOException, InvalidOpCodeException { public Import(BufferedInputStream in) throws IOException, InvalidOpCodeException {
module = new WName(in); module = WName.read(in);
name = new WName(in); name = WName.read(in);
importDescription = new ImportDesc(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.module = module;
this.name = name; this.name = name;
this.importDescription = importDescription; this.importDescription = importDescription;
@ -29,24 +28,24 @@ public class Import extends WASMOpCode {
@Override @Override
public void assemble(OutputStream out) throws IOException, InvalidOpCodeException { public void assemble(OutputStream out) throws IOException, InvalidOpCodeException {
module.assemble(out); WName.write(module, out);
name.assemble(out); WName.write(name, out);
importDescription.assemble(out); importDescription.assemble(out);
} }
public WName getModule() { public String getModule() {
return module; return module;
} }
public void setModule(WName module) { public void setModule(String module) {
this.module = module; this.module = module;
} }
public WName getName() { public String getName() {
return name; return name;
} }
public void setName(WName name) { public void setName(String name) {
this.name = name; this.name = name;
} }

View File

@ -1,11 +1,11 @@
package disassembly.modules.sections.imprt; package wasm.disassembly.modules.sections.imprt;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.modules.indices.TypeIdx; import wasm.disassembly.modules.indices.TypeIdx;
import disassembly.types.GlobalType; import wasm.disassembly.types.GlobalType;
import disassembly.types.MemType; import wasm.disassembly.types.MemType;
import disassembly.types.TableType; import wasm.disassembly.types.TableType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -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<Import> imports;
public ImportSection(BufferedInputStream in) throws IOException, InvalidOpCodeException {
super(in, IMPORT_SECTION_ID);
imports = new Vector<>(in, Import::new);
}
public ImportSection(List<Import> imports) {
super(IMPORT_SECTION_ID);
this.imports = new Vector<>(imports);
}
@Override
protected void assemble2(OutputStream out) throws IOException, InvalidOpCodeException {
imports.assemble(out);
}
public List<Import> getImports() {
return imports.getElements();
}
public void setImports(List<Import> imports) {
this.imports = new Vector<>(imports);
}
public void importFunctions(List<Import> functions) {
List<Import> newImports = new ArrayList<>(functions);
newImports.addAll(imports.getElements());
setImports(newImports);
FuncIdx.OFFSET += functions.size();
}
}

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.memory; package wasm.disassembly.modules.sections.memory;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.types.MemType; import wasm.disassembly.types.MemType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,13 +1,11 @@
package disassembly.modules.sections.memory; package wasm.disassembly.modules.sections.memory;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Vector; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.start; package wasm.disassembly.modules.sections.start;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.modules.indices.FuncIdx; import wasm.disassembly.modules.indices.FuncIdx;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,12 +1,10 @@
package disassembly.modules.sections.start; package wasm.disassembly.modules.sections.start;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.modules.sections.Section;
import disassembly.modules.sections.Section;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class StartSection extends Section { public class StartSection extends Section {

View File

@ -1,8 +1,8 @@
package disassembly.modules.sections.table; package wasm.disassembly.modules.sections.table;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.types.TableType; import wasm.disassembly.types.TableType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,15 +1,11 @@
package disassembly.modules.sections.table; package wasm.disassembly.modules.sections.table;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.conventions.Vector;
import disassembly.conventions.Creator; import wasm.disassembly.modules.sections.Section;
import disassembly.conventions.Vector;
import disassembly.modules.sections.Section;
import disassembly.types.TableType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,9 @@
package disassembly.modules.sections.type; package wasm.disassembly.modules.sections.type;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.conventions.Vector; import wasm.disassembly.conventions.Vector;
import disassembly.modules.sections.Section; import wasm.disassembly.modules.sections.Section;
import disassembly.types.FuncType; import wasm.disassembly.types.FuncType;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,4 +1,4 @@
package disassembly.types; package wasm.disassembly.types;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -1,11 +1,10 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class FuncType extends WASMOpCode { public class FuncType extends WASMOpCode {

View File

@ -1,11 +1,10 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class GlobalType extends WASMOpCode { public class GlobalType extends WASMOpCode {

View File

@ -1,8 +1,8 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.values.WUnsignedInt; import wasm.disassembly.values.WUnsignedInt;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,11 +1,10 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class MemType extends WASMOpCode { public class MemType extends WASMOpCode {

View File

@ -1,4 +1,4 @@
package disassembly.types; package wasm.disassembly.types;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -1,12 +1,11 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import disassembly.conventions.CustomVector; import wasm.disassembly.conventions.CustomVector;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List; import java.util.List;

View File

@ -1,11 +1,10 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.InvalidOpCodeException; import wasm.disassembly.InvalidOpCodeException;
import disassembly.WASMOpCode; import wasm.disassembly.WASMOpCode;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class TableType extends WASMOpCode { public class TableType extends WASMOpCode {

View File

@ -1,6 +1,4 @@
package disassembly.types; package wasm.disassembly.types;
import disassembly.WASMOpCode;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class WByte extends WASMOpCode { public class WByte extends WASMOpCode {

View File

@ -1,4 +1,4 @@
package disassembly.values; package wasm.disassembly.values;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -1,9 +1,8 @@
package disassembly.values; package wasm.disassembly.values;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigInteger;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class WFloat { public class WFloat {

View File

@ -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);
}
}

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class WSignedLong { public class WSignedLong {

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;

View File

@ -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.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class WUnsignedLong { public class WUnsignedLong {