Accessors

This commit is contained in:
Tony Garnock-Jones 2015-06-30 12:25:05 -04:00
parent 0f75e40676
commit e984c00379
1 changed files with 17 additions and 0 deletions

View File

@ -118,6 +118,23 @@ static inline tt_node_ptr_t tt_cons_node(tt_arena_t *a,
return tt_arena_cons(a, TT_TAG_NODE, index, zero, one);
}
static inline tt_node_ptr_t tt_left(tt_arena_t *a, tt_node_ptr_t p) {
return a->nodes[tt_ptr_idx(p)].a;
}
static inline tt_node_ptr_t tt_right(tt_arena_t *a, tt_node_ptr_t p) {
return a->nodes[tt_ptr_idx(p)].b;
}
#define TT_TAIL_TRIE(a,p) tt_left(a,p)
#define TT_BRANCH_WILDCARD(a,p) tt_left(a,p)
#define TT_BRANCH_OTHERS(a,p) tt_right(a,p)
#define TT_LEAF_TRIE(a,p) tt_left(a,p)
#define TT_LEAF_ATOM(a,p) ((tt_atom_t) tt_right(a,p))
#define TT_NODE_INDEX(a,p) (a->headers[tt_ptr_idx(p)].inuse.index)
#define TT_NODE_ZERO(a,p) tt_left(a,p)
#define TT_NODE_ONE(a,p) tt_right(a,p)
#ifdef __cplusplus
}
#endif