OR-1 dataflow CPU sketch
1#include "tree_sitter/api.h"
2
3#include <napi.h>
4
5#ifndef NODE_TREE_SITTER_ADDON_DATA_H_
6#define NODE_TREE_SITTER_ADDON_DATA_H_
7
8namespace node_tree_sitter {
9
10class AddonData final {
11public:
12 explicit AddonData(Napi::Env _env) {}
13
14 ~AddonData() {
15 ts_query_cursor_delete(ts_query_cursor);
16 }
17
18 // conversions
19 uint32_t *point_transfer_buffer = nullptr;
20
21 // node
22 uint32_t *transfer_buffer = nullptr;
23 uint32_t transfer_buffer_length = 0;
24 Napi::ObjectReference module_exports;
25 TSTreeCursor scratch_cursor = {nullptr, nullptr, {0, 0}};
26
27 // parser
28 Napi::FunctionReference parser_constructor;
29 Napi::FunctionReference string_slice;
30
31 // query
32 TSQueryCursor *ts_query_cursor = nullptr;
33 Napi::FunctionReference query_constructor;
34
35 // tree_cursor
36 Napi::FunctionReference tree_cursor_constructor;
37
38 // tree
39 Napi::FunctionReference tree_constructor;
40
41 // lookaheaditerator
42 Napi::FunctionReference lookahead_iterator_constructor;
43};
44
45} // namespace node_tree_sitter
46
47#endif // NODE_TREE_SITTER_ADDON_DATA_H_