Minor improvements

This commit is contained in:
Augusto Gunsch 2020-12-21 15:21:37 -03:00
parent f26d7704a8
commit cbf7879794
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 4 additions and 9 deletions

View File

@ -42,6 +42,7 @@ LINE* mksimpleln(char** tokens, int count) {
LINE* ln = mkline(count); LINE* ln = mkline(count);
for(int i = 0; i < count; i++) for(int i = 0; i < count; i++)
addtoken(ln, ezheapstr(tokens[i])); addtoken(ln, ezheapstr(tokens[i]));
ln->next = NULL;
return ln; return ln;
} }
@ -75,12 +76,8 @@ LINEBLOCK* compileexpression(SCOPE* s, TERM* e) {
LINEBLOCK* next = NULL; LINEBLOCK* next = NULL;
if(e->type == intconstant) { if(e->type == intconstant) {
LINE* ln = mkline(3); char* tokens[] = { "push", "constant", itoa(e->integer) };
addtoken(ln, ezheapstr("push")); myblk = mklnblk(mksimpleln(tokens, sizeof(tokens) / sizeof(char*)));
addtoken(ln, ezheapstr("constant"));
addtoken(ln, itoa(e->integer));
ln->next = NULL;
myblk = mklnblk(ln);
} }
else if(e->type == unaryopterm) { else if(e->type == unaryopterm) {
myblk = compileexpression(s, e->expression); myblk = compileexpression(s, e->expression);
@ -97,9 +94,7 @@ LINEBLOCK* compileexpression(SCOPE* s, TERM* e) {
if(e->next != NULL) { if(e->next != NULL) {
next = compileexpression(s, e->next); next = compileexpression(s, e->next);
LINE* op = mathopln(e->op); appendln(next, mathopln(e->op));
appendln(next, op);
op->next = NULL;
myblk = mergelnblks(myblk, next); myblk = mergelnblks(myblk, next);
} }