diff options
author | Marvin Borner | 2023-05-31 13:21:24 +0200 |
---|---|---|
committer | Marvin Borner | 2023-05-31 13:21:24 +0200 |
commit | 931df5e774eebb098c5d7be93937d2b2f12b86ac (patch) | |
tree | ec60efb28549b4f83a42bbb41a2c702c0565e3b5 /src/parse.c | |
parent | d347a2fa6483059e6397d2b70e82aa657f1144d2 (diff) |
Added parent hashmaps
Diffstat (limited to 'src/parse.c')
-rw-r--r-- | src/parse.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/parse.c b/src/parse.c index 730ef44..d25034e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -17,14 +17,15 @@ static struct term_handle abs_blc(char **term, size_t depth) hash_t res = hash((uint8_t *)&res_type, sizeof(res_type), inner.hash); struct term *res_term; - if ((res_term = map_get(res))) { + if ((res_term = map_get(map_all_terms(), res))) { term_refer_head(res_term, depth); } else { res_term = term_new(res_type, res, depth); res_term->u.abs.term = inner.term; - map_set(res_term, res); + map_set(map_all_terms(), res_term, res); } + map_set(res_term->u.abs.term->parents, res_term, res_term->hash); return (struct term_handle){ .term = res_term, .hash = res }; } @@ -38,15 +39,18 @@ static struct term_handle app_blc(char **term, size_t depth) res = hash((uint8_t *)&res, sizeof(res), rhs.hash); struct term *res_term; - if ((res_term = map_get(res))) { + if ((res_term = map_get(map_all_terms(), res))) { term_refer_head(res_term, depth); } else { res_term = term_new(res_type, res, depth); res_term->u.app.lhs = lhs.term; res_term->u.app.rhs = rhs.term; - map_set(res_term, res); + map_set(map_all_terms(), res_term, res); } + map_set(res_term->u.app.lhs->parents, res_term, res_term->hash); + map_set(res_term->u.app.rhs->parents, res_term, res_term->hash); + return (struct term_handle){ .term = res_term, .hash = res }; } @@ -56,12 +60,12 @@ static struct term_handle var_blc(int index, size_t depth) hash_t res = hash((uint8_t *)&res_type, sizeof(res_type), index); struct term *res_term; - if ((res_term = map_get(res))) { + if ((res_term = map_get(map_all_terms(), res))) { term_refer_head(res_term, depth); } else { res_term = term_new(res_type, res, depth); res_term->u.var.index = index; - map_set(res_term, res); + map_set(map_all_terms(), res_term, res); } return (struct term_handle){ .term = res_term, .hash = res }; |