Commit 32e4e99691afc1a7b6290400b5aa9c4942dfd577

Thomas de Grivel 2024-02-14T16:48:49

evaluate macros

diff --git a/.ic3_history b/.ic3_history
index 522676e..dde0cba 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,9 +1,3 @@
-dlopen("/home/dx/c/thodg/c3-lang/c3/libc3/window/.libs/libc3_window.so.0.0", (U32) 0)
-getenv("_")
-getenv("SHELL")
-getenv("HOME")
-getenv("USER")
-"a" + "b"
 "ab" + "cd"
 "ab" + "cd" + "ef"
 "Bonjour " + name + " !"
@@ -97,3 +91,9 @@ name
 a = 1
 ^ a = 1
 ^ a
+m = macro (name) { "Hello, " + name + " !" }
+m("123")
+m = macro (name) { quote "Hello, " + name + " !" }
+m("123")
+m = macro (name) { quote "Hello, " + name + " !" }
+m("123")
diff --git a/libc3/env.c b/libc3/env.c
index cbc1d42..613e38b 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -611,7 +611,12 @@ bool env_eval_fn_call (s_env *env, const s_fn *fn,
     env->frame = frame_clean(&frame);
     return false;
   }
-  *dest = tag;
+  if (fn->macro) {
+    if (! env_eval_tag(env, &tag, dest))
+      return false;
+  }
+  else
+    *dest = tag;
   list_delete_all(args);
   list_delete_all(tmp);
   env->frame = frame_clean(&frame);