Remove unused enum

This commit is contained in:
Augusto Gunsch 2020-10-31 20:40:17 -03:00
parent f0dd1b852b
commit 46c2a83735
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 4 additions and 17 deletions

View File

@ -4,18 +4,6 @@
#include <ctype.h> #include <ctype.h>
#include "translator.h" #include "translator.h"
enum operation { push, pop };
enum operation getop(struct line* ln) {
char* tok = ln->tokens[0];
if(strcmp(tok, "push") == 0)
return push;
if(strcmp(tok, "pop") == 0)
return pop;
fprintf(stderr, "Invalid operation '%s'; line %i\n", tok, ln->truen);
exit(1);
}
void freeasmlns(struct asmln** lns, int count) { void freeasmlns(struct asmln** lns, int count) {
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
free(lns[i]->instr); free(lns[i]->instr);
@ -364,8 +352,8 @@ void mkpop(struct line* ln, struct asmln*** asmlns, int* asmind, int* asmsize) {
(*asmind) = asmi; (*asmind) = asmi;
} }
void switchop(struct line* ln, struct asmln*** asmlns, int* asmind, int* asmsize, enum operation op, char* fname) { void switchop(struct line* ln, struct asmln*** asmlns, int* asmind, int* asmsize, char* fname) {
if(op == push) if(strcmp(ln->tokens[0], "push") == 0)
if(strcmp(ln->tokens[1], "constant") == 0) if(strcmp(ln->tokens[1], "constant") == 0)
pushcons(ln, asmlns, asmind, asmsize); pushcons(ln, asmlns, asmind, asmsize);
else if(strcmp(ln->tokens[1], "static") == 0) else if(strcmp(ln->tokens[1], "static") == 0)
@ -374,7 +362,7 @@ void switchop(struct line* ln, struct asmln*** asmlns, int* asmind, int* asmsize
pushtemp(ln, asmlns, asmind, asmsize); pushtemp(ln, asmlns, asmind, asmsize);
else else
mkpush(ln, asmlns, asmind, asmsize); mkpush(ln, asmlns, asmind, asmsize);
else if(op == pop) else if(strcmp(ln->tokens[0], "pop") == 0)
if(strcmp(ln->tokens[1], "static") == 0) if(strcmp(ln->tokens[1], "static") == 0)
popstat(ln, asmlns, asmind, asmsize, fname); popstat(ln, asmlns, asmind, asmsize, fname);
else if(strcmp(ln->tokens[1], "temp") == 0) else if(strcmp(ln->tokens[1], "temp") == 0)
@ -390,8 +378,7 @@ struct asmln** translate(struct line** lns, int lnscount, int* asmcount, char* f
for(int i = 0; i < lnscount; i++) { for(int i = 0; i < lnscount; i++) {
struct line* ln = lns[i]; struct line* ln = lns[i];
enum operation op = getop(ln); switchop(ln, &asmlns, &asmi, &sizebet, fname);
switchop(ln, &asmlns, &asmi, &sizebet, op, fname);
} }
(*asmcount) = asmi; (*asmcount) = asmi;