Commit 77265a5ad01f92fd09d05f9fda644f4a81b58eec

Thomas de Grivel 2024-07-09T01:03:10

wip access

diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 4c4365c..f9f8f0e 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -243,3 +243,5 @@ add {C3, :symbol, C3.module}
 replace {C3.module, :symbol_value, cfn Sym "c3_module" (Result)}
 add {C3, :symbol, C3.search_modules}
 replace {C3.search_modules, :symbol_value, cfn List "c3_search_modules" (Result)}
+add {C3, :symbol, C3.access}
+replace {C3.access, :symbol_value, cfn Tag "c3_access" (Tag, Sym, Result)}
diff --git a/libc3/c3.c b/libc3/c3.c
index d559628..761754b 100644
--- a/libc3/c3.c
+++ b/libc3/c3.c
@@ -30,6 +30,18 @@ const s_str g_c3_bases_hexadecimal[2] = {{{NULL}, 16, {"0123456789abcdef"}},
                                          {{NULL}, 16, {"0123456789ABCDEF"}}};
 sw          g_c3_exit_code = 1;
 
+s_tag * c3_access (const s_tag *tag, const s_sym * const *sym,
+                   s_tag *dest)
+{
+  assert(tag);
+  assert(sym);
+  assert(dest);
+  (void) tag;
+  (void) sym;
+  tag_init(dest);
+  return dest;
+}
+
 void c3_break (void)
 {
   err_puts("break");
diff --git a/libc3/c3_main.h b/libc3/c3_main.h
index 93ea0fc..7c5f8b2 100644
--- a/libc3/c3_main.h
+++ b/libc3/c3_main.h
@@ -36,8 +36,11 @@ void           c3_license (void);
 const s_sym ** c3_module (const s_sym **dest);
 
 /* Operators. */
+s_tag * c3_access (const s_tag *tag, const s_sym * const *sym,
+                   s_tag *dest);
 s_tag * c3_def (const s_call *call, s_tag *dest);
-s_tag * c3_defmodule (const s_sym **name, const s_block *block, s_tag *dest);
+s_tag * c3_defmodule (const s_sym **name, const s_block *block,
+                      s_tag *dest);
 s_tag * c3_defoperator (const s_sym **name, const s_sym **sym,
                         const s_tag *symbol_value,
                         u8 operator_precedence,
diff --git a/libc3/map.c b/libc3/map.c
index 7c20df6..597f2e0 100644
--- a/libc3/map.c
+++ b/libc3/map.c
@@ -21,16 +21,15 @@
 #include "map.h"
 #include "tag.h"
 
-s_tag * map_access (const s_map *map, const s_tag *key, s_tag *value)
+s_tag * map_access (const s_map *map, const s_sym *key, s_tag *value)
 {
+  s_tag tag_key;
   assert(map);
   assert(key);
   assert(value);
-  if (key->type != TAG_SYM) {
-    err_puts("map_access: only works with symbol key");
-    return NULL;
-  }
-  return map_get(map, key, value);
+  tag_key.type = TAG_SYM;
+  tag_key.data.sym = key;
+  return map_get(map, &tag_key, value);
 }
 
 s_map * map_init_cast (s_map *map, const s_tag *tag)
diff --git a/libc3/map.h b/libc3/map.h
index 72780aa..3ee47ed 100644
--- a/libc3/map.h
+++ b/libc3/map.h
@@ -35,7 +35,7 @@ s_map * map_set (s_map *map, const s_tag *key, const s_tag *value);
 s_map * map_sort (s_map *map);
 
 /* Operators */
-s_tag * map_access (const s_map *map, const s_tag *key, s_tag *value);
+s_tag * map_access (const s_map *map, const s_sym *key, s_tag *value);
 s_map * map_cast (const s_tag *tag, s_map *map);
 s_tag * map_get (const s_map *map, const s_tag *key, s_tag *dest);
 s_map * map_update (const s_map *map, const s_tag *key,