yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::AssemblyEditor Class Reference

Text editor for modifying assembly code. More...

#include <assembly_editor.h>

Inheritance diagram for yaze::editor::AssemblyEditor:

Classes

struct  Z3DisasmHookJump
 
struct  Z3DisasmSourceJump
 

Public Member Functions

 AssemblyEditor (Rom *rom=nullptr)
 
void ChangeActiveFile (const std::string_view &filename)
 
absl::Status JumpToSymbolDefinition (const std::string &symbol)
 
absl::Status JumpToReference (const std::string &reference)
 
std::string active_file_path () const
 
TextEditor::Coordinates active_cursor_position () const
 
void Initialize () override
 
absl::Status Load () override
 
void InlineUpdate ()
 
void UpdateCodeView ()
 
absl::Status Cut () override
 
absl::Status Copy () override
 
absl::Status Paste () override
 
absl::Status Undo () override
 
absl::Status Redo () override
 
absl::Status Find () override
 
absl::Status Update () override
 
absl::Status Save () override
 
void OpenFolder (const std::string &folder_path)
 
absl::Status ValidateCurrentFile ()
 
absl::Status ApplyPatchToRom ()
 
void UpdateErrorMarkers (const core::AsarPatchResult &result)
 
void ClearErrorMarkers ()
 
void SetRom (Rom *rom)
 
Romrom () const
 
bool is_asar_initialized () const
 
const std::map< std::string, core::AsarSymbol > & symbols () const
 
core::AsarWrapperasar_wrapper ()
 
const std::vector< core::AssemblyDiagnostic > & last_diagnostics () const
 
- Public Member Functions inherited from yaze::editor::Editor
 Editor ()=default
 
virtual ~Editor ()=default
 
virtual void SetDependencies (const EditorDependencies &deps)
 
virtual void SetGameData (zelda3::GameData *game_data)
 
virtual std::string GetUndoDescription () const
 
virtual std::string GetRedoDescription () const
 
const UndoManagerundo_manager () const
 
virtual absl::Status Clear ()
 
virtual void ContributeStatus (StatusBar *)
 
EditorType type () const
 
bool * active ()
 
void set_active (bool active)
 
void toggle_active ()
 
virtual bool IsRomLoaded () const
 
virtual std::string GetRomStatus () const
 
Romrom () const
 
zelda3::GameDatagame_data () const
 
EditorContext context () const
 
bool HasContext () const
 

Private Member Functions

TextEditorGetActiveEditor ()
 
const TextEditorGetActiveEditor () const
 
bool HasActiveFile () const
 
void DrawCodeEditor ()
 
void DrawFileBrowser ()
 
void DrawSymbolsContent ()
 
void DrawBuildOutput ()
 
void DrawDisassemblyContent ()
 
void DrawToolbarContent ()
 
void DrawFileMenu ()
 
void DrawEditMenu ()
 
void DrawAssembleMenu ()
 
void DrawCurrentFolder ()
 
void DrawFileTabView ()
 
void DrawToolset ()
 
void DrawSymbolPanel ()
 
void ClearSymbolJumpCache ()
 
absl::Status NavigateDisassemblyQuery ()
 
absl::Status GenerateZ3Disassembly ()
 
void PollZ3DisassemblyTask ()
 
void RefreshZ3DisassemblyFiles ()
 
void LoadSelectedZ3DisassemblyFile ()
 
void RefreshSelectedZ3DisassemblyMetadata ()
 
absl::Status RunProjectGraphQueryInDrawer (const std::vector< std::string > &args, const std::string &title)
 
std::string ResolveZ3DisasmCommand () const
 
std::string ResolveZ3DisasmOutputDir () const
 
std::string ResolveZ3DisasmRomPath () const
 
std::string BuildProjectGraphBankQuery () const
 
std::string BuildProjectGraphLookupQuery (uint32_t address) const
 
int SelectedZ3DisasmBankIndex () const
 
std::optional< uint32_t > CurrentDisassemblyBank () const
 

Private Attributes

bool file_is_loaded_ = false
 
int current_file_id_ = 0
 
int active_file_id_ = -1
 
