Fix file output (all assembly must be in one file)
This commit is contained in:
parent
553c87029f
commit
2de711957a
|
@ -1,2 +1,2 @@
|
||||||
jack-compiler
|
jackc
|
||||||
tags
|
tags
|
||||||
|
|
4
main.c
4
main.c
|
@ -57,19 +57,19 @@ int main(int argc, char* argv[]) {
|
||||||
actonunits(head, vmtranslateunit);
|
actonunits(head, vmtranslateunit);
|
||||||
|
|
||||||
currunit = head;
|
currunit = head;
|
||||||
|
FILE* output = fopen("out.asm", "w");
|
||||||
while(currunit != NULL) {
|
while(currunit != NULL) {
|
||||||
FILE* output = fopen(currunit->file->outname, "w");
|
|
||||||
if(output == NULL) {
|
if(output == NULL) {
|
||||||
eprintf("%s", strerror(errno));
|
eprintf("%s", strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printstrlist(currunit->asmlns, output);
|
printstrlist(currunit->asmlns, output);
|
||||||
fclose(output);
|
|
||||||
COMPILEUNIT* next = currunit->next;
|
COMPILEUNIT* next = currunit->next;
|
||||||
freeunit(currunit);
|
freeunit(currunit);
|
||||||
currunit = next;
|
currunit = next;
|
||||||
}
|
}
|
||||||
|
fclose(output);
|
||||||
|
|
||||||
freecompiler(compiler);
|
freecompiler(compiler);
|
||||||
freetree(headclass);
|
freetree(headclass);
|
||||||
|
|
|
@ -93,9 +93,9 @@ bool isdir(char* f, int len) {
|
||||||
|
|
||||||
char* getoutname(char* fullname, int len) {
|
char* getoutname(char* fullname, int len) {
|
||||||
char* trimmed = trimstr(fullname, len, 4);
|
char* trimmed = trimstr(fullname, len, 4);
|
||||||
int sz = sizeof(char) * (len);
|
int sz = sizeof(char) * (len-1);
|
||||||
char* outname = (char*)malloc(sz);
|
char* outname = (char*)malloc(sz);
|
||||||
snprintf(outname, sz, "%sasm", trimmed);
|
snprintf(outname, sz, "%svm", trimmed);
|
||||||
free(trimmed);
|
free(trimmed);
|
||||||
return outname;
|
return outname;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue