mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
updated for gwasm minimal 1.0.1
This commit is contained in:
parent
c2fcee21b9
commit
d9d1785a33
@ -232,7 +232,7 @@
|
||||
<dependency>
|
||||
<groupId>G-Earth</groupId>
|
||||
<artifactId>G-Wasm</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -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,23 +37,23 @@ public class IncomingPacketPatcher implements StreamReplacement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCompare getCodeCompare() {
|
||||
return code -> {
|
||||
if (!(code.getLocalss().equals(Collections.singletonList(new Locals(1, ValType.I32)))))
|
||||
return false;
|
||||
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,
|
||||
InstrType.I32_EQZ, InstrType.IF, InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.LOCAL_TEE,
|
||||
InstrType.IF);
|
||||
List<InstrType> expectedExpr = Arrays.asList(InstrType.I32_CONST, InstrType.I32_LOAD8_S,
|
||||
InstrType.I32_EQZ, InstrType.IF, InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.LOCAL_TEE,
|
||||
InstrType.IF);
|
||||
|
||||
if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false;
|
||||
if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false;
|
||||
|
||||
for (int j = 0; j < code.getExpression().getInstructions().size(); j++) {
|
||||
Instr instr = code.getExpression().getInstructions().get(j);
|
||||
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
||||
}
|
||||
for (int j = 0; j < code.getExpression().getInstructions().size(); j++) {
|
||||
Instr instr = code.getExpression().getInstructions().get(j);
|
||||
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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,18 +35,16 @@ public class OutgoingPacketPatcher implements StreamReplacement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCompare getCodeCompare() {
|
||||
return code -> {
|
||||
if (code.getLocalss().size() != 0) return false;
|
||||
List<Instr> expression = code.getExpression().getInstructions();
|
||||
if (expression.get(0).getInstrType() != InstrType.LOCAL_GET) return false;
|
||||
if (expression.get(1).getInstrType() != InstrType.LOCAL_GET) return false;
|
||||
if (expression.get(2).getInstrType() != InstrType.LOCAL_GET) return false;
|
||||
if (expression.get(3).getInstrType() != InstrType.I32_LOAD) return false;
|
||||
if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false;
|
||||
if (expression.get(5).getInstrType() != InstrType.CALL) return false;
|
||||
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;
|
||||
if (expression.get(1).getInstrType() != InstrType.LOCAL_GET) return false;
|
||||
if (expression.get(2).getInstrType() != InstrType.LOCAL_GET) return false;
|
||||
if (expression.get(3).getInstrType() != InstrType.I32_LOAD) return false;
|
||||
if (expression.get(4).getInstrType() != InstrType.I32_CONST) return false;
|
||||
if (expression.get(5).getInstrType() != InstrType.CALL) return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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 -> {
|
||||
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;
|
||||
};
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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,23 +37,21 @@ public class SetKeyPatcher implements StreamReplacement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCompare getCodeCompare() {
|
||||
return 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,
|
||||
InstrType.I32_EQZ, InstrType.IF, InstrType.BLOCK, InstrType.LOCAL_GET, InstrType.I32_CONST,
|
||||
InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.I32_CONST,
|
||||
InstrType.CALL);
|
||||
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,
|
||||
InstrType.I32_EQZ, InstrType.IF, InstrType.BLOCK, InstrType.LOCAL_GET, InstrType.I32_CONST,
|
||||
InstrType.LOCAL_GET, InstrType.I32_LOAD, InstrType.I32_CONST, InstrType.I32_CONST, InstrType.I32_CONST,
|
||||
InstrType.CALL);
|
||||
|
||||
if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false;
|
||||
if (code.getExpression().getInstructions().size() != expectedExpr.size()) return false;
|
||||
|
||||
for (int j = 0; j < code.getExpression().getInstructions().size(); j++) {
|
||||
Instr instr = code.getExpression().getInstructions().get(j);
|
||||
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
||||
}
|
||||
for (int j = 0; j < code.getExpression().getInstructions().size(); j++) {
|
||||
Instr instr = code.getExpression().getInstructions().get(j);
|
||||
if (instr.getInstrType() != expectedExpr.get(j)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user