std::vector< std::string > files_
 
std::vector< TextEditoropen_files_
 
ImVector< int > active_files_
 
std::string current_file_
 
FolderItem current_folder_
 
TextEditor text_editor_
 
Romrom_
 
core::AsarWrapper asar_
 
bool asar_initialized_ = false
 
bool show_symbol_panel_ = false
 
std::map< std::string, core::AsarSymbolsymbols_
 
std::vector< std::string > last_errors_
 
std::vector< std::string > last_warnings_
 
std::vector< core::AssemblyDiagnosticlast_diagnostics_
 
BackgroundCommandTask z3disasm_task_
 
bool z3disasm_all_banks_ = false
 
int z3disasm_bank_start_ = 0
 
int z3disasm_bank_end_ = 0
 
std::string z3disasm_output_dir_
 
std::vector< std::string > z3disasm_files_
 
int z3disasm_selected_index_ = -1
 
std::string z3disasm_selected_path_
 
std::string z3disasm_selected_contents_
 
std::vector< Z3DisasmSourceJumpz3disasm_source_jumps_
 
std::vector< Z3DisasmHookJumpz3disasm_hook_jumps_
 
std::string z3disasm_status_
 
bool z3disasm_task_acknowledged_ = true
 
std::string disasm_query_ = "0x008000"
 
int disasm_instruction_count_ = 24
 
std::string disasm_status_
 
std::string symbol_jump_root_
 
absl::flat_hash_map< std::string, AsmSymbolLocationsymbol_jump_cache_
 
absl::flat_hash_set< std::string > symbol_jump_negative_cache_
 

Friends

struct ::yaze::test::AssemblyEditorGuiTestAccess
 

Additional Inherited Members

- Protected Member Functions inherited from yaze::editor::Editor
std::string MakePanelTitle (const std::string &base_title) const
 
std::string MakeWindowId (const std::string &base_id) const
 
template<typename T >
absl::StatusOr< T > SafeRomAccess (std::function< T()> accessor, const std::string &operation="") const
 
- Protected Attributes inherited from yaze::editor::Editor
bool active_ = false
 
EditorType type_
 
EditorDependencies dependencies_
 
UndoManager undo_manager_
 

Detailed Description

Text editor for modifying assembly code.

Definition at line 45 of file assembly_editor.h.

Constructor & Destructor Documentation

◆ AssemblyEditor()

yaze::editor::AssemblyEditor::AssemblyEditor ( Rom * rom = nullptr)
inlineexplicit

Member Function Documentation

◆ ChangeActiveFile()

void yaze::editor::AssemblyEditor::ChangeActiveFile ( const std::string_view & filename)

Definition at line 2172 of file assembly_editor.cc.

References TextEditor::GetDarkPalette(), yaze::util::GetFileName(), and yaze::util::LoadFile().

Referenced by JumpToReference(), and JumpToSymbolDefinition().

Here is the call graph for this function:

◆ JumpToSymbolDefinition()

◆ JumpToReference()

◆ active_file_path()

std::string yaze::editor::AssemblyEditor::active_file_path ( ) const

Definition at line 891 of file assembly_editor.cc.

References active_file_id_, files_, and HasActiveFile().

Here is the call graph for this function:

◆ active_cursor_position()

TextEditor::Coordinates yaze::editor::AssemblyEditor::active_cursor_position ( ) const

Definition at line 898 of file assembly_editor.cc.

References active_file_id_, HasActiveFile(), TextEditor::Coordinates::Invalid(), and open_files_.

Here is the call graph for this function:

◆ Initialize()

◆ Load()

absl::Status yaze::editor::AssemblyEditor::Load ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 726 of file assembly_editor.cc.

◆ InlineUpdate()

◆ UpdateCodeView()

void yaze::editor::AssemblyEditor::UpdateCodeView ( )

Definition at line 2036 of file assembly_editor.cc.

◆ Cut()

absl::Status yaze::editor::AssemblyEditor::Cut ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2212 of file assembly_editor.cc.

◆ Copy()

absl::Status yaze::editor::AssemblyEditor::Copy ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2217 of file assembly_editor.cc.

◆ Paste()

absl::Status yaze::editor::AssemblyEditor::Paste ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2222 of file assembly_editor.cc.

◆ Undo()

absl::Status yaze::editor::AssemblyEditor::Undo ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2227 of file assembly_editor.cc.

◆ Redo()

absl::Status yaze::editor::AssemblyEditor::Redo ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2232 of file assembly_editor.cc.

◆ Find()

absl::Status yaze::editor::AssemblyEditor::Find ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 81 of file assembly_editor.h.

◆ Update()

absl::Status yaze::editor::AssemblyEditor::Update ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2001 of file assembly_editor.cc.

◆ Save()

absl::Status yaze::editor::AssemblyEditor::Save ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 2044 of file assembly_editor.cc.

◆ OpenFolder()

void yaze::editor::AssemblyEditor::OpenFolder ( const std::string & folder_path)

Definition at line 920 of file assembly_editor.cc.

References ClearSymbolJumpCache(), current_folder_, and symbol_jump_root_.

Referenced by DrawFileBrowser(), JumpToReference(), and JumpToSymbolDefinition().

Here is the call graph for this function:

◆ ValidateCurrentFile()

absl::Status yaze::editor::AssemblyEditor::ValidateCurrentFile ( )

Definition at line 2367 of file assembly_editor.cc.

Referenced by DrawBuildOutput().

◆ ApplyPatchToRom()

absl::Status yaze::editor::AssemblyEditor::ApplyPatchToRom ( )

Definition at line 2445 of file assembly_editor.cc.

Referenced by DrawBuildOutput().

◆ UpdateErrorMarkers()

void yaze::editor::AssemblyEditor::UpdateErrorMarkers ( const core::AsarPatchResult & result)

◆ ClearErrorMarkers()

void yaze::editor::AssemblyEditor::ClearErrorMarkers ( )

Definition at line 2561 of file assembly_editor.cc.

◆ SetRom()

void yaze::editor::AssemblyEditor::SetRom ( Rom * rom)
inline

Definition at line 95 of file assembly_editor.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

Rom * yaze::editor::AssemblyEditor::rom ( ) const
inline

Definition at line 96 of file assembly_editor.h.

References rom_.

Referenced by SetRom().

◆ is_asar_initialized()

bool yaze::editor::AssemblyEditor::is_asar_initialized ( ) const
inline

Definition at line 99 of file assembly_editor.h.

References asar_initialized_.

◆ symbols()

const std::map< std::string, core::AsarSymbol > & yaze::editor::AssemblyEditor::symbols ( ) const
inline

Definition at line 100 of file assembly_editor.h.

References symbols_.

◆ asar_wrapper()

core::AsarWrapper * yaze::editor::AssemblyEditor::asar_wrapper ( )
inline

Definition at line 103 of file assembly_editor.h.

References asar_.

◆ last_diagnostics()

const std::vector< core::AssemblyDiagnostic > & yaze::editor::AssemblyEditor::last_diagnostics ( ) const
inline

Definition at line 107 of file assembly_editor.h.

References last_diagnostics_.

◆ GetActiveEditor() [1/2]

TextEditor * yaze::editor::AssemblyEditor::GetActiveEditor ( )
private

Definition at line 906 of file assembly_editor.cc.

References active_file_id_, HasActiveFile(), open_files_, and text_editor_.

Referenced by DrawBuildOutput(), DrawCodeEditor(), JumpToReference(), and JumpToSymbolDefinition().

Here is the call graph for this function:

◆ GetActiveEditor() [2/2]

const TextEditor * yaze::editor::AssemblyEditor::GetActiveEditor ( ) const
private

Definition at line 913 of file assembly_editor.cc.

References active_file_id_, HasActiveFile(), open_files_, and text_editor_.

Here is the call graph for this function:

◆ HasActiveFile()

bool yaze::editor::AssemblyEditor::HasActiveFile ( ) const
inlineprivate

◆ DrawCodeEditor()

◆ DrawFileBrowser()

◆ DrawSymbolsContent()

