mirror of
https://github.com/sirjonasxx/G-Wasm.git
synced 2025-01-18 16:46:28 +01:00
stuff
This commit is contained in:
parent
9dbf50c7e1
commit
ac126c26df
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>G-Earth</groupId>
|
||||
<artifactId>G-Wasm</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.0.1</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -1,31 +1,10 @@
|
||||
package wasm;
|
||||
|
||||
import wasm.disassembly.InvalidOpCodeException;
|
||||
import wasm.disassembly.instructions.Expression;
|
||||
import wasm.disassembly.instructions.Instr;
|
||||
import wasm.disassembly.instructions.InstrType;
|
||||
import wasm.disassembly.instructions.misc.SingleByteInstr;
|
||||
import wasm.disassembly.modules.Module;
|
||||
import wasm.disassembly.modules.indices.FuncIdx;
|
||||
import wasm.disassembly.modules.indices.TypeIdx;
|
||||
import wasm.disassembly.modules.sections.code.Func;
|
||||
import wasm.disassembly.modules.sections.code.Locals;
|
||||
import wasm.disassembly.modules.sections.export.Export;
|
||||
import wasm.disassembly.modules.sections.export.ExportDesc;
|
||||
import wasm.disassembly.modules.sections.imprt.Import;
|
||||
import wasm.disassembly.modules.sections.imprt.ImportDesc;
|
||||
import wasm.disassembly.types.FuncType;
|
||||
import wasm.disassembly.types.ResultType;
|
||||
import wasm.disassembly.types.ValType;
|
||||
import wasm.misc.CodeCompare;
|
||||
import wasm.misc.Function;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GWasm {
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class CustomVector<B> extends WASMOpCode {
|
||||
|
||||
public CustomVector(BufferedInputStream in, Creator<B> creator, Assembler<B> assembler, Module module) throws IOException, InvalidOpCodeException {
|
||||
long length = WUnsignedInt.read(in, 32);
|
||||
elements = new ArrayList<>();
|
||||
elements = new ArrayList<>(1);
|
||||
for (int i = 0; i < length; i++) {
|
||||
elements.add(creator.create(in, module));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Vector<B extends WASMOpCode> extends WASMOpCode {
|
||||
|
||||
public Vector(BufferedInputStream in, Creator<B> creator, Module module) throws IOException, InvalidOpCodeException {
|
||||
long length = WUnsignedInt.read(in, 32);
|
||||
elements = new ArrayList<>();
|
||||
elements = new ArrayList<>(1);
|
||||
for (int i = 0; i < length; i++) {
|
||||
elements.add(creator.create(in, module));
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class BlockInstr extends Instr {
|
||||
|
||||
blockType = new BlockType(in, module);
|
||||
|
||||
blockInstructions = new ArrayList<>();
|
||||
blockInstructions = new ArrayList<>(4);
|
||||
InstrType type;
|
||||
while ((type = InstrFactory.disassembleType(in)) != InstrType.END) {
|
||||
blockInstructions.add(InstrFactory.disassemble(in, type, module));
|
||||
|
@ -24,14 +24,14 @@ public class IfElseInstr extends Instr {
|
||||
super(instrType);
|
||||
|
||||
blockType = new BlockType(in, module);
|
||||
ifInstructions = new ArrayList<>();
|
||||
ifInstructions = new ArrayList<>(2);
|
||||
elseInstructions = null;
|
||||
List<Instr> currentBlock = ifInstructions;
|
||||
|
||||
InstrType type;
|
||||
while ((type = InstrFactory.disassembleType(in)) != InstrType.END) {
|
||||
if (type == InstrType.ELSE) {
|
||||
elseInstructions = new ArrayList<>();
|
||||
elseInstructions = new ArrayList<>(2);
|
||||
currentBlock = elseInstructions;
|
||||
}
|
||||
else {
|
||||
|
@ -2,7 +2,6 @@ package wasm.disassembly.modules;
|
||||
|
||||
import wasm.disassembly.InvalidOpCodeException;
|
||||
import wasm.disassembly.WASMOpCode;
|
||||
import wasm.disassembly.modules.indices.FuncIdx;
|
||||
import wasm.disassembly.modules.sections.Section;
|
||||
import wasm.disassembly.modules.sections.code.CodeSection;
|
||||
import wasm.disassembly.modules.sections.custom.CustomSection;
|
||||
@ -12,15 +11,11 @@ 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.Import;
|
||||
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 wasm.disassembly.types.FuncType;
|
||||
import wasm.misc.CodeCompare;
|
||||
import wasm.misc.Function;
|
||||
import wasm.misc.StreamReplacement;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package wasm.disassembly.modules.sections.code;
|
||||
|
||||
import wasm.disassembly.InvalidOpCodeException;
|
||||
import wasm.disassembly.conventions.Creator;
|
||||
import wasm.disassembly.conventions.Vector;
|
||||
import wasm.disassembly.instructions.Expression;
|
||||
import wasm.disassembly.instructions.Instr;
|
||||
import wasm.disassembly.instructions.InstrType;
|
||||
@ -12,10 +10,7 @@ import wasm.disassembly.modules.Module;
|
||||
import wasm.disassembly.modules.indices.FuncIdx;
|
||||
import wasm.disassembly.modules.indices.LocalIdx;
|
||||
import wasm.disassembly.modules.sections.Section;
|
||||
import wasm.disassembly.modules.sections.data.Data;
|
||||
import wasm.disassembly.values.WUnsignedInt;
|
||||
import wasm.misc.CodeCompare;
|
||||
import wasm.misc.Function;
|
||||
import wasm.misc.StreamReplacement;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@ -52,9 +47,8 @@ public class CodeSection extends Section {
|
||||
for (int j = 0; j < module.streamReplacements.size(); j++) {
|
||||
|
||||
if (module.getFunctionSection().matchesSearchFunctionsTypes.get(j).contains(i)) {
|
||||
CodeCompare comparer = module.streamReplacements.get(j).getCodeCompare();
|
||||
|
||||
if (comparer.isEqual(func)) {
|
||||
if (module.streamReplacements.get(j).codeMatches(func)) {
|
||||
StreamReplacement.ReplacementType actionTaken = module.streamReplacements.get(j).getReplacementType();
|
||||
if (actionTaken == StreamReplacement.ReplacementType.HOOK) {
|
||||
CallInstr call = new CallInstr(new FuncIdx(j, module));
|
||||
|
@ -1,16 +1,10 @@
|
||||
package wasm.disassembly.modules.sections.function;
|
||||
|
||||
import wasm.disassembly.InvalidOpCodeException;
|
||||
import wasm.disassembly.conventions.Vector;
|
||||
import wasm.disassembly.modules.Module;
|
||||
import wasm.disassembly.modules.indices.FuncIdx;
|
||||
import wasm.disassembly.modules.indices.TypeIdx;
|
||||
import wasm.disassembly.modules.sections.Section;
|
||||
import wasm.disassembly.modules.sections.code.Code;
|
||||
import wasm.disassembly.modules.sections.code.Func;
|
||||
import wasm.disassembly.values.WUnsignedInt;
|
||||
import wasm.misc.CodeCompare;
|
||||
import wasm.misc.Function;
|
||||
import wasm.misc.StreamReplacement;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
|
@ -1,10 +0,0 @@
|
||||
package wasm.misc;
|
||||
|
||||
import wasm.disassembly.modules.sections.code.Func;
|
||||
import wasm.disassembly.types.FuncType;
|
||||
|
||||
public interface CodeCompare {
|
||||
|
||||
boolean isEqual(Func code);
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package wasm.misc;
|
||||
|
||||
import wasm.disassembly.modules.sections.code.Func;
|
||||
import wasm.disassembly.types.FuncType;
|
||||
|
||||
public interface StreamReplacement {
|
||||
@ -14,5 +15,5 @@ public interface StreamReplacement {
|
||||
ReplacementType getReplacementType();
|
||||
String getImportName();
|
||||
String getExportName();
|
||||
CodeCompare getCodeCompare();
|
||||
boolean codeMatches(Func code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user