Sexpr* args = b->value.b.args;
Sexpr* i = eval(clone(car(args)), env);
Sexpr* j = eval(clone(car(cdr(args))), env);
+#ifdef TYPECHECK
+ if((unquote(i)->type != UINT) || (unquote(j)->type != UINT)) {
+ ERR("+: ", "arguments not uints");
+ sexpr_free(b);
+ sexpr_free(i);
+ sexpr_free(j);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
K_UINT_TYPE m = unquote(i)->value.u;
K_UINT_TYPE n = unquote(j)->value.u;
sexpr_free(b);
Sexpr* args = b->value.b.args;
Sexpr* i = eval(clone(car(args)), env);
Sexpr* j = eval(clone(car(cdr(args))), env);
+#ifdef TYPECHECK
+ if((unquote(i)->type != UINT) || (unquote(j)->type != UINT)) {
+ ERR("-: ", "arguments not uints");
+ sexpr_free(b);
+ sexpr_free(i);
+ sexpr_free(j);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
K_UINT_TYPE m = unquote(i)->value.u;
K_UINT_TYPE n = unquote(j)->value.u;
sexpr_free(b);
Sexpr* args = b->value.b.args;
Sexpr* i = eval(clone(car(args)), env);
Sexpr* j = eval(clone(car(cdr(args))), env);
+#ifdef TYPECHECK
+ if((unquote(i)->type != UINT) || (unquote(j)->type != UINT)) {
+ ERR("*: ", "arguments not uints");
+ sexpr_free(b);
+ sexpr_free(i);
+ sexpr_free(j);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
K_UINT_TYPE m = unquote(i)->value.u;
K_UINT_TYPE n = unquote(j)->value.u;
sexpr_free(b);
Sexpr* args = b->value.b.args;
Sexpr* i = eval(clone(car(args)), env);
Sexpr* j = eval(clone(car(cdr(args))), env);
+#ifdef TYPECHECK
+ if((unquote(i)->type != UINT) || (unquote(j)->type != UINT)) {
+ ERR("/: ", "arguments not uints");
+ sexpr_free(b);
+ sexpr_free(i);
+ sexpr_free(j);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
K_UINT_TYPE m = unquote(i)->value.u;
K_UINT_TYPE n = unquote(j)->value.u;
sexpr_free(b);
Sexpr* args = b->value.b.args;
Sexpr* i = eval(clone(car(args)), env);
Sexpr* j = eval(clone(car(cdr(args))), env);
+#ifdef TYPECHECK
+ if((unquote(i)->type != UINT) || (unquote(j)->type != UINT)) {
+ ERR("%: ", "arguments not uints");
+ sexpr_free(b);
+ sexpr_free(i);
+ sexpr_free(j);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
K_UINT_TYPE m = unquote(i)->value.u;
K_UINT_TYPE n = unquote(j)->value.u;
sexpr_free(b);
return cons(b, rest);
Sexpr* args = b->value.b.args;
Sexpr* unqargev = eval(clone(car(args)), env);
+#ifdef TYPECHECK
+ if(unquote(unqargev)->type != CONS) {
+ ERR("car: ", "argument not cons cell");
+ sexpr_free(b);
+ sexpr_free(unqargev);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
Sexpr* ret = cons(from_quote(clone(car(unquote(unqargev)))), rest);
sexpr_free(unqargev);
sexpr_free(b);
return cons(b, rest);
Sexpr* args = b->value.b.args;
Sexpr* unqargev = eval(clone(car(args)), env);
+#ifdef TYPECHECK
+ if(unquote(unqargev)->type != CONS) {
+ ERR("cdr: ", "argument not cons cell");
+ sexpr_free(b);
+ sexpr_free(unqargev);
+ return cons(from_nil(), rest);
+ }
+#endif // typecheck
Sexpr* ret = cons(from_quote(clone(cdr(unquote(unqargev)))), rest);
sexpr_free(unqargev);
sexpr_free(b);