void yaze::editor::AssemblyEditor::DrawSymbolsContent ( )
private

Definition at line 993 of file assembly_editor.cc.

References ICON_MD_SEARCH, and symbols_.

Referenced by Initialize().

◆ DrawBuildOutput()

◆ DrawDisassemblyContent()

void yaze::editor::AssemblyEditor::DrawDisassemblyContent ( )
private

◆ DrawToolbarContent()

void yaze::editor::AssemblyEditor::DrawToolbarContent ( )
private

◆ DrawFileMenu()

void yaze::editor::AssemblyEditor::DrawFileMenu ( )
private

Definition at line 2131 of file assembly_editor.cc.

References ICON_MD_FILE_OPEN, ICON_MD_SAVE, and yaze::util::FileDialogWrapper::ShowOpenFileDialog().

Referenced by DrawCodeEditor().

Here is the call graph for this function:

◆ DrawEditMenu()

void yaze::editor::AssemblyEditor::DrawEditMenu ( )
private

◆ DrawAssembleMenu()

void yaze::editor::AssemblyEditor::DrawAssembleMenu ( )
private

◆ DrawCurrentFolder()

void yaze::editor::AssemblyEditor::DrawCurrentFolder ( )
private

Definition at line 2075 of file assembly_editor.cc.

Referenced by DrawFileBrowser().

◆ DrawFileTabView()

void yaze::editor::AssemblyEditor::DrawFileTabView ( )
private

Definition at line 1943 of file assembly_editor.cc.

References yaze::gui::BeginThemedTabBar(), yaze::gui::EndThemedTabBar(), and yaze::util::GetFileName().

Referenced by DrawCodeEditor().

Here is the call graph for this function:

◆ DrawToolset()

void yaze::editor::AssemblyEditor::DrawToolset ( )
private

Definition at line 2061 of file assembly_editor.cc.

References yaze::gui::Toolset::AddAction(), yaze::gui::Toolset::Begin(), yaze::gui::Toolset::End(), ICON_MD_FOLDER_OPEN, and ICON_MD_SAVE.

Here is the call graph for this function:

◆ DrawSymbolPanel()

void yaze::editor::AssemblyEditor::DrawSymbolPanel ( )
private

Definition at line 2699 of file assembly_editor.cc.

◆ ClearSymbolJumpCache()

void yaze::editor::AssemblyEditor::ClearSymbolJumpCache ( )
private

Definition at line 928 of file assembly_editor.cc.

References symbol_jump_cache_, and symbol_jump_negative_cache_.

Referenced by OpenFolder().

◆ NavigateDisassemblyQuery()

absl::Status yaze::editor::AssemblyEditor::NavigateDisassemblyQuery ( )
private

Definition at line 1504 of file assembly_editor.cc.

Referenced by RunProjectGraphQueryInDrawer().

◆ GenerateZ3Disassembly()

absl::Status yaze::editor::AssemblyEditor::GenerateZ3Disassembly ( )
private

Definition at line 1436 of file assembly_editor.cc.

◆ PollZ3DisassemblyTask()

void yaze::editor::AssemblyEditor::PollZ3DisassemblyTask ( )
private

Definition at line 1405 of file assembly_editor.cc.

◆ RefreshZ3DisassemblyFiles()

void yaze::editor::AssemblyEditor::RefreshZ3DisassemblyFiles ( )
private

Definition at line 1356 of file assembly_editor.cc.

◆ LoadSelectedZ3DisassemblyFile()

void yaze::editor::AssemblyEditor::LoadSelectedZ3DisassemblyFile ( )
private

Definition at line 1335 of file assembly_editor.cc.

◆ RefreshSelectedZ3DisassemblyMetadata()

◆ RunProjectGraphQueryInDrawer()

◆ ResolveZ3DisasmCommand()

std::string yaze::editor::AssemblyEditor::ResolveZ3DisasmCommand ( ) const
private

Definition at line 1134 of file assembly_editor.cc.

◆ ResolveZ3DisasmOutputDir()

std::string yaze::editor::AssemblyEditor::ResolveZ3DisasmOutputDir ( ) const
private

