diff --git a/Makefile b/Makefile
index d6bc652..ad9727c 100644
--- a/Makefile
+++ b/Makefile
@@ -67,6 +67,7 @@ cov:
debug:
${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
${MAKE} -C libc3 debug
${MAKE} -C ic3 debug
${MAKE} -C c3s debug
@@ -135,7 +136,9 @@ gdb_demo_gl:
${MAKE} -C libc3 gdb_demo_gl
gdb_ic3:
- ${MAKE} debug
+ ${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libc3 debug
${MAKE} -C ic3 gdb_ic3
gdb_test:
diff --git a/ic3/.ic3_history b/ic3/.ic3_history
index 479953d..f2c9602 100644
--- a/ic3/.ic3_history
+++ b/ic3/.ic3_history
@@ -1,7 +1,3 @@
- quote do
- x = unquote(x)
- {x, x}
- end
end
dt(200)
dt(a)
@@ -97,3 +93,7 @@ defmodule Plop do end
defmodule Plop do def a = 1 end
quote_cfn Plop
defmodule Plop do def a = 1 end
+Plop.a
+defmodule Plop do def a = 1 end
+Plop.a
+Plop
diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 626d62a..dddf44d 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -219,7 +219,7 @@ replace {C3.hash, :symbol_value, cfn Uw "tag_hash_uw" (Tag)}
add {C3, :symbol, C3.defmodule}
replace {C3.defmodule, :arity, 2}
replace {C3.defmodule, :is_a, :special_operator}
-replace {C3.defmodule, :symbol_value, cfn Sym "c3_defmodule" (Sym, Block, Result)}
+replace {C3.defmodule, :symbol_value, cfn Tag "c3_defmodule" (Sym, Block, Result)}
add {C3, :symbol, C3.def}
replace {C3.def, :arity, 1}
replace {C3.def, :is_a, :special_operator}
diff --git a/libc3/env.c b/libc3/env.c
index b8041d7..9be7826 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -112,6 +112,9 @@ s_tag * env_defmodule (s_env *env, const s_sym **name,
{
const s_sym *module;
s_tag *result = NULL;
+ s_tag tag_is_a;
+ s_tag tag_module;
+ s_tag tag_module_name;
s_tag tmp = {0};
assert(env);
assert(name);
@@ -121,10 +124,16 @@ s_tag * env_defmodule (s_env *env, const s_sym **name,
module = env->current_module;
env_module_is_loading_set(env, *name, true);
env->current_module = *name;
- if (env_eval_block(env, block, &tmp)) {
- tag_clean(&tmp);
- tag_init_sym(dest, *name);
- result = dest;
+ tag_init_sym(&tag_is_a, &g_sym_is_a);
+ tag_init_sym(&tag_module, &g_sym_module);
+ tag_init_sym(&tag_module_name, *name);
+ if (facts_add_tags(&env->facts, &tag_module_name, &tag_is_a,
+ &tag_module)) {
+ if (env_eval_block(env, block, &tmp)) {
+ tag_clean(&tmp);
+ tag_init_sym(dest, *name);
+ result = dest;
+ }
}
env->current_module = module;
env_module_is_loading_set(env, *name, false);
@@ -1513,6 +1522,8 @@ bool env_module_load (s_env *env, const s_sym *module, s_facts *facts)
err_puts(": module_path");
goto ko;
}
+ if (! file_access(&path, &g_sym_r))
+ goto ko;
tag_init_time(&tag_time);
if (facts_load_file(facts, &path) < 0) {
err_write_1("env_module_load: ");
@@ -1556,7 +1567,8 @@ bool env_module_maybe_reload (s_env *env, const s_sym *module,
return false;
}
//io_inspect_str(&path);
- if (! file_mtime(&path, &tag_mtime)) {
+ if (! file_access(&path, &g_sym_r) ||
+ ! file_mtime(&path, &tag_mtime)) {
str_clean(&path);
return false;
}
diff --git a/libc3/file.c b/libc3/file.c
index c588f7e..1aaac94 100644
--- a/libc3/file.c
+++ b/libc3/file.c
@@ -31,8 +31,7 @@
# define O_BINARY 0
#endif
-bool * file_access (const s_str *path, const s_sym *mode,
- bool *dest)
+bool file_access (const s_str *path, const s_sym *mode)
{
sw m;
if (mode == &g_sym_r)
@@ -51,8 +50,7 @@ bool * file_access (const s_str *path, const s_sym *mode,
m = X_OK;
else
m = F_OK;
- *dest = access(path->ptr.pchar, m) ? false : true;
- return dest;
+ return ! access(path->ptr.pchar, m);
}
sw file_copy (const char *from, const char *to)
@@ -167,7 +165,6 @@ FILE * file_open (const char *path, const char *mode)
s_str * file_search (const s_str *suffix, const s_sym *mode,
s_str *dest)
{
- bool access;
char buf_s[PATH_MAX];
s_buf buf;
const s_list *path;
@@ -192,8 +189,7 @@ s_str * file_search (const s_str *suffix, const s_sym *mode,
return NULL;
buf_read_to_str(&buf, &tmp);
//io_inspect_str(&tmp);
- file_access(&tmp, mode, &access);
- if (access) {
+ if (file_access(&tmp, mode)) {
*dest = tmp;
return dest;
}
diff --git a/libc3/file.h b/libc3/file.h
index 51b0d6a..3677f99 100644
--- a/libc3/file.h
+++ b/libc3/file.h
@@ -25,8 +25,7 @@
#include "types.h"
/* Observers */
-bool * file_access (const s_str *path, const s_sym *mode,
- bool *dest);
+bool file_access (const s_str *path, const s_sym *mode);
sw file_copy (const char *from, const char *to);
s_str * file_dirname (const s_str *path, s_str *dest);
s_tag * file_mtime (const s_str *path, s_tag *dest);