diff --git a/fuzzer/Instruction.java b/fuzzer/Instruction.java index e6bb0d021d540b21e9f3d7a8a533f12b5e63723e..8608385a4d525cf8013172ce141eae9683d6e4ca 100644 --- a/fuzzer/Instruction.java +++ b/fuzzer/Instruction.java @@ -28,7 +28,7 @@ public enum Instruction { } return grammar; } - + private final String opcode; private final OperandType[] operands; @@ -40,7 +40,7 @@ public enum Instruction { public String getOpcode(){ return opcode; } - + public OperandType[] getOperands(){ return operands; } @@ -52,5 +52,30 @@ public enum Instruction { } return "\"" + opcode + "\"" + operandsString; } - + + public Instruction fromStringToInstruction(String input) { + int end_command = input.indexOf(" "); + + String command = ""; + if (end_command != -1) { + command += input.substring(0, end_command); + } + + if (command == "put") { + return Instruction.PUT; + } else if (command == "get") { + return Instruction.GET; + } else if (command == "rem") { + return Instruction.REM; + } else if (command == "save") { + return Instruction.SAVE; + } else if (command == "list") { + return Instruction.LIST; + } else if (command == "masterpw") { + return Instruction.MASTERPW; + } + + return null; + } + }