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