module_load_time -> env_module_load_time, module_maybe_reload -> env_module_maybe_reload
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
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,