Commit eef9feec01ebf581bf4fe33418fab333d0d8cd79

Thomas de Grivel 2024-06-25T11:31:10

module_load_time -> env_module_load_time, module_maybe_reload -> env_module_maybe_reload

diff --git a/libc3/env.c b/libc3/env.c
index b5b0087..de5757b 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -2024,7 +2024,7 @@ bool env_module_ensure_loaded (s_env *env, const s_sym *module)
     }
     return true;
   }
-  module_maybe_reload(module, &env->facts);
+  env_module_maybe_reload(env, module);
   return true;
 }
 
@@ -2166,14 +2166,37 @@ const s_sym * env_module_load_defstruct (s_env *env,
   return module;
 }
 
-bool env_module_maybe_reload (s_env *env, const s_sym *module,
-                              s_facts *facts)
+s_tag * env_module_load_time (s_env *env, const s_sym *module,
+                              s_tag *dest)
+{
+  s_facts_with_cursor cursor;
+  const s_fact *fact;
+  s_tag tag_module_name;
+  s_tag tag_load_time;
+  s_tag tag_time_var;
+  tag_init_sym(&tag_module_name, module);
+  tag_init_sym(&tag_load_time, &g_sym_load_time);
+  tag_init_var(&tag_time_var, &g_sym_Tag);
+  if (! facts_with(&env->facts, &cursor, (t_facts_spec) {
+        &tag_module_name, &tag_load_time, &tag_time_var, NULL, NULL }))
+    return NULL;
+  if (! facts_with_cursor_next(&cursor, &fact) ||
+      ! fact) {
+    facts_with_cursor_clean(&cursor);
+    return NULL;
+  }
+  facts_with_cursor_clean(&cursor);
+  *dest = tag_time_var;
+  return dest;
+}
+
+bool env_module_maybe_reload (s_env *env, const s_sym *module)
 {
   s_str path;
   bool r = false;
   s_tag tag_load_time = {0};
   s_tag tag_mtime;
-  module_load_time(module, facts, &tag_load_time);
+  env_module_load_time(env, module, &tag_load_time);
   if (module_path(module, &env->module_path, C3_EXT, &path)) {
     if (file_access(&path, &g_sym_r))
       r = true;
@@ -2529,7 +2552,7 @@ bool * env_struct_type_exists (s_env *env, const s_sym *module,
   tag_init_sym(&tag_module, module);
   tag_init_sym(&tag_defstruct, &g_sym_defstruct);
   tag_init_var(&tag_var, &g_sym_Tag);
-  env_module_maybe_reload(env, module, &env->facts);
+  env_module_maybe_reload(env, module);
   if (! facts_with_tags(&env->facts, &cursor, &tag_module,
                         &tag_defstruct, &tag_var))
     return NULL;
@@ -2555,7 +2578,7 @@ const s_struct_type * env_struct_type_find (s_env *env,
   tag_init_sym(&tag_module, module);
   tag_init_sym(&tag_struct_type, &g_sym_struct_type);
   tag_init_var(&tag_var, &g_sym_Tag);
-  env_module_maybe_reload(env, module, &env->facts);
+  env_module_maybe_reload(env, module);
   facts_with(&env->facts, &cursor, (t_facts_spec) {
       &tag_module, &tag_struct_type, &tag_var, NULL, NULL });
   if (! facts_with_cursor_next(&cursor, &found))
diff --git a/libc3/env.h b/libc3/env.h
index 7119e02..1bc8a28 100644
--- a/libc3/env.h
+++ b/libc3/env.h
@@ -27,6 +27,8 @@ s_ident *      env_ident_resolve_module (s_env *env,
                                          const s_ident *ident,
                                          s_ident *dest);
 const s_sym ** env_module (s_env *env, const s_sym **dest);
+s_tag *        env_module_load_time (s_env *env, const s_sym *module,
+                                     s_tag *dest);
 s_list **      env_module_search_modules (s_env *env,
                                           const s_sym *module,
                                           s_list **dest);
@@ -177,8 +179,7 @@ bool          env_module_is_loading_set (s_env *env,
                                          bool value);
 bool          env_module_load (s_env *env, const s_sym *module);
 bool          env_module_maybe_reload (s_env *env,
-                                       const s_sym *module,
-                                       s_facts *facts);
+                                       const s_sym *module);
 s8            env_operator_arity (s_env *env, const s_ident *op);
 bool *        env_operator_find (s_env *env, const s_ident *op,
                                  bool *dest);
diff --git a/libc3/module.c b/libc3/module.c
index 10e1ff1..937efcd 100644
--- a/libc3/module.c
+++ b/libc3/module.c
@@ -71,33 +71,14 @@ bool module_load (const s_sym *module)
   return env_module_load(&g_c3_env, module);
 }
 
-s_tag * module_load_time (const s_sym *module, s_facts *facts,
-                          s_tag *dest)
+s_tag * module_load_time (const s_sym *module, s_tag *dest)
 {
-  s_facts_with_cursor cursor;
-  const s_fact *fact;
-  s_tag tag_module_name;
-  s_tag tag_load_time;
-  s_tag tag_time_var;
-  tag_init_sym(&tag_module_name, module);
-  tag_init_sym(&tag_load_time, &g_sym_load_time);
-  tag_init_var(&tag_time_var, &g_sym_Tag);
-  if (! facts_with(facts, &cursor, (t_facts_spec) {
-        &tag_module_name, &tag_load_time, &tag_time_var, NULL, NULL }))
-    return NULL;
-  if (! facts_with_cursor_next(&cursor, &fact) ||
-      ! fact) {
-    facts_with_cursor_clean(&cursor);
-    return NULL;
-  }
-  facts_with_cursor_clean(&cursor);
-  *dest = tag_time_var;
-  return dest;
+  return env_module_load_time(&g_c3_env, module, dest);
 }
 
-bool module_maybe_reload (const s_sym *module, s_facts *facts)
+bool module_maybe_reload (const s_sym *module)
 {
-  return env_module_maybe_reload(&g_c3_env, module, facts);
+  return env_module_maybe_reload(&g_c3_env, module);
 }
 
 s_str * module_path (const s_sym *module, const s_str *prefix,
diff --git a/libc3/module.h b/libc3/module.h
index ed28eb6..2fcb085 100644
--- a/libc3/module.h
+++ b/libc3/module.h
@@ -25,7 +25,7 @@
 /* Modifiers */
 bool module_ensure_loaded (const s_sym *module);
 bool module_load (const s_sym *module);
-bool module_maybe_reload (const s_sym *module, s_facts *facts);
+bool module_maybe_reload (const s_sym *module);
 
 /* Observers */
 bool *        module_has_ident (const s_sym *module,
@@ -35,8 +35,7 @@ bool *        module_has_symbol (const s_sym *module,
                                  const s_sym *sym,
                                  s_facts *facts, bool *dest);
 bool *        module_is_loading (const s_sym *module, bool *dest);
-s_tag *       module_load_time (const s_sym *module, s_facts *facts,
-                                s_tag *dest);
+s_tag *       module_load_time (const s_sym *module, s_tag *dest);
 s_str *       module_path (const s_sym *module, const s_str *prefix,
                            const char *ext, s_str *dest);
 sw            module_path_size (const s_sym *module,