Ada, C: fix step3 error handling.
authorJoel Martin <github@martintribe.org>
Tue, 1 Nov 2016 15:44:49 +0000 (10:44 -0500)
committerJoel Martin <github@martintribe.org>
Tue, 1 Nov 2016 15:44:49 +0000 (10:44 -0500)
New step3 tests were added during basic implementation that broke Ada
and C.

ada/step3_env.adb
c/step3_env.c
c/types.h

index a5dcf96..cca59b3 100644 (file)
@@ -1,4 +1,5 @@
 with Ada.Command_Line;
+with Ada.Exceptions;
 with Ada.Text_IO;
 with Envs;
 with Eval_Callback;
@@ -254,8 +255,15 @@ begin
    Init (Repl_Env);
 
    loop
-      Ada.Text_IO.Put ("user> ");
-      exit when Ada.Text_IO.End_Of_File;
-      Ada.Text_IO.Put_Line (Rep (Ada.Text_IO.Get_Line, Repl_Env));
+      begin
+         Ada.Text_IO.Put ("user> ");
+         exit when Ada.Text_IO.End_Of_File;
+         Ada.Text_IO.Put_Line (Rep (Ada.Text_IO.Get_Line, Repl_Env));
+      exception
+         when E : others =>
+            Ada.Text_IO.Put_Line
+              (Ada.Text_IO.Standard_Error,
+               Ada.Exceptions.Exception_Information (E));
+      end;
    end loop;
 end Step3_Env;
index 8c5abfa..ba93279 100644 (file)
@@ -80,6 +80,7 @@ MalVal *EVAL(MalVal *ast, Env *env) {
         MalVal *a1 = _nth(ast, 1),
                *a2 = _nth(ast, 2);
         MalVal *res = EVAL(a2, env);
+        if (mal_error) return NULL;
         env_set(env, a1, res);
         return res;
     } else if (strcmp("let*", a0->val.string) == 0) {
index 83ce394..7f327b8 100644 (file)
--- a/c/types.h
+++ b/c/types.h
@@ -6,6 +6,8 @@
 #ifdef USE_GC
 
 #include <gc/gc.h>
+void nop_free(void* ptr);
+void GC_setup();
 char* GC_strdup(const char *src);
 #define MAL_GC_SETUP()  GC_setup()
 #define MAL_GC_MALLOC   GC_MALLOC