◆ ResolveZ3DisasmRomPath()

std::string yaze::editor::AssemblyEditor::ResolveZ3DisasmRomPath ( ) const
private

◆ BuildProjectGraphBankQuery()

std::string yaze::editor::AssemblyEditor::BuildProjectGraphBankQuery ( ) const
private

Definition at line 1188 of file assembly_editor.cc.

References SelectedZ3DisasmBankIndex().

Here is the call graph for this function:

◆ BuildProjectGraphLookupQuery()

std::string yaze::editor::AssemblyEditor::BuildProjectGraphLookupQuery ( uint32_t address) const
private

Definition at line 1197 of file assembly_editor.cc.

◆ SelectedZ3DisasmBankIndex()

int yaze::editor::AssemblyEditor::SelectedZ3DisasmBankIndex ( ) const
private

◆ CurrentDisassemblyBank()

std::optional< uint32_t > yaze::editor::AssemblyEditor::CurrentDisassemblyBank ( ) const
private

Definition at line 1122 of file assembly_editor.cc.

References disasm_query_, and symbols_.

Friends And Related Symbol Documentation

◆ ::yaze::test::AssemblyEditorGuiTestAccess

friend struct ::yaze::test::AssemblyEditorGuiTestAccess
friend

Definition at line 112 of file assembly_editor.h.

Member Data Documentation

◆ file_is_loaded_

bool yaze::editor::AssemblyEditor::file_is_loaded_ = false
private

Definition at line 163 of file assembly_editor.h.

◆ current_file_id_

int yaze::editor::AssemblyEditor::current_file_id_ = 0
private

Definition at line 164 of file assembly_editor.h.

◆ active_file_id_

int yaze::editor::AssemblyEditor::active_file_id_ = -1
private

◆ files_

std::vector<std::string> yaze::editor::AssemblyEditor::files_
private

Definition at line 167 of file assembly_editor.h.

Referenced by active_file_path().

◆ open_files_

std::vector<TextEditor> yaze::editor::AssemblyEditor::open_files_
private

◆ active_files_

ImVector<int> yaze::editor::AssemblyEditor::active_files_
private

Definition at line 169 of file assembly_editor.h.

◆ current_file_

std::string yaze::editor::AssemblyEditor::current_file_
private

Definition at line 171 of file assembly_editor.h.

Referenced by DrawCodeEditor().

◆ current_folder_

FolderItem yaze::editor::AssemblyEditor::current_folder_
private

◆ text_editor_

TextEditor yaze::editor::AssemblyEditor::text_editor_
private

Definition at line 173 of file assembly_editor.h.

Referenced by AssemblyEditor(), GetActiveEditor(), GetActiveEditor(), and Initialize().

◆ rom_

Rom* yaze::editor::AssemblyEditor::rom_
private

◆ asar_

core::AsarWrapper yaze::editor::AssemblyEditor::asar_
private

Definition at line 178 of file assembly_editor.h.

Referenced by asar_wrapper(), and RunProjectGraphQueryInDrawer().

◆ asar_initialized_

bool yaze::editor::AssemblyEditor::asar_initialized_ = false
private

Definition at line 182 of file assembly_editor.h.

Referenced by is_asar_initialized().

◆ show_symbol_panel_

bool yaze::editor::AssemblyEditor::show_symbol_panel_ = false
private

Definition at line 183 of file assembly_editor.h.

◆ symbols_

std::map<std::string, core::AsarSymbol> yaze::editor::AssemblyEditor::symbols_
private

◆ last_errors_

std::vector<std::string> yaze::editor::AssemblyEditor::last_errors_
private

Definition at line 197 of file assembly_editor.h.

Referenced by DrawBuildOutput().

◆ last_warnings_

std::vector<std::string> yaze::editor::AssemblyEditor::last_warnings_
private

Definition at line 198 of file assembly_editor.h.

Referenced by DrawBuildOutput().

◆ last_diagnostics_

std::vector<core::AssemblyDiagnostic> yaze::editor::AssemblyEditor::last_diagnostics_
private

Definition at line 199 of file assembly_editor.h.

Referenced by DrawBuildOutput(), and last_diagnostics().

◆ z3disasm_task_

BackgroundCommandTask yaze::editor::AssemblyEditor::z3disasm_task_
private

Definition at line 200 of file assembly_editor.h.

◆ z3disasm_all_banks_

bool yaze::editor::AssemblyEditor::z3disasm_all_banks_ = false
private

Definition at line 201 of file assembly_editor.h.

◆ z3disasm_bank_start_

int yaze::editor::AssemblyEditor::z3disasm_bank_start_ = 0
private

Definition at line 202 of file assembly_editor.h.

◆ z3disasm_bank_end_

int yaze::editor::AssemblyEditor::z3disasm_bank_end_ = 0
private

Definition at line 203 of file assembly_editor.h.

◆ z3disasm_output_dir_

std::string yaze::editor::AssemblyEditor::z3disasm_output_dir_
private

Definition at line 204 of file assembly_editor.h.

Referenced by ResolveZ3DisasmOutputDir().

◆ z3disasm_files_

std::vector<std::string> yaze::editor::AssemblyEditor::z3disasm_files_
private

Definition at line 205 of file assembly_editor.h.

◆ z3disasm_selected_index_

int yaze::editor::AssemblyEditor::z3disasm_selected_index_ = -1
private

Definition at line 206 of file assembly_editor.h.

◆ z3disasm_selected_path_

std::string yaze::editor::AssemblyEditor::z3disasm_selected_path_
private

Definition at line 207 of file assembly_editor.h.

Referenced by SelectedZ3DisasmBankIndex().

◆ z3disasm_selected_contents_

std::string yaze::editor::AssemblyEditor::z3disasm_selected_contents_
private

Definition at line 208 of file assembly_editor.h.

◆ z3disasm_source_jumps_

std::vector<Z3DisasmSourceJump> yaze::editor::AssemblyEditor::z3disasm_source_jumps_
private

Definition at line 209 of file assembly_editor.h.

Referenced by RefreshSelectedZ3DisassemblyMetadata().

◆ z3disasm_hook_jumps_

std::vector<Z3DisasmHookJump> yaze::editor::AssemblyEditor::z3disasm_hook_jumps_
private

Definition at line 210 of file assembly_editor.h.

Referenced by RefreshSelectedZ3DisassemblyMetadata().

◆ z3disasm_status_

std::string yaze::editor::AssemblyEditor::z3disasm_status_
private

Definition at line 211 of file assembly_editor.h.

◆ z3disasm_task_acknowledged_

bool yaze::editor::AssemblyEditor::z3disasm_task_acknowledged_ = true
private

Definition at line 212 of file assembly_editor.h.

◆ disasm_query_

std::string yaze::editor::AssemblyEditor::disasm_query_ = "0x008000"
private

Definition at line 213 of file assembly_editor.h.

Referenced by CurrentDisassemblyBank(), and RunProjectGraphQueryInDrawer().

◆ disasm_instruction_count_

int yaze::editor::AssemblyEditor::disasm_instruction_count_ = 24
private

Definition at line 214 of file assembly_editor.h.

◆ disasm_status_

std::string yaze::editor::AssemblyEditor::disasm_status_
private

Definition at line 215 of file assembly_editor.h.

◆ symbol_jump_root_

std::string yaze::editor::AssemblyEditor::symbol_jump_root_
private

Definition at line 219 of file assembly_editor.h.

Referenced by JumpToSymbolDefinition(), and OpenFolder().

◆ symbol_jump_cache_

absl::flat_hash_map<std::string, AsmSymbolLocation> yaze::editor::AssemblyEditor::symbol_jump_cache_
private

Definition at line 220 of file assembly_editor.h.

Referenced by ClearSymbolJumpCache(), and JumpToSymbolDefinition().

◆ symbol_jump_negative_cache_

absl::flat_hash_set<std::string> yaze::editor::AssemblyEditor::symbol_jump_negative_cache_
private

Definition at line 221 of file assembly_editor.h.

Referenced by ClearSymbolJumpCache(), and JumpToSymbolDefinition().


The documentation for this class was generated from the following files: