1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Wire up variable xrefs

Also, update the EditDefSymbol value range check to take the width
into account.
This commit is contained in:
Andy McFadden 2019-08-29 13:32:45 -07:00
parent e82339573f
commit 4a02cb9846
4 changed files with 42 additions and 13 deletions

View File

@ -1336,6 +1336,23 @@ namespace SourceGen {
}
}
public DefSymbol GetLocalVariableFromLine(int lineIndex) {
Line line = this[lineIndex];
int offset = line.FileOffset;
if (!mProject.LvTables.TryGetValue(offset, out LocalVariableTable lvt)) {
Debug.Assert(false);
return null;
}
int tableIndex = line.SubLineIndex;
if (lvt.ClearPrevious) {
if (--tableIndex < 0) {
return null;
}
}
return lvt[tableIndex];
}
private FormattedParts[] GenerateStringLines(int offset, string popcode,
List<string> operands) {
FormattedParts[] partsArray = new FormattedParts[operands.Count];

View File

@ -2966,20 +2966,28 @@ namespace SourceGen {
LineListGen.Line.Type type = CodeLineList[lineIndex].LineType;
if (type != LineListGen.Line.Type.Code &&
type != LineListGen.Line.Type.Data &&
type != LineListGen.Line.Type.EquDirective) {
type != LineListGen.Line.Type.EquDirective &&
type != LineListGen.Line.Type.LocalVariableTable) {
// Code, data, and platform symbol EQUs have xrefs.
return;
}
// Find the appropriate xref set.
int offset = CodeLineList[lineIndex].FileOffset;
XrefSet xrefs;
if (offset < 0) {
int index = LineListGen.DefSymIndexFromOffset(offset);
DefSymbol defSym = mProject.ActiveDefSymbolList[index];
xrefs = defSym.Xrefs;
// Find the appropriate xref set.
if (type == LineListGen.Line.Type.LocalVariableTable) {
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(lineIndex);
xrefs = (defSym == null) ? null : defSym.Xrefs;
} else {
xrefs = mProject.GetXrefSet(offset);
int offset = CodeLineList[lineIndex].FileOffset;
if (offset < 0) {
// EQU in header
int index = LineListGen.DefSymIndexFromOffset(offset);
DefSymbol defSym = mProject.ActiveDefSymbolList[index];
xrefs = defSym.Xrefs;
} else {
xrefs = mProject.GetXrefSet(offset);
}
}
if (xrefs == null || xrefs.Count == 0) {
return;

View File

@ -52,7 +52,7 @@ limitations under the License.
<StackPanel Grid.Column="1" Grid.Row="1">
<TextBox Margin="0,1,0,0" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Name="valueRangeLabel" Text="• Value between 0-255" Margin="0,4,0,0"/>
<TextBlock Name="valueRangeLabel" Text="• Value between 0-255, including width" Margin="0,4,0,0"/>
<TextBlock Name="valueUniqueLabel" Text="• Values in table must not overlap" Margin="0,4,0,0"/>
<TextBlock Name="valueNotesLabel" Text="• Decimal, hex ($), or binary (%)" Margin="0,4,0,16"/>
</StackPanel>

View File

@ -196,10 +196,6 @@ namespace SourceGen.WpfGui {
//} else {
// valueValid = true;
//}
bool valueRangeValid = true;
if (mIsVariable && valueValid && (thisValue < 0 || thisValue > 255)) {
valueRangeValid = false;
}
bool widthValid = true;
int thisWidth = 0;
@ -210,6 +206,14 @@ namespace SourceGen.WpfGui {
}
}
bool valueRangeValid = true;
if (mIsVariable && valueValid && widthValid) {
// $ff with width 1 is okay, $ff with width 2 is not
if (thisValue < 0 || thisValue + thisWidth > 256) {
valueRangeValid = false;
}
}
Symbol.Type symbolType = IsConstant ? Symbol.Type.Constant : Symbol.Type.ExternalAddr;
// For a variable, the value must also be unique within the table. Values have