diff --git a/.ic3_history b/.ic3_history
index 5f0d4c2..0bc63d8 100644
--- a/.ic3_history
+++ b/.ic3_history
@@ -1,7 +1,3 @@
-to_list(%{a: 1, b: 2})
-to_list = fn (map) { Map.map(map, fn (k, v) { {k, v} }) }
-to_list(%{a: 1, b: 2})
-Map.to_list(%{a: 1, b: 2})
"\U+1FAB0"
1 + 10000000000000000000000000000
Map.map
@@ -97,3 +93,7 @@ GL.Point2D{}}
GL.Point2D{}
GL.Point2D
{}
+facts_next_id
+facts_next_id()
+4 * 27
+24 * 7
diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
index 0bdbba9..624abc4 100644
--- a/lib/c3/0.1/c3.facts
+++ b/lib/c3/0.1/c3.facts
@@ -186,3 +186,5 @@ add {C3, :symbol, C3.fib}
replace {C3.fib, :fn, fn { (0) { 1 }
(1) { 1 }
(x) { fib(x - 1) + fib(x - 2) } }}
+add {C3, :symbol, C3.facts_next_id}
+replace {C3.facts_next_id, :cfn, cfn Uw "c3_facts_next_id" (Result)}
diff --git a/libc3/c3.c b/libc3/c3.c
index ba49061..2f170dd 100644
--- a/libc3/c3.c
+++ b/libc3/c3.c
@@ -47,6 +47,12 @@ void c3_exit (sw code)
exit((int) code);
}
+uw * c3_facts_next_id (uw *dest)
+{
+ *dest = g_c3_env.facts.next_id;
+ return dest;
+}
+
s_env * c3_init (s_env *env, int argc, s8 **argv)
{
if (! env)
diff --git a/libc3/env.c b/libc3/env.c
index 9befcef..5d5e855 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -58,6 +58,7 @@ void env_clean (s_env *env)
assert(env);
frame_delete_all(env->frame);
error_handler_delete_all(env->error_handler);
+ struct_type_facts_clean(&env->facts);
facts_clean(&env->facts);
buf_file_close(&env->in);
buf_clean(&env->in);
diff --git a/libc3/facts.c b/libc3/facts.c
index 2e86b23..4c6add3 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -50,7 +50,7 @@ s_fact * facts_add_fact (s_facts *facts, const s_fact *fact)
return &item->data;
}
tmp.id = facts->next_id;
- if (facts->next_id == U64_MAX) {
+ if (facts->next_id == UW_MAX) {
errx(1, "facts serial id exhausted");
return NULL;
}
@@ -216,7 +216,7 @@ s_facts * facts_init (s_facts *facts)
facts->index_osp->compare = compare_fact_osp;
facts->log = NULL;
facts_lock_init(facts);
- facts->next_id = 0;
+ facts->next_id = 1;
return facts;
}
diff --git a/libc3/struct_type.h b/libc3/struct_type.h
index 8cb05a1..e00af54 100644
--- a/libc3/struct_type.h
+++ b/libc3/struct_type.h
@@ -46,6 +46,6 @@ s_struct_type * struct_type_new (const s_sym *module,
bool struct_type_exists (const s_sym *module);
const s_struct_type * struct_type_find (const s_sym *module);
uw struct_type_padding (uw offset, uw size);
-
+void struct_type_facts_clean(s_facts *facts);
#endif /* LIBC3_STRUCT_TYPE_H */
diff --git a/libc3/types.h b/libc3/types.h
index 45bc68c..b3df9a1 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -148,6 +148,7 @@ typedef struct ident s_ident;
typedef struct integer s_integer;
typedef struct integer_fraction s_integer_fraction;
typedef struct list s_list;
+typedef struct list__fact s_list__fact;
typedef struct list s_list_map;
typedef struct log s_log;
typedef struct map s_map;
@@ -223,6 +224,11 @@ struct frame {
s_frame *next;
};
+struct list__fact {
+ s_fact *fact;
+ s_list__fact *next;
+};
+
struct map {
uw count;
s_tag *key; /* sorted (see tag_compare) */
@@ -519,7 +525,7 @@ TYPEDEF_SKIPLIST_NODE(fact, s_fact *);
} s_skiplist__##name
TYPEDEF_SKIPLIST(fact, s_fact *);
-
+
/* 8 */
struct facts {
s_set__tag tags;
@@ -531,7 +537,8 @@ struct facts {
pthread_rwlock_t rwlock;
sw rwlock_count;
pthread_t rwlock_thread;
- u64 next_id;
+ uw next_id;
+ s_list__fact *fact_list;
};
struct facts_cursor {