mirror of
https://github.com/pfusik/xasm.git
synced 2025-02-07 01:30:39 +00:00
parent
a0bfe1366d
commit
7ad066fc6f
36
source/app.d
36
source/app.d
@ -1080,24 +1080,22 @@ File openInputFile(string filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File openOutputFile(char letter, string defaultExt) {
|
File openOutputFile(string filename, string msg) {
|
||||||
string filename = optionParameters[letter - 'a'];
|
|
||||||
if (filename is null)
|
|
||||||
filename = sourceFilename.setExtension(defaultExt);
|
|
||||||
if (letter == 'o')
|
|
||||||
objectFilename = filename;
|
|
||||||
try {
|
try {
|
||||||
return File(filename, "wb");
|
return File(filename, "wb");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new AssemblyError(e.msg);
|
throw new AssemblyError(e.msg);
|
||||||
}
|
}
|
||||||
|
if (!getOption('q'))
|
||||||
|
writeln(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ensureListingFileOpen(char letter, string msg) {
|
void ensureListingFileOpen(char letter, string msg) {
|
||||||
if (!listingStream.isOpen) {
|
if (!listingStream.isOpen) {
|
||||||
listingStream = openOutputFile(letter, "lst");
|
string filename = optionParameters[letter - 'a'];
|
||||||
if (!getOption('q'))
|
if (filename is null)
|
||||||
write(msg);
|
filename = sourceFilename.setExtension("lst");
|
||||||
|
listingStream = openOutputFile(filename, msg);
|
||||||
listingStream.writeln(TITLE);
|
listingStream.writeln(TITLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1124,7 +1122,7 @@ void listLine() {
|
|||||||
return;
|
return;
|
||||||
if (getOption('i') && includeLevel > 0)
|
if (getOption('i') && includeLevel > 0)
|
||||||
return;
|
return;
|
||||||
ensureListingFileOpen('l', "Writing listing file...\n");
|
ensureListingFileOpen('l', "Writing listing file...");
|
||||||
if (currentFilename != lastListedFilename) {
|
if (currentFilename != lastListedFilename) {
|
||||||
listingStream.writeln("Source: ", currentFilename);
|
listingStream.writeln("Source: ", currentFilename);
|
||||||
lastListedFilename = currentFilename;
|
lastListedFilename = currentFilename;
|
||||||
@ -1156,7 +1154,7 @@ void listCommentLine() {
|
|||||||
void listLabelTable() {
|
void listLabelTable() {
|
||||||
if (optionParameters['t' - 'a'] !is null && listingStream.isOpen)
|
if (optionParameters['t' - 'a'] !is null && listingStream.isOpen)
|
||||||
listingStream.close();
|
listingStream.close();
|
||||||
ensureListingFileOpen('t', "Writing label table...\n");
|
ensureListingFileOpen('t', "Writing label table...");
|
||||||
listingStream.writeln("Label table:");
|
listingStream.writeln("Label table:");
|
||||||
foreach (string name; sort(labelTable.keys)) {
|
foreach (string name; sort(labelTable.keys)) {
|
||||||
Label l = labelTable[name];
|
Label l = labelTable[name];
|
||||||
@ -1182,11 +1180,8 @@ void objectByte(ubyte b) {
|
|||||||
} else {
|
} else {
|
||||||
assert(pass2);
|
assert(pass2);
|
||||||
if (!optionObject) return;
|
if (!optionObject) return;
|
||||||
if (!objectStream.isOpen) {
|
if (!objectStream.isOpen)
|
||||||
objectStream = openOutputFile('o', "obx");
|
objectStream = openOutputFile(objectFilename, "Writing object file...");
|
||||||
if (!getOption('q'))
|
|
||||||
writeln("Writing object file...");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
objectStream.write(cast(char) b);
|
objectStream.write(cast(char) b);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -2955,6 +2950,9 @@ int main(string[] args) {
|
|||||||
`);
|
`);
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
objectFilename = optionParameters['o' - 'a'];
|
||||||
|
if (objectFilename is null)
|
||||||
|
objectFilename = sourceFilename.setExtension("obx");
|
||||||
try {
|
try {
|
||||||
assemblyPass();
|
assemblyPass();
|
||||||
pass2 = true;
|
pass2 = true;
|
||||||
@ -2964,10 +2962,8 @@ int main(string[] args) {
|
|||||||
} catch (AssemblyError e) {
|
} catch (AssemblyError e) {
|
||||||
warning(e.msg, true);
|
warning(e.msg, true);
|
||||||
exitCode = 2;
|
exitCode = 2;
|
||||||
if (objectStream.isOpen) {
|
objectStream.close();
|
||||||
objectStream.close();
|
remove(objectFilename);
|
||||||
remove(objectFilename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
listingStream.close();
|
listingStream.close();
|
||||||
objectStream.close();
|
objectStream.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user