diff --git a/SourceGen/LocalVariableLookup.cs b/SourceGen/LocalVariableLookup.cs index 5711a40..c596c22 100644 --- a/SourceGen/LocalVariableLookup.cs +++ b/SourceGen/LocalVariableLookup.cs @@ -104,6 +104,8 @@ namespace SourceGen { /// up in the symbol table, and the uniquifier isn't able to tell that the entry in the /// symbol table is itself. The logic is simpler if we just rename the label before /// the uniquifier ever sees it. + /// + /// I feel like there has to be a simpler way to do this. This'll do for now. /// private Dictionary mDupRemap; diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index a71f5e4..8205017 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -1324,6 +1324,7 @@ namespace SourceGen { case LineListGen.Line.Type.EquDirective: case LineListGen.Line.Type.RegWidthDirective: case LineListGen.Line.Type.OrgDirective: + case LineListGen.Line.Type.LocalVariableTable: if (format == ClipLineFormat.Disassembly) { if (!string.IsNullOrEmpty(parts.Addr)) { sb.Append(parts.Addr); @@ -1706,21 +1707,37 @@ namespace SourceGen { public void EditLocalVariableTable() { int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex(); int offset = CodeLineList[selIndex].FileOffset; + // Get existing table, if any. mProject.LvTables.TryGetValue(offset, out LocalVariableTable oldLvt); - EditLocalVariableTable dlg = new EditLocalVariableTable(mMainWin, mProject.SymbolTable, - mOutputFormatter, oldLvt); + EditLocalVariableTable dlg = new EditLocalVariableTable(mMainWin, mProject, + mOutputFormatter, oldLvt, offset); if (dlg.ShowDialog() != true) { return; } - if (oldLvt == dlg.NewTable) { + if (offset != dlg.NewOffset) { + // Table moved. We create two changes, one to delete the current table, one + // to create a new table. + Debug.Assert(!mProject.LvTables.TryGetValue(dlg.NewOffset, + out LocalVariableTable unused)); + + UndoableChange rem = UndoableChange.CreateLocalVariableTableChange(offset, + oldLvt, null); + UndoableChange add = UndoableChange.CreateLocalVariableTableChange(dlg.NewOffset, + null, dlg.NewTable); + ChangeSet cs = new ChangeSet(2); + cs.Add(rem); + cs.Add(add); + ApplyUndoableChanges(cs); + } else if (oldLvt != dlg.NewTable) { + // New table, edited in place, or deleted. + UndoableChange uc = UndoableChange.CreateLocalVariableTableChange(offset, + oldLvt, dlg.NewTable); + ChangeSet cs = new ChangeSet(uc); + ApplyUndoableChanges(cs); + } else { Debug.WriteLine("LvTable unchanged"); - return; } - UndoableChange uc = UndoableChange.CreateLocalVariableTableChange(offset, - oldLvt, dlg.NewTable); - ChangeSet cs = new ChangeSet(uc); - ApplyUndoableChanges(cs); } public bool CanEditLongComment() { diff --git a/SourceGen/SourceGen.csproj b/SourceGen/SourceGen.csproj index 683e4af..a060190 100644 --- a/SourceGen/SourceGen.csproj +++ b/SourceGen/SourceGen.csproj @@ -118,6 +118,9 @@ EditLongComment.xaml + + EditLvTableLocation.xaml + EditNote.xaml @@ -275,6 +278,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/SourceGen/WpfGui/EditLocalVariableTable.xaml b/SourceGen/WpfGui/EditLocalVariableTable.xaml index 9ccc01f..3e6f59c 100644 --- a/SourceGen/WpfGui/EditLocalVariableTable.xaml +++ b/SourceGen/WpfGui/EditLocalVariableTable.xaml @@ -83,8 +83,10 @@ limitations under the License. Content="Clear values from previous tables"/> -