Rework AST access API: reduce heap allocation
This commit is contained in:
parent
feb46302f3
commit
54e40b8146
16 changed files with 288 additions and 273 deletions
|
|
@ -2,19 +2,13 @@
|
|||
#define RUNTIME_NODE_H_
|
||||
|
||||
#include "tree_sitter/parser.h"
|
||||
#include "runtime/length.h"
|
||||
#include "runtime/tree.h"
|
||||
|
||||
struct TSNode {
|
||||
size_t ref_count;
|
||||
size_t index;
|
||||
TSLength position;
|
||||
const TSTree *content;
|
||||
struct TSNode *parent;
|
||||
const char **names;
|
||||
};
|
||||
TSNode ts_node_make(const TSTree *, TSLength);
|
||||
|
||||
TSNode *ts_node_make(const TSTree *tree, TSNode *parent, size_t index,
|
||||
TSLength position, const char **names);
|
||||
TSNode *ts_node_make_root(const TSTree *tree, const char **names);
|
||||
static inline TSNode ts_node_null() {
|
||||
return (TSNode){.data = NULL, .position = ts_length_zero() };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue