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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +