feat/8-ast-datastructures #11

Merged
thacuber2a03 merged 3 commits from feat/8-ast-datastructures into main 2025-10-20 23:12:14 +02:00

Example usage:

  click_ast_k_unary* x = click_ast_new(header->_obj._arena, click_ast_k_unary);
  click_ast* xx = &x->header;

  click_ast_dup(x);
  click_ast_drop(x);
  click_dup(click_ast, xx);
  click_drop(click_ast, xx);
  click_ast_drop(x);

closes #8

Example usage: ```c click_ast_k_unary* x = click_ast_new(header->_obj._arena, click_ast_k_unary); click_ast* xx = &x->header; click_ast_dup(x); click_ast_drop(x); click_dup(click_ast, xx); click_drop(click_ast, xx); click_ast_drop(x); ``` closes #8
@ -50,2 +69,4 @@
typedef int click_exitcode;
#define click_borrow /* borrow ownership for lifetime */
#define click_move /* permanently move ownership */
Owner

what do you plan on doing here?

what do you plan on doing here?
Author
Owner

just improve code readability; also there are ownership specifiers in c23 I thnk? didn't look at it yet

just improve code readability; also there are ownership specifiers in c23 I thnk? didn't look at it yet
alexander.nutz marked this conversation as resolved
thacuber2a03 left a comment
Owner

I'm merging all of this but I'm going to take the time to document it all as really only you can read it

I'm merging all of this but I'm going to take the time to document it all as really only you can read it
@ -199,0 +292,4 @@
} while (0)
#define click_dup_impl(/* borrow */ obj) \
click_debug_assert(((click_obj_header*) (obj))->_rc++ != 0);
Owner

what does it mean for _rc to be -1

what does it mean for `_rc` to be -1
Author
Owner

this just makes sure we aren't overflowing refcount

this just makes sure we aren't overflowing refcount
Author
Owner

but actually that should be a pre increment

but actually that should be a pre increment
Owner

sob

just patch it into main I guess I can't be bothered

sob just patch it into main I guess I can't be bothered
Author
Owner

but merge conflicts with the header PR
I'll open an issue instead and we do it after header PR merged

but merge conflicts with the header PR I'll open an issue instead and we do it after header PR merged
alexander.nutz marked this conversation as resolved
@ -199,0 +303,4 @@
#define click_as_obj(t, ptr) \
((click_obj_header*) &( \
(t*) click_obj_forward_ptr_and_assert(t, (t*) ptr)) \
->_obj)
Owner

_obj is only really explained once you get to click_ast.h, might wanna check that

`_obj` is only really explained once you get to `click_ast.h`, might wanna check that
@ -0,0 +33,4 @@
// this or any of the children had parser error
bool contains_parser_error : 1;
// this had parser error itself
bool is_parser_error : 1;
Owner

"this"

(would replace with "this node", assuming everything here is, in fact, the header for a node. granted, I still have no idea what the point of an obj is)

"this" (would replace with "this node", assuming everything here is, in fact, the header for a node. granted, I still have no idea what the point of an obj is)
alexander.nutz marked this conversation as resolved
@ -0,0 +49,4 @@
#define click_ast_header_children(ast_header) \
((click_ast**) (((char*) (void*) (click_ast*) (ast_header)) + \
click_ast_kindinfo[(ast_header)->kind].children_offset))
Owner

oh my god

oh my god
alexander.nutz marked this conversation as resolved
@ -235,0 +238,4 @@
void click_check_impl_fail(void)
{
click_panic("click object generational reference fail -> reference was kept longer than object lifetime");
}
Owner

any reason this needs to be a separate impl function?

any reason this needs to be a separate impl function?
Author
Owner

yes because performance

yes because performance
alexander.nutz marked this conversation as resolved
thacuber2a03 deleted branch feat/8-ast-datastructures 2025-10-20 23:12:14 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
click-project/click!11
No description provided.