1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

SGEC tweaks

Don't allow comments to be set in the middle of an instruction or
multi-byte data item.  The subsequent partial update confuses the
line list generator.

Change order of note/long-comment/comment to match display.
This commit is contained in:
Andy McFadden 2020-07-16 10:14:28 -07:00
parent 0860a00a54
commit 9a56ae8544
2 changed files with 22 additions and 10 deletions

View File

@ -4421,8 +4421,12 @@ namespace SourceGen {
if (!Sgec.ImportFromFile(sgecPathName, mProject, cs, out string detailMsg)) {
MessageBox.Show("Failed: " + detailMsg);
} else {
ApplyUndoableChanges(cs);
MessageBox.Show("Success: " + detailMsg);
if (cs.Count != 0) {
ApplyUndoableChanges(cs);
MessageBox.Show("Success: " + detailMsg);
} else {
MessageBox.Show("Success; no changes were made.");
}
}
}

View File

@ -100,10 +100,12 @@ namespace SourceGen {
int prevOffset = -1;
using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
for (int offset = 0; offset < proj.FileDataLength; offset++) {
if (!string.IsNullOrEmpty(proj.Comments[offset])) {
sw.WriteLine(SET_COMMENT + " " +
if (proj.Notes.TryGetValue(offset, out MultiLineComment nt)) {
SerMultiLineComment serCom = new SerMultiLineComment(nt);
string cereal = ser.Serialize(serCom);
sw.WriteLine(SET_NOTE + " " +
PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' +
proj.Comments[offset]);
cereal);
prevOffset = offset;
numItems++;
}
@ -116,12 +118,10 @@ namespace SourceGen {
prevOffset = offset;
numItems++;
}
if (proj.Notes.TryGetValue(offset, out MultiLineComment nt)) {
SerMultiLineComment serCom = new SerMultiLineComment(nt);
string cereal = ser.Serialize(serCom);
sw.WriteLine(SET_NOTE + " " +
if (!string.IsNullOrEmpty(proj.Comments[offset])) {
sw.WriteLine(SET_COMMENT + " " +
PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' +
cereal);
proj.Comments[offset]);
prevOffset = offset;
numItems++;
}
@ -201,6 +201,14 @@ namespace SourceGen {
prevOffset = offset;
if (!proj.GetAnattrib(offset).IsStart) {
// This causes problems when we try to do a LineListGen update, because
// we specifically request it to do the modified offset, which happens to
// be in the middle of an instruction, and it gets very confused.
detailMsg = "Line " + lineNum + ": attempt to modify middle of instr/data item";
return false;
}
string cmdStr = matches[0].Groups[GROUP_CMD].Value;
string valueStr = matches[0].Groups[GROUP_VALUE].Value;
switch (cmdStr) {