mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-17 09:04:43 +00:00
Wire up variable xrefs
Also, update the EditDefSymbol value range check to take the width into account.
This commit is contained in:
parent
e82339573f
commit
4a02cb9846
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user