diff --git a/SourceGen/DefSymbol.cs b/SourceGen/DefSymbol.cs
index 1e4f20b..b166e8a 100644
--- a/SourceGen/DefSymbol.cs
+++ b/SourceGen/DefSymbol.cs
@@ -23,6 +23,8 @@ namespace SourceGen {
/// Instances are immutable.
///
public class DefSymbol : Symbol {
+ public const int NO_WIDTH = -1;
+
///
/// Data format descriptor.
///
@@ -40,8 +42,9 @@ namespace SourceGen {
public string Tag { get; private set; }
///
- /// Number of bytes referenced by the symbol. Useful for identifying two-byte and
- /// three-byte pointers. Used for Variables.
+ /// Number of bytes referenced by the symbol. Useful for identifying multi-byte items,
+ /// such as two-byte and three-byte pointers. Used for Variables. Value will be
+ /// NO_WIDTH if unset.
///
public int Width { get; private set; }
@@ -62,6 +65,7 @@ namespace SourceGen {
Debug.Assert(source == Source.Platform || source == Source.Project);
Debug.Assert(type == Type.ExternalAddr || type == Type.Constant);
Xrefs = new XrefSet();
+ Width = NO_WIDTH;
}
///
diff --git a/SourceGen/LineListGen.cs b/SourceGen/LineListGen.cs
index d634543..33d51c6 100644
--- a/SourceGen/LineListGen.cs
+++ b/SourceGen/LineListGen.cs
@@ -1069,6 +1069,8 @@ namespace SourceGen {
// isn't the ORG at the start of the file. (This may temporarily do
// double-spacing if we do a partial update, because we won't be able to
// "see" the previous line. Harmless.)
+ // TODO: consider always adding blanks, and doing a fix-up pass afterward.
+ // (but keep in mind that blank lines should always come above things)
//
// Interesting case:
// .dd2 $1000
diff --git a/SourceGen/LocalVariableTable.cs b/SourceGen/LocalVariableTable.cs
new file mode 100644
index 0000000..99e8d23
--- /dev/null
+++ b/SourceGen/LocalVariableTable.cs
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2019 faddenSoft
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Collections.Generic;
+
+namespace SourceGen {
+ ///
+ /// Table of redefinable variables. A project may have several of these, at different
+ /// offsets. The contents of later tables overwrite the contents of earlier tables.
+ ///
+ public class LocalVariableTable {
+ ///
+ /// List of variables. The symbol's label must be unique within a table, so we sort
+ /// on that.
+ ///
+ private SortedList mVariables;
+
+ ///
+ /// If set, all values from previous VariableTables should be discarded when this
+ /// table is encountered.
+ ///
+ ///
+ /// Might be useful to allow addresses (DP ops) and constants (StackRel ops) to be
+ /// cleared independently, but I suspect the typical compiled-language scenario will
+ /// involve StackRel for args and a sliding DP for locals, so generally it makes
+ /// sense to just clear both.
+ ///
+ public bool ClearPrevious { get; set; }
+
+ ///
+ /// Indexer.
+ ///
+ /// Symbol's label.
+ /// Matching symbol. Throws an exception if not found.
+ public DefSymbol this[string key] {
+ get {
+ return mVariables[key];
+ }
+ set {
+ mVariables[key] = value;
+ }
+ }
+
+ ///
+ /// Constructs an empty table.
+ ///
+ public LocalVariableTable() {
+ mVariables = new SortedList();
+ }
+ }
+}
diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs
index 549faec..ef592c9 100644
--- a/SourceGen/MainController.cs
+++ b/SourceGen/MainController.cs
@@ -1685,6 +1685,18 @@ namespace SourceGen {
}
}
+ public bool CanEditLocalVariableTable() {
+ return true; // TODO
+ }
+
+ public void EditLocalVariableTable() {
+ // TODO
+ EditLocalVariableTable dlg = new EditLocalVariableTable(mMainWin);
+ if (dlg.ShowDialog() != true) {
+ return;
+ }
+ }
+
public bool CanEditLongComment() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
diff --git a/SourceGen/SourceGen.csproj b/SourceGen/SourceGen.csproj
index de56815..58d38d9 100644
--- a/SourceGen/SourceGen.csproj
+++ b/SourceGen/SourceGen.csproj
@@ -89,6 +89,7 @@
ShowText.xaml
+
AboutBox.xaml
@@ -110,6 +111,9 @@
EditLabel.xaml
+
+ EditLocalVariableTable.xaml
+
EditLongComment.xaml
@@ -262,6 +266,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/SourceGen/WpfGui/EditLocalVariableTable.xaml b/SourceGen/WpfGui/EditLocalVariableTable.xaml
new file mode 100644
index 0000000..e49a31a
--- /dev/null
+++ b/SourceGen/WpfGui/EditLocalVariableTable.xaml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs b/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs
new file mode 100644
index 0000000..ba0c8ea
--- /dev/null
+++ b/SourceGen/WpfGui/EditLocalVariableTable.xaml.cs
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2019 faddenSoft
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace SourceGen.WpfGui {
+ ///
+ /// Edit a LocalVariableTable.
+ ///
+ public partial class EditLocalVariableTable : Window {
+ // Item for the symbol list view.
+ public class FormattedSymbol {
+ public string Label { get; private set; }
+ public string Value { get; private set; }
+ public string Type { get; private set; }
+ public string Width { get; private set; }
+ public string Comment { get; private set; }
+
+ public FormattedSymbol(string label, string value, string type, string width,
+ string comment) {
+ Label = label;
+ Value = value;
+ Type = type;
+ Width = width;
+ Comment = comment;
+ }
+ }
+ public ObservableCollection Variables { get; private set; } =
+ new ObservableCollection();
+
+ public EditLocalVariableTable(Window owner) {
+ InitializeComponent();
+ Owner = owner;
+ DataContext = this;
+ }
+
+ public void Window_Loaded(object sender, RoutedEventArgs e) {
+ }
+
+ private void OkButton_Click(object sender, RoutedEventArgs e) {
+ DialogResult = true;
+ }
+
+ private void DeleteTableButton_Click(object sender, RoutedEventArgs e) {
+ }
+
+ private void SymbolsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) {
+ }
+
+ private void SymbolsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
+ }
+
+ private void NewSymbolButton_Click(object sender, RoutedEventArgs e) {
+ }
+
+ private void EditSymbolButton_Click(object sender, EventArgs e) {
+ }
+
+ private void RemoveSymbolButton_Click(object sender, RoutedEventArgs e) {
+ }
+ }
+}
diff --git a/SourceGen/WpfGui/MainWindow.xaml b/SourceGen/WpfGui/MainWindow.xaml
index 7f4423d..c17364c 100644
--- a/SourceGen/WpfGui/MainWindow.xaml
+++ b/SourceGen/WpfGui/MainWindow.xaml
@@ -80,6 +80,7 @@ limitations under the License.
Ctrl+L
+
Ctrl+M
@@ -192,6 +193,8 @@ limitations under the License.
CanExecute="IsProjectOpen" Executed="EditHeaderCommentCmd_Executed"/>
+
+
diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs
index ab5c956..b71abbd 100644
--- a/SourceGen/WpfGui/MainWindow.xaml.cs
+++ b/SourceGen/WpfGui/MainWindow.xaml.cs
@@ -951,6 +951,10 @@ namespace SourceGen.WpfGui {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLabel();
}
+ private void CanEditLocalVariableTable(object sender, CanExecuteRoutedEventArgs e) {
+ e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLocalVariableTable();
+ }
+
private void CanEditLongComment(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLongComment();
}
@@ -1081,6 +1085,10 @@ namespace SourceGen.WpfGui {
mMainCtrl.EditLabel();
}
+ private void EditLocalVariableTableCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
+ mMainCtrl.EditLocalVariableTable();
+ }
+
private void EditLongCommentCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditLongComment();
}