Exceptions!!!
This commit is contained in:
+13
-9
@@ -3,11 +3,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
DEFUN(print, "print", (LispVal * v), "(v)", "") {
|
||||
debug_obj_info(stdout, v);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
FILE *in = fopen(argv[1], "r");
|
||||
fseek(in, 0, SEEK_END);
|
||||
@@ -17,15 +12,24 @@ int main(int argc, const char **argv) {
|
||||
fread(src, 1, src_len, in);
|
||||
fclose(in);
|
||||
lisp_init();
|
||||
REGISTER_GLOBAL_FUNCTION(print);
|
||||
push_local_reference_frame();
|
||||
StackFrame *toplevel = LISP_STACK_REF();
|
||||
ReadStream s;
|
||||
read_stream_init(&s, src, src_len);
|
||||
LispVal *r;
|
||||
while ((r = read(&s))) {
|
||||
Feval(r, Qnil);
|
||||
}
|
||||
CONDITION_CASE(
|
||||
LIST(Qt),
|
||||
{
|
||||
while ((r = read(&s))) {
|
||||
Feval(r, Qnil);
|
||||
}
|
||||
},
|
||||
{
|
||||
fprintf(stderr, "Caught exception: ");
|
||||
Fprint_condition(EXCEPTION_NAME(), EXCEPTION_DATA(),
|
||||
Qerror_write_byte); //
|
||||
fprintf(stderr, "\nBacktrace (toplevel comes last):\n");
|
||||
});
|
||||
unwind_to(toplevel);
|
||||
lisp_shutdown();
|
||||
free(src);
|
||||
|
||||
Reference in New Issue
Block a user