aboutsummaryrefslogtreecommitdiffstats
path: root/clox/src/table.h
diff options
context:
space:
mode:
Diffstat (limited to 'clox/src/table.h')
-rw-r--r--clox/src/table.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/clox/src/table.h b/clox/src/table.h
new file mode 100644
index 0000000..b4c3271
--- /dev/null
+++ b/clox/src/table.h
@@ -0,0 +1,27 @@
+#ifndef TABLE_H
+#define TABLE_H
+
+#include "common.h"
+#include "value.h"
+
+typedef struct {
+ ObjString *key;
+ Value value;
+} Entry;
+
+typedef struct {
+ int count;
+ int capacity;
+ Entry *entries;
+} Table;
+
+void initTable(Table *table);
+void freeTable(Table *table);
+bool tableGet(Table *table, ObjString *key, Value *value);
+bool tableSet(Table *table, ObjString *key, Value value);
+bool tableDelete(Table *table, ObjString *key);
+void tableAddAll(Table *from, Table *to);
+ObjString *tableFindString(Table *talbe, const char *chars, int length,
+ uint32_t hash);
+
+#endif