From a9913b8b6948698d4ad7450548c4710fc3c4b076 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 25 Dec 2019 19:14:51 -0800 Subject: [PATCH] Fix symbol entry bug in operand editors The un-trimmed symbol was being used, so labels entered with annotation characters (e.g. "FOO?") were failing to be found. --- SourceGen/Symbol.cs | 3 ++- SourceGen/WpfGui/EditDataOperand.xaml.cs | 4 ++-- SourceGen/WpfGui/EditInstructionOperand.xaml.cs | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/SourceGen/Symbol.cs b/SourceGen/Symbol.cs index e6cbd92..15f778e 100644 --- a/SourceGen/Symbol.cs +++ b/SourceGen/Symbol.cs @@ -328,7 +328,8 @@ namespace SourceGen { /// True if the first character indicates that this is /// a non-unique label. /// Annotation found, or None if none found. - /// Trimmed version of the string. + /// Trimmed version of the string, or the original string if an error + /// is encountered. public static string TrimAndValidateLabel(string label, string nonUniquePrefix, out bool isValid, out bool isLenValid, out bool isFirstCharValid, out bool hasNonUniquePrefix, out LabelAnnotation anno) { diff --git a/SourceGen/WpfGui/EditDataOperand.xaml.cs b/SourceGen/WpfGui/EditDataOperand.xaml.cs index c633052..0e28758 100644 --- a/SourceGen/WpfGui/EditDataOperand.xaml.cs +++ b/SourceGen/WpfGui/EditDataOperand.xaml.cs @@ -1026,13 +1026,13 @@ namespace SourceGen.WpfGui { Symbol osym = mProject.FindBestNonUniqueLabel(trimLabel, matchOffset); if (osym != null) { - weakLabel = osym.Label; + trimLabel = osym.Label; } else { Debug.WriteLine("Attempt to create ref to nonexistant non-unique sym"); subType = FormatDescriptor.SubType.Hex; } } - symbolRef = new WeakSymbolRef(weakLabel, part); + symbolRef = new WeakSymbolRef(trimLabel, part); } else { Debug.Assert(false); } diff --git a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs index 1b6b539..6bce253 100644 --- a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs +++ b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs @@ -716,8 +716,6 @@ namespace SourceGen.WpfGui { part = WeakSymbolRef.Part.Low; } - string weakLabel = SymbolLabel; - // Deal with non-unique labels. If the label refers to an existing // symbol, use its label, which will have the tag. If the label doesn't // have a match, discard it -- we don't support weak refs to ambiguous @@ -728,7 +726,7 @@ namespace SourceGen.WpfGui { out Symbol.LabelAnnotation unused3); if (isValid && hasNonUniquePrefix) { if (LookupSymbol(trimLabel, hasNonUniquePrefix, out Symbol sym)) { - weakLabel = sym.Label; + trimLabel = sym.Label; } else { Debug.WriteLine("Attempt to create ref to non-existant non-unique sym"); return null; @@ -736,7 +734,7 @@ namespace SourceGen.WpfGui { } return FormatDescriptor.Create(instructionLength, - new WeakSymbolRef(weakLabel, part), false); + new WeakSymbolRef(trimLabel, part), false); } FormatDescriptor.SubType subType;