make format

This commit is contained in:
NunoSempere 2023-05-01 21:00:20 -04:00
parent ff8b45489b
commit f9bfc8fb46

View File

@ -223,13 +223,15 @@ lispval* pop_lispval(lispval* v, int i)
return r;
}
lispval* take_lispval(lispval* v, int i){ // Unneeded.
lispval* take_lispval(lispval* v, int i)
{ // Unneeded.
lispval* x = pop_lispval(v, i);
delete_lispval(v);
return x;
}
lispval* builtin_op(char* op, lispval* v){
lispval* builtin_op(char* op, lispval* v)
{
// For now, ensure all args are numbers
for (int i = 0; i < v->count; i++) {
if (v->cell[i]->type != LISPVAL_NUM) {
@ -252,13 +254,20 @@ lispval* builtin_op(char* op, lispval* v){
// Pop the next element
lispval* y = pop_lispval(v, 0);
if (strcmp(op, "+") == 0) { x->num += y->num; }
if (strcmp(op, "-") == 0) { x->num -= y->num; }
if (strcmp(op, "*") == 0) { x->num *= y->num; }
if (strcmp(op, "+") == 0) {
x->num += y->num;
}
if (strcmp(op, "-") == 0) {
x->num -= y->num;
}
if (strcmp(op, "*") == 0) {
x->num *= y->num;
}
if (strcmp(op, "/") == 0) {
if (y->num == 0) {
delete_lispval(x); delete_lispval(y);
delete_lispval(x);
delete_lispval(y);
return lispval_err("Error: Division By Zero!");
}
x->num /= y->num;
@ -272,7 +281,6 @@ lispval* builtin_op(char* op, lispval* v){
}
}
lispval* evaluate_lispval(lispval* l)
{
// Evaluate the children if needed