diff --git a/README.md b/README.md
index e0c41ad..8873dd2 100644
--- a/README.md
+++ b/README.md
@@ -112,7 +112,7 @@ Script interpreter.
- DONE boolean operators
- DONE comparison operators
- arrays
- - DONE parse
+ - parse
- DONE inspect
- DONE [][][] data
- lists
@@ -123,6 +123,10 @@ Script interpreter.
- ffi ?
- libdwarf
- control structures
+ - modules
+ - DONE symbols
+ - DONE as facts
+ - autoload (remember load time, compare with file time)
- functions
- return
- def
diff --git a/libc3/env.c b/libc3/env.c
index bb66b92..f783ffc 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -14,6 +14,7 @@
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <unistd.h>
#include "binding.h"
#include "c3.h"
@@ -553,6 +554,13 @@ bool env_eval_tuple (s_env *env, const s_tuple *tuple, s_tag *dest)
return true;
}
+s64 env_gettime ()
+{
+ struct timespec time;
+ clock_gettime(CLOCK_REALTIME, &time);
+ return time.tv_sec;
+}
+
s_env * env_init (s_env *env)
{
assert(env);
@@ -603,7 +611,11 @@ void env_longjmp (s_env *env, jmp_buf *jmp_buf)
bool env_module_load (s_env *env, const s_sym *name,
s_facts *facts)
{
+ s_fact fact;
s_str path;
+ s_tag tag_name;
+ s_tag tag_load_time;
+ s_tag tag_time;
assert(env);
assert(name);
assert(facts);
@@ -627,6 +639,10 @@ bool env_module_load (s_env *env, const s_sym *name,
return false;
}
str_clean(&path);
+ fact.subject = tag_init_sym(&tag_name, name);
+ fact.predicate = tag_init_sym(&tag_load_time, sym_1("load_time"));
+ fact.object = tag_init_time(&tag_time);
+ facts_add_fact(facts, &fact);
return true;
}
diff --git a/libc3/tag.c b/libc3/tag.c
index 6ee5eea..37d4567 100644
--- a/libc3/tag.c
+++ b/libc3/tag.c
@@ -2203,6 +2203,27 @@ s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p)
return tag;
}
+s_tag * tag_init_time (s_tag *tag)
+{
+ struct timespec time;
+ s_tag tmp;
+ tag_init_tuple(&tmp, 2);
+ clock_gettime(CLOCK_REALTIME, &time);
+ tag_init_s64(&tmp.data.tuple.tag[0], time.tv_sec);
+ tag_init_s64(&tmp.data.tuple.tag[1], time.tv_nsec);
+ *tag = tmp;
+ return tag;
+}
+
+s_tag * tag_init_tuple (s_tag *tag, uw count)
+{
+ assert(tag);
+ assert(count);
+ tag->type = TAG_TUPLE;
+ tuple_init(&tag->data.tuple, count);
+ return tag;
+}
+
s_tag * tag_init_u8 (s_tag *tag, u8 i)
{
assert(tag);
diff --git a/libc3/tag.h b/libc3/tag.h
index de9c303..d8d65d7 100644
--- a/libc3/tag.h
+++ b/libc3/tag.h
@@ -48,6 +48,7 @@ s_tag * tag_init_str (s_tag *tag, s8 *free, uw size, const s8 *p);
s_tag * tag_init_str_1 (s_tag *tag, s8 *free, const s8 *p);
s_tag * tag_init_sym (s_tag *tag, const s_sym *p);
s_tag * tag_init_sym_1 (s_tag *tag, const s8 *p);
+s_tag * tag_init_time (s_tag *tag);
s_tag * tag_init_tuple (s_tag *tag, uw count);
s_tag * tag_init_tuple_2 (s_tag *tag, s_tag *a, s_tag *b);
s_tag * tag_init_var (s_tag *tag);
diff --git a/test/ic3/list.in b/test/ic3/list.in
index d26447d..d0852ec 100644
--- a/test/ic3/list.in
+++ b/test/ic3/list.in
@@ -42,3 +42,5 @@
## comment 9b
List.map((1, 2, 3, 4), fn (x) { x * 2 })
+
+List.reverse((1, 2, 3, 4))
diff --git a/test/ic3/list.out.expected b/test/ic3/list.out.expected
index d3385af..6b61ae3 100644
--- a/test/ic3/list.out.expected
+++ b/test/ic3/list.out.expected
@@ -21,3 +21,4 @@
(:a, :b, :c | :d)
(:a, :b, :c | :d)
(2, 4, 6, 8)
+(4, 3, 2, 1)