Commit b2c27cda41a3d3fda032f379762ad2e43e6a5f3f

Thomas de Grivel 2024-03-29T18:23:05

wip defmodule + def

diff --git a/.ic3_history b/.ic3_history
index 94de646..479953d 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,5 +1,3 @@
-    x = unquote x
-def dt = macro (x) do
   quote do
     x = unquote(x)
     {x, x}
@@ -94,6 +92,8 @@ do end
 defmodule Plop do end
 quote Plop
 quote_cfn Plop
-type(voidà
-)
-type(void)
+(Sym) "Abc"
+defmodule Plop do end
+defmodule Plop do def a = 1 end
+quote_cfn Plop
+defmodule Plop do def a = 1 end
diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 1755c4b..479953d 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,4 +1,3 @@
-def dt = macro (x) do
   quote do
     x = unquote(x)
     {x, x}
@@ -97,3 +96,4 @@ quote_cfn Plop
 defmodule Plop do end
 defmodule Plop do def a = 1 end
 quote_cfn Plop
+defmodule Plop do def a = 1 end
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 0d3f061..e4629ea 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1761,6 +1761,20 @@ sw buf_inspect_paren_sym_size (const s_sym *sym)
   return r;
 }
 
+sw buf_inspect_pointer (s_buf *buf, const void *ptr)
+{
+  sw r;
+  sw result = 0;
+  assert(buf);
+  if ((r = buf_write_1(buf, "0x")) < 0)
+    return r;
+  result += r;
+  if ((r = buf_inspect_uw_hexadecimal(buf, (uw *) &ptr)) < 0)
+    return r;
+  result += r;
+  return result;
+}
+
 sw buf_inspect_ptag (s_buf *buf, const p_tag *ptag)
 {
   sw r;
diff --git a/libc3/buf_inspect.h b/libc3/buf_inspect.h
index bdb2118..f2db3d0 100644
--- a/libc3/buf_inspect.h
+++ b/libc3/buf_inspect.h
@@ -116,6 +116,8 @@ sw buf_inspect_map (s_buf *buf, const s_map *map);
 sw buf_inspect_map_size (const s_map *map);
 sw buf_inspect_paren_sym (s_buf *buf, const s_sym *sym);
 sw buf_inspect_paren_sym_size (const s_sym *sym);
+sw buf_inspect_pointer (s_buf *buf, const void *ptr);
+sw buf_inspect_pointer_size (const void *ptr);
 sw buf_inspect_ptag (s_buf *buf, const p_tag *ptag);
 sw buf_inspect_ptag_size (const p_tag *ptag);
 sw buf_inspect_ptr (s_buf *buf, const u_ptr_w *ptr);
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 7ada8fa..e0a549b 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -107,11 +107,10 @@ s_tag * cfn_apply (s_cfn *cfn, s_list *args, s_tag *dest)
         err_write_1("cfn_apply: ");
         err_inspect_str(&cfn->name->str);
         err_write_1(": ");
-        err_inspect_ptr(result_pointer);
-        err_write_1(": ");
-        err_inspect_ptr(arg_pointer_result);
+        err_inspect_pointer(result_pointer);
+        err_write_1(" != ");
+        err_inspect_pointer(arg_pointer_result);
         err_write_1("\n");
-        assert(! "cfn_apply: error");
         goto ko;
       }
       *dest = tmp2;
diff --git a/libc3/configure b/libc3/configure
index 13556fb..57c018a 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -38,7 +38,7 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$LO_SOURCES")"
 
 # Common config for all targets
 CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-LDFLAGS="--shared $LDFLAGS -rdynamic"
+LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
 config_asan
 config_gnu
 pkg_config libbsd-overlay
diff --git a/libc3/env.c b/libc3/env.c
index dd7ff02..ea4c96c 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -349,8 +349,10 @@ bool env_eval_call_resolve (s_env *env, s_call *call)
   ident_init_copy(&tmp_ident, &call->ident);
   if (! env_ident_resolve_module(env, &tmp_ident, &call->ident) ||
       ! module_ensure_loaded(call->ident.module, &env->facts) ||
-      ! call_get(call, &env->facts))
+      ! call_get(call, &env->facts)) {
+    ident_init_copy(&call->ident, &tmp_ident);
     return false;
+  }
   return true;
 }
 
diff --git a/libc3/io.c b/libc3/io.c
index 2811b9b..352dd98 100644
--- a/libc3/io.c
+++ b/libc3/io.c
@@ -113,6 +113,7 @@ DEF_ERR_IO_INSPECT(fn_pattern, const s_list *)
 DEF_ERR_IO_INSPECT(ident,      const s_ident *)
 DEF_ERR_IO_INSPECT(list,       const s_list * const *)
 DEF_ERR_IO_INSPECT(map,        const s_map *)
+DEF_ERR_IO_INSPECT(pointer,    const void *)
 DEF_ERR_IO_INSPECT(ptr,        const u_ptr_w *)
 DEF_ERR_IO_INSPECT(s8,         const s8 *)
 DEF_ERR_IO_INSPECT(s16,        const s16 *)
diff --git a/libc3/io.h b/libc3/io.h
index e5b0a73..9fc98d5 100644
--- a/libc3/io.h
+++ b/libc3/io.h
@@ -50,6 +50,7 @@ PROTOTYPES_ERR_IO_INSPECT(ident,      const s_ident *);
 PROTOTYPES_ERR_IO_INSPECT(integer,    const s_integer *);
 PROTOTYPES_ERR_IO_INSPECT(list,       const s_list * const *);
 PROTOTYPES_ERR_IO_INSPECT(map,        const s_map *);
+PROTOTYPES_ERR_IO_INSPECT(pointer,    const void *);
 PROTOTYPES_ERR_IO_INSPECT(ptr,        const u_ptr_w *);
 PROTOTYPES_ERR_IO_INSPECT(s8,         const s8 *);
 PROTOTYPES_ERR_IO_INSPECT(s16,        const s16 *);