updated for gwasm minimal 1.0.1

This commit is contained in:
sirjonasxx 2021-11-26 00:51:46 +01:00
parent c2fcee21b9
commit d9d1785a33
5 changed files with 44 additions and 54 deletions

View File

@ -232,7 +232,7 @@
<dependency>
<groupId>G-Earth</groupId>
<artifactId>G-Wasm</artifactId>
<version>1.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>

View File

@ -7,7 +7,6 @@ import wasm.disassembly.modules.sections.code.Locals;
import wasm.disassembly.types.FuncType;
import wasm.disassembly.types.ResultType;
import wasm.disassembly.types.ValType;
import wasm.misc.CodeCompare;
import wasm.misc.StreamReplacement;
import java.util.Arrays;
@ -38,8 +37,7 @@ public class IncomingPacketPatcher implements StreamReplacement {
}
@Override
public CodeCompare getCodeCompare() {
return code -> {
public boolean codeMatches(Func code) {
if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32)))))
return false;
@ -55,6 +53,7 @@ public class IncomingPacketPatcher implements StreamReplacement {
}
return true;
};
}
}

View File

@ -6,7 +6,6 @@ import wasm.disassembly.modules.sections.code.Func;
import wasm.disassembly.types.FuncType;
import wasm.disassembly.types.ResultType;
import wasm.disassembly.types.ValType;
import wasm.misc.CodeCompare;
import wasm.misc.StreamReplacement;
import java.util.Arrays;
@ -36,8 +35,7 @@ public class OutgoingPacketPatcher implements StreamReplacement {
}
@Override
public CodeCompare getCodeCompare() {
return code -> {
public boolean codeMatches(Func code) {
if (code.getLocalss().size() != 0) return false;
List<Instr> expression = code.getExpression().getInstructions();
if (expression.get(0).getInstrType() != InstrType.LOCAL_GET) return false;
@ -48,6 +46,5 @@ public class OutgoingPacketPatcher implements StreamReplacement {
if (expression.get(5).getInstrType() != InstrType.CALL) return false;
return true;
};
}
}

View File

@ -6,7 +6,6 @@ import wasm.disassembly.modules.sections.code.Func;
import wasm.disassembly.types.FuncType;
import wasm.disassembly.types.ResultType;
import wasm.disassembly.types.ValType;
import wasm.misc.CodeCompare;
import wasm.misc.StreamReplacement;
import java.util.Arrays;
@ -36,13 +35,11 @@ public class ReturnBytePatcher implements StreamReplacement {
}
@Override
public CodeCompare getCodeCompare() {
return code -> {
public boolean codeMatches(Func code) {
if (code.getLocalss().size() != 0) return false;
if (code.getExpression().getInstructions().size() != 30) return false;
List<Instr> expr = code.getExpression().getInstructions();
if (expr.get(expr.size() - 1).getInstrType() != InstrType.I32_XOR) return false;
return true;
};
}
}

View File

@ -7,7 +7,6 @@ import wasm.disassembly.modules.sections.code.Locals;
import wasm.disassembly.types.FuncType;
import wasm.disassembly.types.ResultType;
import wasm.disassembly.types.ValType;
import wasm.misc.CodeCompare;
import wasm.misc.StreamReplacement;
import java.util.Arrays;
@ -38,8 +37,7 @@ public class SetKeyPatcher implements StreamReplacement {
}
@Override
public CodeCompare getCodeCompare() {
return code -> {
public boolean codeMatches(Func code) {
if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32)))))
return false;
List<InstrType> expectedExpr = Arrays.asList(InstrType.I32_CONST, InstrType.I32_LOAD8_S,
@ -55,6 +53,5 @@ public class SetKeyPatcher implements StreamReplacement {
}
return true;
};
}
}