changeset 126:4b55334c8708

built-ins: Pop (undef) from stack and add raise/recover built-ins
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 01 Sep 2019 19:21:21 +0200
parents ed74caa03e11
children dbed1593881c
files src/built-ins.c
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/built-ins.c	Sun Sep 01 19:20:50 2019 +0200
+++ b/src/built-ins.c	Sun Sep 01 19:21:21 2019 +0200
@@ -19,11 +19,15 @@
 };
 
 static const struct ybuiltin_id_mapping YBUILTIN_ID_MAPPING[] = {
-    {"undef", YBUILTIN_UNDEF}, {"for", YBUILTIN_FOR}, {"let", YBUILTIN_LET},
-    {"defn", YBUILTIN_DEFN},   {"+", YBUILTIN_PLUS},  {"-", YBUILTIN_MINUS},
-    {"*", YBUILTIN_MULT},      {"/", YBUILTIN_DIV},   {"if", YBUILTIN_IF},
-    {"seq", YBUILTIN_SEQ},     {"==", YBUILTIN_EQ},   {"<", YBUILTIN_LT},
-    {"car", YBUILTIN_CAR},     {"cdr", YBUILTIN_CDR}, {"push", YBUILTIN_PUSH},
+    {"undef", YBUILTIN_UNDEF},     {"for", YBUILTIN_FOR},
+    {"let", YBUILTIN_LET},         {"defn", YBUILTIN_DEFN},
+    {"+", YBUILTIN_PLUS},          {"-", YBUILTIN_MINUS},
+    {"*", YBUILTIN_MULT},          {"/", YBUILTIN_DIV},
+    {"if", YBUILTIN_IF},           {"seq", YBUILTIN_SEQ},
+    {"==", YBUILTIN_EQ},           {"<", YBUILTIN_LT},
+    {"car", YBUILTIN_CAR},         {"cdr", YBUILTIN_CDR},
+    {"push", YBUILTIN_PUSH},       {"raise", YBUILTIN_RAISE},
+    {"recover", YBUILTIN_RECOVER},
 };
 
 static const char* YBUILTIN_ENUM_STR[] = {
@@ -98,9 +102,13 @@
             &invalid_expr);                                           \
         return exc;                                                   \
     }
+
 /// Returns a YEXPR_UNDEF expression. TODO: Automatically add symbolic reference
 /// "undef".
-yexpr_t ybuiltin_fn_undef(yeval_state_t* state) { return yexpr_new(); }
+yexpr_t ybuiltin_fn_undef(yeval_state_t* state) {
+    yvec_pop(&state->call_stack, NULL);
+    return yexpr_new();
+}
 
 /// Expects a list expression starting with built-in "for" on the stack. It is
 /// not modified.