13 #define TS_START_END(node, start, end) \
15 start = ts_node_start_byte(node); \
16 end = ts_node_end_byte(node); \
36 state->types = ht_pp_new0();
38 state->types = base_types;
40 if (!callable_types) {
41 state->callables = ht_pp_new0();
43 state->callables = callable_types;
46 state->forward = ht_pp_new0();
51 state->verbose =
false;
56 ht_pp_free(
state->forward);
57 ht_pp_free(
state->types);
58 ht_pp_free(
state->callables);
67 ht_pp_free(
state->forward);
152 if (!root_node_child_count) {
160 if (
state->verbose) {
179 int i = 0, result = 0;
180 for (
i = 0;
i < root_node_child_count;
i++) {
184 if (!strcmp(node_code,
";") || !strcmp(node_code,
",")) {
202 *error_msg =
strdup(error_msgs);
207 if (
state->verbose) {
240 size_t read_bytes = 0;
242 if (!source_code || !read_bytes) {
261 size_t read_bytes = 0;
263 if (!source_code || !read_bytes) {
285 eprintf(
"CParserState initialization error!\n");
333 if (!root_node_child_count) {
342 if (
parser->state->verbose) {
363 int i = 0, result = 0;
365 for (
i = 0;
i < root_node_child_count;
i++) {
374 if (result || !tpair) {
382 *error_msg =
strdup(error_msgs);
387 if (
parser->state->verbose) {
425 if (!root_node_child_count) {
433 if (
parser->state->verbose) {
453 int i = 0, result = 0;
455 for (
i = 0;
i < root_node_child_count;
i++) {
464 if (result || !tpair) {
472 *error_msg =
strdup(error_msgs);
477 if (
parser->state->verbose) {
const char * ts_node_type(TSNode)
void ts_parser_delete(TSParser *parser)
TSNode ts_node_named_child(TSNode, uint32_t)
char * ts_node_string(TSNode)
uint32_t ts_node_named_child_count(TSNode)
void ts_tree_delete(TSTree *self)
TSNode ts_tree_root_node(const TSTree *self)
bool ts_parser_set_language(TSParser *self, const TSLanguage *language)
TSParser * ts_parser_new(void)
TSTree * ts_parser_parse_string(TSParser *self, const TSTree *old_tree, const char *string, uint32_t length)
RZ_API RZ_OWN RzTypeParser * rz_type_parser_init(HtPP *types, HtPP *callables)
Creates a new instance of the C type parser.
RZ_API int rz_type_parse_file(RzTypeDB *typedb, const char *path, const char *dir, char **error_msg)
Parses the C types file creating the new parser state.
TSLanguage * tree_sitter_c()
RZ_API RZ_OWN RzType * rz_type_parse_string_declaration_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type declaration.
#define TS_START_END(node, start, end)
RZ_API RZ_OWN RzTypeParser * rz_type_parser_new()
Creates a new instance of the C type parser.
RZ_API void rz_type_parser_free(RZ_NONNULL RzTypeParser *parser)
Frees the instance of the C type parser without destroying hashtables.
void c_parser_state_free_keep_ht(CParserState *state)
RZ_API RZ_OWN RzType * rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type definition.
RZ_API int rz_type_parse_string_stateless(RzTypeParser *parser, const char *code, char **error_msg)
Parses the C type string reusing the existing parser state.
static int type_parse_string(CParserState *state, const char *code, char **error_msg)
void c_parser_state_reset_keep_ht(CParserState *state)
CParserState * c_parser_state_new(HtPP *base_types, HtPP *callable_types)
RZ_API int rz_type_parse_file_stateless(RzTypeParser *parser, const char *path, const char *dir, char **error_msg)
Parses the C types file reusing the existing parser state.
static char * ts_node_sub_string(TSNode node, const char *cstr)
RZ_API void rz_type_parse_reset(RzTypeDB *typedb)
Reset the C parser state.
void c_parser_state_free(CParserState *state)
RZ_API int rz_type_parse_string(RzTypeDB *typedb, const char *code, char **error_msg)
Parses the C type string creating the new parser state.
RZ_API void rz_type_parser_free_purge(RZ_NONNULL RzTypeParser *parser)
Frees the instance of the C type parser and destroy the hashtables.
static static fork const void static count static fd const char const char static newpath const char static path const char path
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
RZ_API void Ht_() free(HtName_(Ht) *ht)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
insn_type_descr_t types[]
#define rz_return_val_if_fail(expr, val)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API ut64 rz_file_size(const char *str)
#define RZ_LOG_DEBUG(fmtstr,...)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API RZ_OWN char * rz_strbuf_drain_nofree(RzStrBuf *sb)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
int parse_declaration_node(CParserState *state, TSNode node, const char *text, ParserTypePair **tpair)
int parse_type_nodes_save(CParserState *state, TSNode node, const char *text)
int parse_type_descriptor_single(CParserState *state, TSNode node, const char *text, ParserTypePair **tpair)
void parser_debug(CParserState *state, const char *fmt,...)
void parser_warning(CParserState *state, const char *fmt,...)