Permalink
Browse files

Use callstacks correctly

  • Loading branch information...
1 parent c381766 commit b53b1ab8acc93fae801e1a83520aa2329710e913 @programble committed May 6, 2012
Showing with 4 additions and 15 deletions.
  1. +0 −1 include/callstack.h
  2. +0 −6 src/callstack.c
  3. +2 −4 src/lisp_value/call.c
  4. +2 −4 src/main.c
View
@@ -18,7 +18,6 @@ callstack *callstack_dup(callstack *this);
void callstack_push(callstack *this, metadata *meta);
void callstack_pop(callstack *this);
-void callstack_clear(callstack *this);
char *callstack_sprint(callstack *this);
View
@@ -44,12 +44,6 @@ void callstack_pop(callstack *this)
talloc_free(node);
}
-void callstack_clear(callstack *this)
-{
- while (this->head)
- callstack_pop(this);
-}
-
char *callstack_sprint(callstack *this)
{
char *sprint = talloc_strdup(NULL, "");
View
@@ -14,10 +14,8 @@ lisp_value *lisp_value_call(lisp_value *this, lisp_value *args, context *ctx)
case LISP_TYPE_BUILTIN: {
callstack_push(ctx->callstack, this->meta);
lisp_value *value = LISP_BUILTIN(this)(args, ctx);
- if (value) {
- callstack_pop(ctx->callstack);
- return value;
- } else return NULL;
+ callstack_pop(ctx->callstack);
+ return value;
}
default:
assert(0); return NULL;
View
@@ -47,18 +47,16 @@ void parse_eval(parser *p, context *ctx, bool print)
while ((value = parser_parse(p))) {
callstack_push(ctx->callstack, value->meta);
-
lisp_value *eval = lisp_value_eval(value, ctx);
+ callstack_pop(ctx->callstack);
if (eval) {
if (print)
SPRINT_PRINTLN(lisp_value, eval);
talloc_free(eval);
- callstack_pop(ctx->callstack);
} else {
printf("Some kind of error occurred, but I don't have exceptions yet!\n");
- SPRINT_PRINT(callstack, ctx->callstack);
- callstack_clear(ctx->callstack);
+ // TODO: Handle unhandled exceptions
}
talloc_free(value);

0 comments on commit b53b1ab

Please sign in to comment.