public ConsoleSimulation(string inputFileName, CommandInterpreter interpreter) { m_Terminal = new ConsoleEmulator(interpreter); m_Logger = new ConsoleLogger(); m_TerminationMgr = new TerminationManager(inputFileName); var fileParserFac = new FileReaderFactory(); ICompiledFileReader fileParser = fileParserFac.GetFileParser(inputFileName); DisassembledFileBase file = fileParser.ParseFile(inputFileName, m_Logger); m_Terminal.PrintString("Successfully loaded " + inputFileName + " (source file: " + file.SourceInformation.SourceFilePath + "; " + file.TotalFileSize + " bytes)\n"); m_ExecCtx = new RuntimeProcess(file, m_Terminal); IEnumerable <InstructionData> programInstructions = DisassemblerServices.GenerateInstructionData(file.SymbolTable, file.TextSegment, file.SourceInformation); m_SrcMapping = new Dictionary <int, SourceLineInformation>(); foreach (InstructionData instructionElem in programInstructions) { m_SrcMapping.Add(instructionElem.ProgramCounterLocation, new SourceLineInformation(instructionElem)); } m_CmdTable = new CommandTable(m_SrcMapping, m_ExecCtx, m_Terminal, m_TerminationMgr); m_Terminal.AddAvailableCommands(m_CmdTable.AllCommands); }
public CommandTable(Dictionary <int, SourceLineInformation> srcData, RuntimeProcess executive, ITerminal terminal, TerminationManager termMgr) { var tmpCmdList = new List <IConsoleCommand>() { new PwdCommand(terminal), new DirCommand(terminal), new ChangeDirectoryCommand(), new DumpRegistersCommand(executive.RegisterManager, terminal), new DumpMemoryCommand(executive, terminal), new FormatAndDumpRegistersCommand(executive.RegisterManager, terminal), new FormatAndDumpMemoryCommand(executive, terminal), new ReadRegisterCommand(executive.RegisterManager, terminal), new FormatAndReadRegisterCommand(executive.RegisterManager, terminal), new ReadMemoryCommand(executive, terminal), new FormatAndReadMemoryCommand(executive, terminal), new WriteRegisterCommand(executive.RegisterManager, terminal), new WriteMemoryCommand(executive, terminal), new RunProcessCommand(executive, terminal), new InstructionStepCommand(executive, terminal), new SetBreakpointCommand(srcData, executive, terminal), new ContinueExecutionCommand(executive, terminal), new QuitCommand(executive, terminal, termMgr), new LoadFileCommand(executive, terminal, termMgr) }; m_CmdData = new Dictionary <CommandKey, IConsoleCommand>(); foreach (var cmd in tmpCmdList) { m_CmdData.Add(new CommandKey(cmd.CommandString, cmd.NumArguments), cmd); } m_OverallHelpCmd = new GenericHelpCommand(this, terminal); m_CmdData.Add(new CommandKey(m_OverallHelpCmd.CommandString, m_OverallHelpCmd.NumArguments), m_OverallHelpCmd); }