summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data_structures.c17
-rw-r--r--identifiers.c4
-rw-r--r--test.toc6
3 files changed, 26 insertions, 1 deletions
diff --git a/data_structures.c b/data_structures.c
index 37ae242..af89aa4 100644
--- a/data_structures.c
+++ b/data_structures.c
@@ -378,6 +378,23 @@ static inline void *str_hash_table_get(StrHashTable *t, const char *str, size_t
return slot->data;
}
+static void str_hash_table_fprint(StrHashTable *t, FILE *out) {
+ fprintf(out, "------- Hash table @ %p\n", (void *)t);
+ arr_foreach(t->slots, StrHashTableSlotPtr, slotp) {
+ StrHashTableSlot *slot = *slotp;
+ if (slot) {
+ fprintf(out, "| ");
+ fwrite(slot->str, 1, slot->len, out);
+ fprintf(out, "\n");
+ }
+ }
+ fprintf(out, "------\n");
+}
+
+static void str_hash_table_print(StrHashTable *t) {
+ str_hash_table_fprint(t, stdout);
+}
+
#if RUN_TESTS
static void str_hash_table_test(void) {
StrHashTable t;
diff --git a/identifiers.c b/identifiers.c
index 17bbd47..c3f64b7 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -212,6 +212,10 @@ static void idents_test(void) {
}
#endif
+static void idents_print_all(Identifiers *idents) {
+ str_hash_table_print(&idents->table);
+}
+
static int ident_index_in_decl(Identifier i, Declaration *d) {
int index = 0;
arr_foreach(d->idents, Identifier, j) {
diff --git a/test.toc b/test.toc
index 5a5a328..43ccf56 100644
--- a/test.toc
+++ b/test.toc
@@ -1 +1,5 @@
-#include "tests/std/mem.toc";
+#include "tests/std/io.toc", io;
+
+main ::= fn() {
+ io.puts("hi");
+}