mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-21 10:16:42 +00:00
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out pretty well, so we're going to try adding the same thing to project and platform symbols. The first step is to allow widths to be specified in platform files, and set with the project symbol editor. The DefSymbol editor is also used for local variables, so a bit of dancing is required. For platform/project symbols the width is optional, and is totally ignored for constants. (For variables, constants are used for the StackRel args, so the width is meaningful and required.) We also now show the symbol's type (address or constant) and width in the listing. This gets really distracting when overused, so we only show it when the width is explicitly set. The default width is 1, which most things will be, so users can make an aesthetic choice there. (The place where widths make very little sense is when the symbol represents a code entry point, rather than a data item.) The maximum width of a local variable is now 256, but it's not allowed to overlap with other variables or run of the end of the direct page. The maximum width of a platform/project symbol is 65536, with bank-wrap behavior TBD. The local variable table editor now refers to stack-relative constants as such, rather than simply "constant", to make it clear that it's not just defining an 8-bit constant. Widths have been added to a handful of Apple II platform defs.
This commit is contained in:
@@ -311,10 +311,13 @@ namespace SourceGen {
|
||||
public class SerDefSymbol : SerSymbol {
|
||||
public SerFormatDescriptor DataDescriptor { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public bool HasWidth { get; set; }
|
||||
// Tag not relevant, Xrefs not recorded
|
||||
|
||||
public SerDefSymbol() { }
|
||||
public SerDefSymbol(DefSymbol defSym) : base(defSym) {
|
||||
DataDescriptor = new SerFormatDescriptor(defSym.DataDescriptor);
|
||||
HasWidth = defSym.HasWidth;
|
||||
Comment = defSym.Comment;
|
||||
}
|
||||
}
|
||||
@@ -736,7 +739,7 @@ namespace SourceGen {
|
||||
return false;
|
||||
}
|
||||
|
||||
outDefSym = new DefSymbol(sym, dfd, serDefSym.Comment);
|
||||
outDefSym = new DefSymbol(sym, dfd, serDefSym.HasWidth, serDefSym.Comment);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -837,13 +840,20 @@ namespace SourceGen {
|
||||
outLvt = new LocalVariableTable();
|
||||
outLvt.ClearPrevious = serTable.ClearPrevious;
|
||||
foreach (SerDefSymbol serDef in serTable.Variables) {
|
||||
// Force the "has width" field to true for local variables, because it's
|
||||
// non-optional there. This is really only needed for loading projects
|
||||
// created in v1.3, which didn't have the "has width" property.
|
||||
serDef.HasWidth = true;
|
||||
if (!CreateDefSymbol(serDef, contentVersion, report, out DefSymbol defSym)) {
|
||||
return false;
|
||||
}
|
||||
if (!defSym.IsVariable) {
|
||||
// not expected to happen
|
||||
// not expected to happen; skip it
|
||||
Debug.WriteLine("Found local variable with bad source: " +
|
||||
defSym.SymbolSource);
|
||||
string str = string.Format(Res.Strings.ERR_BAD_LOCAL_VARIABLE_FMT,
|
||||
defSym);
|
||||
report.Add(FileLoadItem.Type.Warning, str);
|
||||
continue;
|
||||
}
|
||||
outLvt.AddOrReplace(defSym);
|
||||
|
||||
Reference in New Issue
Block a user