/// <summary> /// Converte uma linha de codigo MIPS para Objeto de Instrução /// </summary> /// <param name="mipsCommand">A linha mips</param> /// <returns>Instrução resultante, ou null caso ocorra erro.</returns> public static Instruction FromString(string mipsCommand) { mipsCommand = Helper.RemoveExtraSpaces(mipsCommand); string[] splitedCommand = mipsCommand.Split(DELIMITERS); InstructionType type; if (!InstructionType.TryParse(splitedCommand[0], true, out type)) { return(null); } return(new Instruction(type, splitedCommand)); }
public Instruction Parse(string s) { InstructionType intType; InstructionType.TryParse(s.Split(" ")[0], out intType); return(new Instruction() { Type = intType, Arg = int.Parse(s.Split(" ")[1]), Visited = 0 }); }
public static InstructionType GetTypeFromString(string mipsCommand) { mipsCommand = Helper.RemoveExtraSpaces(mipsCommand); string[] splitedCommand = mipsCommand.Split(DELIMITERS); InstructionType type; if (!InstructionType.TryParse(splitedCommand[0], true, out type)) { throw new Exception("Unknown instruction!"); } return(type); }