1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 07:50:37 +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)) { if (!Sgec.ImportFromFile(sgecPathName, mProject, cs, out string detailMsg)) {
MessageBox.Show("Failed: " + detailMsg); MessageBox.Show("Failed: " + detailMsg);
} else { } else {
if (cs.Count != 0) {
ApplyUndoableChanges(cs); ApplyUndoableChanges(cs);
MessageBox.Show("Success: " + detailMsg); MessageBox.Show("Success: " + detailMsg);
} else {
MessageBox.Show("Success; no changes were made.");
}
} }
} }

View File

@ -100,10 +100,12 @@ namespace SourceGen {
int prevOffset = -1; int prevOffset = -1;
using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) { using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
for (int offset = 0; offset < proj.FileDataLength; offset++) { for (int offset = 0; offset < proj.FileDataLength; offset++) {
if (!string.IsNullOrEmpty(proj.Comments[offset])) { if (proj.Notes.TryGetValue(offset, out MultiLineComment nt)) {
sw.WriteLine(SET_COMMENT + " " + SerMultiLineComment serCom = new SerMultiLineComment(nt);
string cereal = ser.Serialize(serCom);
sw.WriteLine(SET_NOTE + " " +
PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' + PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' +
proj.Comments[offset]); cereal);
prevOffset = offset; prevOffset = offset;
numItems++; numItems++;
} }
@ -116,12 +118,10 @@ namespace SourceGen {
prevOffset = offset; prevOffset = offset;
numItems++; numItems++;
} }
if (proj.Notes.TryGetValue(offset, out MultiLineComment nt)) { if (!string.IsNullOrEmpty(proj.Comments[offset])) {
SerMultiLineComment serCom = new SerMultiLineComment(nt); sw.WriteLine(SET_COMMENT + " " +
string cereal = ser.Serialize(serCom);
sw.WriteLine(SET_NOTE + " " +
PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' + PositionStr(offset, prevOffset, proj.AddrMap, relMode) + ':' +
cereal); proj.Comments[offset]);
prevOffset = offset; prevOffset = offset;
numItems++; numItems++;
} }
@ -201,6 +201,14 @@ namespace SourceGen {
prevOffset = offset; 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 cmdStr = matches[0].Groups[GROUP_CMD].Value;
string valueStr = matches[0].Groups[GROUP_VALUE].Value; string valueStr = matches[0].Groups[GROUP_VALUE].Value;
switch (cmdStr) { switch (cmdStr) {