private void LoadDataFromFile(string path) { if (string.IsNullOrEmpty(path)) { return; } if (File.Exists(path)) { MainForm.targetAVMPath = path; var bytes = File.ReadAllBytes(path); var mapFileName = path.Replace(".avm", ".neomap"); debugMode = DebugMode.Assembly; sourceLanguage = SourceLanguageKind.Other; if (File.Exists(mapFileName)) { map = new NeoMapFile(); map.LoadFromFile(mapFileName); } else { map = null; } this.debugger = new NeoDebugger(bytes); this.avm_asm = NeoDisassembler.Disassemble(bytes); if (map != null && map.Entries.Any()) { var srcFile = map.Entries.FirstOrDefault().url; FileName.Text = srcFile; sourceLanguage = LanguageSupport.DetectLanguage(srcFile); debugMode = DebugMode.Source; debugContent[DebugMode.Source] = File.ReadAllText(srcFile); } debugContent[DebugMode.Assembly] = avm_asm.ToString(); FileName.Text = Path.GetFileName(path); ReloadTextArea(); StorageLoad(); UpdateSourceViewMenus(); shouldReset = true; } }
private void LoadDataFromFile(string path) { if (string.IsNullOrEmpty(path)) { return; } if (File.Exists(path)) { var bytes = File.ReadAllBytes(path); var mapFileName = path.Replace(".avm", ".neomap"); debugMode = DebugMode.Assembly; if (File.Exists(mapFileName)) { map = new NeoMapFile(); map.LoadFromFile(mapFileName); } else { map = null; } this.debugger = new NeoDebugger(bytes); this.avm_asm = NeoDisassembler.Disassemble(bytes); if (map != null && map.Entries.Any()) { var srcFile = map.Entries.FirstOrDefault().url; FileName.Text = srcFile; debugMode = DebugMode.Source; debugContent[DebugMode.Source] = File.ReadAllText(srcFile); } debugContent[DebugMode.Assembly] = avm_asm.ToString(); FileName.Text = Path.GetFileName(path); TextArea.Text = debugContent[debugMode]; TextArea.ReadOnly = true; shouldReset = true; } }