diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-12 14:04:34 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-01-12 14:04:34 -0500 |
commit | 7659a5ff48bb51baa6fcf5dfe13c8583413f7f4a (patch) | |
tree | 183fcadb06a6892a86875d057e397d74e3c159b9 /types.h | |
parent | 2069b22cbcbbf293151db0c7c2a3e29f8c29c977 (diff) |
better identifier system (uses much less memory)
Diffstat (limited to 'types.h')
-rw-r--r-- | types.h | 27 |
1 files changed, 8 insertions, 19 deletions
@@ -105,7 +105,6 @@ typedef struct Allocator { typedef struct ArrBlock { void *data; size_t n; /* number of things in this block so far */ - void *last; /* last one of them */ } ArrBlock; typedef struct BlockArr { @@ -170,33 +169,23 @@ typedef struct IdentDecl { U16 flags; } IdentDecl; -/* -The way you search an identifier in a tree is: -root.children[low part of 1st char].children[high part of 1st char] -.children[low part of 2nd char]... - -*/ - -#define TREE_NCHILDREN 16 -typedef struct IdentTree { - /* zero value is an empty trie */ - uint16_t depth; - unsigned char index_in_parent; /* index of this in .parent.children */ +typedef struct IdentSlot { bool export_name; /* is this identifier's name important? */ bool anonymous; /* is this identifier not part of a tree? */ + char *text; /* actual name of the identifier */ + size_t len; /* length of name */ U64 export_id; /* 0 if there's no exported identifier here, otherwise unique positive integer associated with this identifier */ struct Package *pkg; /* NULL if this is not associated with a package */ - struct IdentTree *parent; - struct IdentTree *children[TREE_NCHILDREN]; IdentDecl *decls; /* array of declarations of this identifier */ -} IdentTree; +} IdentSlot; -typedef IdentTree *Identifier; +typedef IdentSlot *Identifier; +typedef IdentSlot *IdentSlotPtr; typedef struct Identifiers { - BlockArr trees; - IdentTree *root; + IdentSlot **slots; U64 nidents; + U32 rseed; } Identifiers; typedef enum { |