1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-07-05 09:28:56 +00:00

Expand set of symbols available to plugins

We were providing platform symbols to plugins through the PlatSym
list, which allowed them to find constants and well-known addresses.
We now pass all project symbols and user labels in as well.  The
name "PlatSym" is no longer accurate, so the class has been renamed.

Also, added a bunch of things to the problem list viewer, and
added some more info to the Info panel.

Also, added a minor test to 2011-hinting that does not affect the
output (which is the point).
This commit is contained in:
Andy McFadden 2019-10-04 16:53:31 -07:00
parent 3172ea0b70
commit 3c3209b67f
18 changed files with 339 additions and 171 deletions

View File

@ -28,11 +28,6 @@ namespace PluginCommon {
/// </summary>
string Identifier { get; }
/// <summary>
/// Returns true if this plugin checks JSR/JSL for inline data.
/// </summary>
//bool HasInlineDataAnalyzer { get; }
/// <summary>
/// Initializes the plugin with an application reference and a buffer with file
/// data. Called before each analysis pass.
@ -43,8 +38,8 @@ namespace PluginCommon {
/// </summary>
/// <param name="appRef">Reference to application interface.</param>
/// <param name="fileData">65xx code and data.</param>
/// <param name="platSyms">Platform symbols, in no particular order.</param>
void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms);
/// <param name="plSyms">Symbols available to plugins, in no particular order.</param>
void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSyms);
}
public interface IPlugin_InlineJsr {

142
PluginCommon/PlSymbol.cs Normal file
View File

@ -0,0 +1,142 @@
/*
* Copyright 2018 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;
using System.Text;
namespace PluginCommon {
/// <summary>
/// Plugin-accessible symbol, for use in extension scripts.
///
/// Instances are immutable.
/// </summary>
[Serializable]
public class PlSymbol {
/// <summary>
/// Subset of Symbol.Source. Does not include auto-generated labels or variables.
/// </summary>
public enum Source {
Unknown = 0,
User,
Project,
Platform
}
/// <summary>
/// Subset of Symbol.Type. Does not specify local vs. global or export.
/// </summary>
public enum Type {
Unknown = 0,
Address,
Constant
}
/// <summary>
/// Label sent to assembler.
/// </summary>
public string Label { get; private set; }
/// <summary>
/// Symbol's numeric value.
/// </summary>
public int Value { get; private set; }
/// <summary>
/// Symbol origin.
/// </summary>
private Source SymbolSource { get; set; }
public bool IsUserSymbol { get { return SymbolSource == Source.User; } }
public bool IsProjectSymbol { get { return SymbolSource == Source.Project; } }
public bool IsPlatformSymbol { get { return SymbolSource == Source.Platform; } }
/// <summary>
/// Symbol type.
/// </summary>
private Type SymbolType { get; set; }
public bool IsAddress { get { return SymbolType == Type.Address; } }
public bool IsConstant { get { return SymbolType == Type.Constant; } }
/// <summary>
/// Platform/project symbols only: width, in bytes, of data at symbol. Will be -1
/// for user labels.
/// </summary>
public int Width { get; private set; }
/// <summary>
/// Platform symbols only: tag used to organize symbols into groups..
/// </summary>
public string Tag { get; private set; }
/// <summary>
/// Nullary constructor, for deserialization.
/// </summary>
private PlSymbol() { }
/// <summary>
/// Constructor.
/// </summary>
/// <param name="label">Symbol label.</param>
/// <param name="value">Symbol value.</param>
/// <param name="tag">Symbol group tag.</param>
public PlSymbol(string label, int value, int width, Source source, Type type, string tag) {
Label = label;
Value = value;
Width = width;
SymbolSource = source;
SymbolType = type;
Tag = tag;
}
/// <summary>
/// Generates a dictionary of platform symbols, keyed by value. Only symbols with
/// a matching tag are included. If more than one symbol has the same value, only
/// one will be included; which one it will be is undefined.
/// </summary>
/// <param name="ppuSyms">List of platform symbols to select from.</param>
/// <param name="tag">Tag to match, or null to collect all symbols.</param>
/// <param name="appRef">Application reference, for debug log output.</param>
/// <returns>Dictionary of matching platform symbols.</returns>
public static Dictionary<int, PlSymbol> GeneratePlatformValueList(List<PlSymbol> ppuSyms,
string tag, IApplication appRef) {
Dictionary<int, PlSymbol> dict = new Dictionary<int, PlSymbol>();
foreach (PlSymbol ps in ppuSyms) {
if (ps.SymbolSource != Source.Platform) {
continue;
}
if (tag == null || tag == ps.Tag) {
try {
dict.Add(ps.Value, ps);
} catch (ArgumentException) {
appRef.DebugLog("WARNING: GenerateValueList: multiple entries with " +
"value " + ps.Value.ToString("x4"));
}
}
}
if (dict.Count == 0) {
appRef.DebugLog("PlSymbol: no symbols found for tag=" + tag);
}
return dict;
}
public override string ToString() {
return Label + "=" + Value.ToString("x4") + " [" + Tag + "]";
}
}
}

View File

@ -1,84 +0,0 @@
/*
* Copyright 2018 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;
using System.Text;
namespace PluginCommon {
/// <summary>
/// Symbols loaded from platform symbol files, for use in extension scripts.
///
/// Instances are immutable.
/// </summary>
[Serializable]
public class PlatSym {
public string Label { get; private set; }
public int Value { get; private set; }
public string Tag { get; private set; }
/// <summary>
/// Nullary constructor, for deserialization.
/// </summary>
private PlatSym() { }
/// <summary>
/// Constructor.
/// </summary>
/// <param name="label">Symbol label.</param>
/// <param name="value">Symbol value.</param>
/// <param name="tag">Symbol group tag.</param>
public PlatSym(string label, int value, string tag) {
Label = label;
Value = value;
Tag = tag;
}
/// <summary>
/// Generates a dictionary of platform symbols, keyed by value. Only symbols with
/// a matching tag are included. If more than one symbol has the same value, only
/// one will be included; which one it will be is undefined.
/// </summary>
/// <param name="platSyms">List of platform symbols to select from.</param>
/// <param name="tag">Tag to match, or null to collect all symbols.</param>
/// <param name="appRef">Application reference, for debug log output.</param>
/// <returns></returns>
public static Dictionary<int, PlatSym> GenerateValueList(List<PlatSym> platSyms,
string tag, IApplication appRef) {
Dictionary<int, PlatSym> dict = new Dictionary<int, PlatSym>();
foreach (PlatSym ps in platSyms) {
if (tag == null || tag == ps.Tag) {
try {
dict.Add(ps.Value, ps);
} catch (ArgumentException) {
appRef.DebugLog("WARNING: GenerateValueList: multiple entries with " +
"value " + ps.Value.ToString("x4"));
}
}
}
if (dict.Count == 0) {
appRef.DebugLog("PlatSym: no symbols found for tag=" + tag);
}
return dict;
}
public override string ToString() {
return Label + "=" + Value.ToString("x4") + " [" + Tag + "]";
}
}
}

View File

@ -152,9 +152,9 @@ namespace PluginCommon {
/// Invokes the Prepare() method on all active plugins.
/// </summary>
/// <param name="appRef">Reference to host object providing app services.</param>
public void PreparePlugins(IApplication appRef, List<PlatSym> platSyms) {
public void PreparePlugins(IApplication appRef, List<PlSymbol> plSyms) {
foreach (KeyValuePair<string, IPlugin> kvp in mActivePlugins) {
kvp.Value.Prepare(appRef, mFileData, platSyms);
kvp.Value.Prepare(appRef, mFileData, plSyms);
}
}

View File

@ -823,7 +823,8 @@ namespace SourceGen {
/// </summary>
/// <param name="genLog">Log for debug messages.</param>
private void ApplyFormatDescriptors(DebugLog genLog) {
// TODO: add these to ProblemList
genLog.LogI("Applying format descriptors");
foreach (KeyValuePair<int, FormatDescriptor> kvp in OperandFormats) {
int offset = kvp.Key;
@ -834,16 +835,29 @@ namespace SourceGen {
// Check offset.
if (offset < 0 || offset >= mAnattribs.Length) {
genLog.LogE("Invalid offset +" + offset.ToString("x6") +
"(desc=" + kvp.Value + ")");
string msg = "invalid offset (desc=" + kvp.Value + ")";
genLog.LogE("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Error,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidOffsetOrLength,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
Debug.Assert(false);
continue; // ignore this one
}
// Make sure it doesn't run off the end
if (offset + kvp.Value.Length > mAnattribs.Length) {
genLog.LogE("Invalid offset+len +" + offset.ToString("x6") +
" len=" + kvp.Value.Length + " file=" + mAnattribs.Length);
string msg = "invalid offset+len: len=" + kvp.Value.Length +
" file=" + mAnattribs.Length;
genLog.LogE("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Error,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidOffsetOrLength,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
Debug.Assert(false);
continue; // ignore this one
}
@ -853,25 +867,50 @@ namespace SourceGen {
// a bunch of bytes as single-byte data items and then add a code entry
// point.
if (kvp.Value.Length != mAnattribs[offset].Length) {
genLog.LogW("+" + offset.ToString("x6") +
": unexpected length on instr format descriptor (" +
kvp.Value.Length + " vs " + mAnattribs[offset].Length + ")");
string msg = "unexpected length on instr format descriptor (" +
kvp.Value.Length + " vs " + mAnattribs[offset].Length + ")";
genLog.LogW("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Warning,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidOffsetOrLength,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
continue; // ignore this one
}
if (kvp.Value.Length == 1) {
// No operand to format!
genLog.LogW("+" + offset.ToString("x6") +
": unexpected format descriptor on single-byte op");
string msg = "unexpected format descriptor on single-byte op";
genLog.LogW("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Warning,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidDescriptor,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
continue; // ignore this one
}
if (!kvp.Value.IsValidForInstruction) {
genLog.LogW("Descriptor not valid for instruction: " + kvp.Value);
string msg = "descriptor not valid for instruction: " + kvp.Value;
genLog.LogW("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Warning,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidDescriptor,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
continue; // ignore this one
}
} else if (mAnattribs[offset].IsInstruction) {
// Mid-instruction format.
genLog.LogW("+" + offset.ToString("x6") +
": unexpected mid-instruction format descriptor");
string msg = "unexpected mid-instruction format descriptor";
genLog.LogW("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Warning,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidDescriptor,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
continue; // ignore this one
} else {
// Data or inline data. The data analyzer hasn't run yet. We want to
@ -889,8 +928,15 @@ namespace SourceGen {
bool overlap = false;
for (int i = offset; i < offset + kvp.Value.Length; i++) {
if (mAnattribs[i].IsInstruction) {
genLog.LogW("+" + offset.ToString("x6") +
": data format descriptor overlaps code at +" + i.ToString("x6"));
string msg =
"data format descriptor overlaps code at +" + i.ToString("x6");
genLog.LogW("+" + offset.ToString("x6") + ": " + msg);
Problems.Add(new ProblemList.ProblemEntry(
ProblemList.ProblemEntry.SeverityLevel.Warning,
offset,
ProblemList.ProblemEntry.ProblemType.InvalidDescriptor,
msg,
ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored));
overlap = true;
break;
}

View File

@ -370,49 +370,50 @@ namespace SourceGen {
public string ToUiString() {
// NOTE: this should be made easier to localize
string retstr = Length + "-byte ";
if (IsString) {
string descr;
switch (FormatSubType) {
case SubType.Ascii:
descr = "ASCII";
retstr += "ASCII";
break;
case SubType.HighAscii:
descr = "ASCII (high)";
retstr += "ASCII (high)";
break;
case SubType.C64Petscii:
descr = "C64 PETSCII";
retstr += "C64 PETSCII";
break;
case SubType.C64Screen:
descr = "C64 Screen";
retstr += "C64 Screen";
break;
default:
descr = "???";
retstr += "???";
break;
}
switch (FormatType) {
case Type.StringGeneric:
descr += " string";
retstr += " string";
break;
case Type.StringReverse:
descr += " string (reverse)";
retstr += " string (reverse)";
break;
case Type.StringNullTerm:
descr += " string (null term)";
retstr += " string (null term)";
break;
case Type.StringL8:
descr += " string (1-byte len)";
retstr += " string (1-byte len)";
break;
case Type.StringL16:
descr += " string (2-byte len)";
retstr += " string (2-byte len)";
break;
case Type.StringDci:
descr += " string (DCI)";
retstr += " string (DCI)";
break;
default:
descr += " ???";
retstr += " ???";
break;
}
return descr;
return retstr;
}
switch (FormatSubType) {
@ -420,43 +421,60 @@ namespace SourceGen {
switch (FormatType) {
case Type.Default:
case Type.NumericLE:
return "Numeric (little-endian)";
retstr += "Numeric (little-endian)";
break;
case Type.NumericBE:
return "Numeric (big-endian)";
retstr += "Numeric (big-endian)";
break;
case Type.Dense:
return "Dense";
retstr += "Dense";
break;
case Type.Fill:
return "Fill";
retstr += "Fill";
break;
default:
// strings handled earlier
return "???";
retstr += "???";
break;
}
break;
case SubType.Hex:
return "Numeric, Hex";
retstr += "Numeric, Hex";
break;
case SubType.Decimal:
return "Numeric, Decimal";
retstr += "Numeric, Decimal";
break;
case SubType.Binary:
return "Numeric, Binary";
retstr += "Numeric, Binary";
break;
case SubType.Address:
return "Address";
retstr += "Address";
break;
case SubType.Symbol:
if (SymbolRef.IsVariable) {
return "Local var \"" + SymbolRef.Label + "\"";
retstr += "Local var \"" + SymbolRef.Label + "\"";
} else {
return "Symbol \"" + SymbolRef.Label + "\"";
retstr += "Symbol \"" + SymbolRef.Label + "\"";
}
break;
case SubType.Ascii:
return "Numeric, ASCII";
retstr += "Numeric, ASCII";
break;
case SubType.HighAscii:
return "Numeric, ASCII (high)";
retstr += "Numeric, ASCII (high)";
break;
case SubType.C64Petscii:
return "Numeric, C64 PETSCII";
retstr += "Numeric, C64 PETSCII";
break;
case SubType.C64Screen:
return "Numeric, C64 Screen";
retstr += "Numeric, C64 Screen";
break;
default:
return "???";
retstr += "???";
break;
}
return retstr;
}
public override string ToString() {

View File

@ -47,6 +47,8 @@ namespace SourceGen {
Unknown = 0,
HiddenLabel,
UnresolvedWeakRef,
InvalidOffsetOrLength,
InvalidDescriptor,
}
public ProblemType Problem { get; private set; }

View File

@ -40,7 +40,7 @@ namespace RuntimeData.Apple {
private IApplication mAppRef;
private byte[] mFileData;
private Dictionary<int, PlatSym> mFunctionList;
private Dictionary<int, PlSymbol> mFunctionList;
public string Identifier {
get {
@ -48,14 +48,14 @@ namespace RuntimeData.Apple {
}
}
public void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms) {
public void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSyms) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("GSOS(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
//System.Diagnostics.Debugger.Break();
mFunctionList = PlatSym.GenerateValueList(platSyms, GSOS_FUNC_TAG, appRef);
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, GSOS_FUNC_TAG, appRef);
}
public void CheckJsl(int offset, out bool noContinue) {
@ -71,7 +71,7 @@ namespace RuntimeData.Apple {
", cmd=$" + req.ToString("x4") + " addr=$" + addr.ToString("x6"));
}
PlatSym sym;
PlSymbol sym;
if (mFunctionList.TryGetValue(req, out sym)) {
mAppRef.SetInlineDataFormat(offset + 4, 2, DataType.NumericLE,
DataSubType.Symbol, sym.Label);

View File

@ -33,7 +33,7 @@ namespace RuntimeData.Apple {
private IApplication mAppRef;
private byte[] mFileData;
private Dictionary<int, PlatSym> mFunctionList;
private Dictionary<int, PlSymbol> mFunctionList;
public string Identifier {
get {
@ -41,13 +41,13 @@ namespace RuntimeData.Apple {
}
}
public void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms) {
public void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSyms) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("IIgsToolbox(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
mFunctionList = PlatSym.GenerateValueList(platSyms, TOOLBOX_FUNC_TAG, appRef);
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, TOOLBOX_FUNC_TAG, appRef);
}
public void CheckJsl(int offset, out bool noContinue) {
@ -67,7 +67,7 @@ namespace RuntimeData.Apple {
", func=$" + func.ToString("x4"));
}
PlatSym sym;
PlSymbol sym;
if (mFunctionList.TryGetValue(func, out sym)) {
mAppRef.SetOperandFormat(offset - 3, DataSubType.Symbol, sym.Label);
}

View File

@ -35,7 +35,7 @@ namespace RuntimeData.Apple {
private IApplication mAppRef;
private byte[] mFileData;
private Dictionary<int, PlatSym> mFunctionList;
private Dictionary<int, PlSymbol> mFunctionList;
public string Identifier {
get {
@ -43,14 +43,14 @@ namespace RuntimeData.Apple {
}
}
public void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms) {
public void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSyms) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("ProDOS(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
//System.Diagnostics.Debugger.Break();
mFunctionList = PlatSym.GenerateValueList(platSyms, P8_MLI_TAG, appRef);
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, P8_MLI_TAG, appRef);
}
public void CheckJsr(int offset, out bool noContinue) {
@ -66,7 +66,7 @@ namespace RuntimeData.Apple {
", cmd=$" + req.ToString("x2") + " addr=$" + addr.ToString("x4"));
}
PlatSym sym;
PlSymbol sym;
if (mFunctionList.TryGetValue(req, out sym)) {
mAppRef.SetInlineDataFormat(offset + 3, 1, DataType.NumericLE,
DataSubType.Symbol, sym.Label);

View File

@ -35,7 +35,7 @@ namespace RuntimeData.Apple {
private IApplication mAppRef;
private byte[] mFileData;
private Dictionary<int, PlatSym> mFunctionList;
private Dictionary<int, PlSymbol> mFunctionList;
public string Identifier {
get {
@ -43,14 +43,14 @@ namespace RuntimeData.Apple {
}
}
public void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms) {
public void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSyms) {
mAppRef = appRef;
mFileData = fileData;
mAppRef.DebugLog("SOS(id=" + AppDomain.CurrentDomain.Id + "): prepare()");
//System.Diagnostics.Debugger.Break();
mFunctionList = PlatSym.GenerateValueList(platSyms, SOS_MLI_TAG, appRef);
mFunctionList = PlSymbol.GeneratePlatformValueList(plSyms, SOS_MLI_TAG, appRef);
}
public void CheckBrk(int offset, out bool noContinue) {
@ -70,7 +70,7 @@ namespace RuntimeData.Apple {
", cmd=$" + req.ToString("x2") + " addr=$" + addr.ToString("x4"));
}
PlatSym sym;
PlSymbol sym;
if (!mFunctionList.TryGetValue(req, out sym)) {
return;
}

View File

@ -17,7 +17,7 @@ namespace RuntimeData.Test2011 {
}
}
public void Prepare(IApplication appRef, byte[] fileData, List<PlatSym> platSyms) {
public void Prepare(IApplication appRef, byte[] fileData, List<PlSymbol> plSymbols) {
mAppRef = appRef;
mFileData = fileData;

View File

@ -26,6 +26,8 @@
"UserLabels":{
},
"OperandFormats":{
"13":{
"Length":1,"Format":"NumericLE","SubFormat":"Decimal","SymbolRef":null},
"51":{
"Length":3,"Format":"Dense","SubFormat":"None","SymbolRef":null},
"66":{

View File

@ -156,39 +156,73 @@ namespace SourceGen.Sandbox {
/// </summary>
/// <param name="appRef">Reference to object providing app services.</param>
public void PrepareScripts(IApplication appRef) {
List<PlatSym> platSyms = GeneratePlatSymList();
List<PlSymbol> plSyms = GeneratePlSymbolList();
if (DomainMgr == null) {
foreach (KeyValuePair<string, IPlugin> kvp in mActivePlugins) {
kvp.Value.Prepare(appRef, mProject.FileData, platSyms);
kvp.Value.Prepare(appRef, mProject.FileData, plSyms);
}
} else {
DomainMgr.PluginMgr.PreparePlugins(appRef, platSyms);
DomainMgr.PluginMgr.PreparePlugins(appRef, plSyms);
}
}
/// <summary>
/// Gathers a list of platform symbols from the project's symbol table.
/// </summary>
private List<PlatSym> GeneratePlatSymList() {
List<PlatSym> platSyms = new List<PlatSym>();
private List<PlSymbol> GeneratePlSymbolList() {
List<PlSymbol> plSymbols = new List<PlSymbol>();
SymbolTable symTab = mProject.SymbolTable;
foreach (Symbol sym in symTab) {
if (!(sym is DefSymbol)) {
// ignore user labels
continue;
PlSymbol.Source plsSource;
switch (sym.SymbolSource) {
case Symbol.Source.Platform:
plsSource = PlSymbol.Source.Platform;
break;
case Symbol.Source.Project:
plsSource = PlSymbol.Source.Project;
break;
case Symbol.Source.User:
plsSource = PlSymbol.Source.User;
break;
case Symbol.Source.Variable:
case Symbol.Source.Auto:
// don't forward these to plugins
continue;
default:
Debug.Assert(false);
continue;
}
DefSymbol defSym = sym as DefSymbol;
if (defSym.SymbolSource != Symbol.Source.Platform) {
// ignore project symbols
continue;
PlSymbol.Type plsType;
switch (sym.SymbolType) {
case Symbol.Type.LocalOrGlobalAddr:
case Symbol.Type.GlobalAddr:
case Symbol.Type.GlobalAddrExport:
case Symbol.Type.ExternalAddr:
plsType = PlSymbol.Type.Address;
break;
case Symbol.Type.Constant:
plsType = PlSymbol.Type.Constant;
break;
default:
Debug.Assert(false);
continue;
}
platSyms.Add(new PlatSym(defSym.Label, defSym.Value, defSym.Tag));
int width = -1;
string tag = string.Empty;
if (sym is DefSymbol) {
DefSymbol defSym = sym as DefSymbol;
width = defSym.DataDescriptor.Length;
tag = defSym.Tag;
}
plSymbols.Add(new PlSymbol(sym.Label, sym.Value, width, plsSource, plsType, tag));
}
return platSyms;
return plSymbols;
}
/// <summary>

View File

@ -52,11 +52,10 @@ namespace SourceGen {
/// <summary>
/// True if the symbol's type is an internal label (auto or user). Will be false
/// for external addresses and constants.
/// for external addresses (including variables) and constants.
/// </summary>
public bool IsInternalLabel {
get {
// Could also check Type instead. Either works for now.
return SymbolSource == Source.User || SymbolSource == Source.Auto;
}
}

View File

@ -252,8 +252,14 @@ namespace SourceGen {
// These have a width of 1 and can't overlap with anything meaningful... even
// if there's a project symbol for the address, it won't be used, because it's
// an in-file address. So we can just remove the entry.
//
// Note we do this *a lot* when the fancier auto labels are enabled, because we
// generate plain labels and then replace them with annotated labels.
mSymbolsByAddress.Remove(sym.Value);
return;
}
// Removing a project/platform symbol requires re-evaluating the by-address table.
RegenerateAddressTable();
}

View File

@ -29,6 +29,8 @@ limitations under the License.
<Window.Resources>
<system:String x:Key="str_HiddenLabel">Hidden label</system:String>
<system:String x:Key="str_UnresolvedWeakRef">Ref'd symbol not found</system:String>
<system:String x:Key="str_InvalidOffsetOrLength">Invalid offset or len</system:String>
<system:String x:Key="str_InvalidDescriptor">Invalid format desc</system:String>
<system:String x:Key="str_LabelIgnored">Label ignored</system:String>
<system:String x:Key="str_FormatDescriptorIgnored">Format ignored</system:String>

View File

@ -101,6 +101,12 @@ namespace SourceGen.Tools.WpfGui {
case ProblemList.ProblemEntry.ProblemType.UnresolvedWeakRef:
problem = (string)FindResource("str_UnresolvedWeakRef");
break;
case ProblemList.ProblemEntry.ProblemType.InvalidOffsetOrLength:
problem = (string)FindResource("str_InvalidOffsetOrLength");
break;
case ProblemList.ProblemEntry.ProblemType.InvalidDescriptor:
problem = (string)FindResource("str_InvalidDescriptor");
break;
default:
problem = "???";
break;