Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_types.h>
#include <rz_list.h>
#include <rz_util/rz_str.h>
#include <rz_util/rz_assert.h>
#include <rz_type.h>
#include <tree_sitter/api.h>
#include <types_parser.h>
Go to the source code of this file.
bool c_parser_array_set_subtype | ( | CParserState * | state, |
RZ_BORROW ParserTypePair * | tpair, | ||
RZ_OWN ParserTypePair * | subpair | ||
) |
Definition at line 889 of file types_storage.c.
References rz_return_val_if_fail, and RZ_TYPE_KIND_ARRAY.
bool c_parser_base_type_exists | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 32 of file types_storage.c.
References c_parser_base_type_find(), and NULL.
Referenced by c_parser_base_type_store(), c_parser_forward_definition_remove(), c_parser_forward_definition_store(), c_parser_new_enum_forward_definition(), c_parser_new_enum_type(), c_parser_new_primitive_type(), c_parser_new_structure_forward_definition(), c_parser_new_structure_type(), c_parser_new_typedef(), c_parser_new_typedef_forward_definition(), c_parser_new_union_forward_definition(), and c_parser_new_union_type().
RzBaseType* c_parser_base_type_find | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 17 of file types_storage.c.
Referenced by c_parser_base_type_exists(), c_parser_get_enum_type(), c_parser_get_primitive_type(), c_parser_get_structure_type(), c_parser_get_typedef(), and c_parser_get_union_type().
bool c_parser_base_type_is_forward_definition | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 26 of file types_storage.c.
References found.
Referenced by c_parser_forward_definition_store(), c_parser_new_enum_forward_definition(), c_parser_new_structure_forward_definition(), c_parser_new_typedef_forward_definition(), c_parser_new_union_forward_definition(), parse_enum_node(), parse_sole_type_name(), parse_struct_node(), parse_typedef_node(), and parse_union_node().
bool c_parser_base_type_store | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
ParserTypePair * | tpair | ||
) |
Definition at line 36 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), and rz_return_val_if_fail.
Referenced by parse_enum_node(), parse_primitive_type(), parse_sized_primitive_type(), parse_struct_node(), parse_typedef_node(), and parse_union_node().
bool c_parser_callable_type_exists | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 94 of file types_storage.c.
References c_parser_callable_type_find(), and NULL.
Referenced by c_parser_callable_type_store().
RzCallable* c_parser_callable_type_find | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 85 of file types_storage.c.
Referenced by c_parser_callable_type_exists().
bool c_parser_callable_type_store | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
RZ_NONNULL RzType * | type | ||
) |
Definition at line 98 of file types_storage.c.
References c_parser_callable_type_exists(), parser_debug(), rz_return_val_if_fail, RZ_TYPE_KIND_CALLABLE, and type.
Referenced by parse_type_abstract_declarator_node(), and parse_type_declarator_node().
bool c_parser_forward_definition_remove | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 70 of file types_storage.c.
References c_parser_base_type_exists(), and rz_return_val_if_fail.
Referenced by parse_enum_node(), parse_struct_node(), parse_typedef_node(), and parse_union_node().
bool c_parser_forward_definition_store | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Definition at line 50 of file types_storage.c.
References c_parser_base_type_exists(), c_parser_base_type_is_forward_definition(), NULL, and rz_return_val_if_fail.
Referenced by c_parser_new_typedef(), and parse_sole_type_name().
RZ_OWN ParserTypePair* c_parser_get_enum_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Returns the enum type if matching in the types hashtable.
If the name matches with the name of one of the base types that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzBaseType as a base. Then it wraps boths in the "type pair"
state | The parser state |
name | Name of the enum type to fetch |
Definition at line 573 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_find(), c_parser_new_enum_naked_type(), rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_ENUM, and rz_return_val_if_fail.
Referenced by parse_enum_node().
RZ_OWN ParserTypePair* c_parser_get_primitive_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
bool | is_const | ||
) |
Returns the primitive type if matching in the types hashtable.
If the name matches with the name of one of the base types that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzBaseType as a base. Then it wraps boths in the "type pair"
state | The parser state |
name | Name of the primitive type to fetch |
is_const | If the primitive type is const |
Definition at line 209 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_find(), rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_ATOMIC, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by parse_primitive_type(), parse_sized_primitive_type(), and parse_sole_type_name().
RZ_OWN ParserTypePair* c_parser_get_structure_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Returns the structure type if matching in the types hashtable.
If the name matches with the name of one of the base types that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzBaseType as a base. Then it wraps boths in the "type pair"
state | The parser state |
name | Name of the structure type to fetch |
Definition at line 317 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_find(), c_parser_new_structure_naked_type(), rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_STRUCT, and rz_return_val_if_fail.
Referenced by parse_sole_type_name(), and parse_struct_node().
RZ_OWN ParserTypePair* c_parser_get_typedef | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Returns the type if matching in the types hashtable.
If the name matches with the name of one of the type aliases that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzBaseType as a base. Then it wraps boths in the "type pair"
state | The parser state |
name | Name of the type alias to fetch |
Definition at line 739 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_find(), rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_TYPEDEF, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by parse_sole_type_name().
RZ_OWN ParserTypePair* c_parser_get_union_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Returns the union type if matching in the types hashtable.
If the name matches with the name of one of the base types that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzBaseType as a base. Then it wraps boths in the "type pair"
state | The parser state |
name | Name of the union type to fetch |
Definition at line 445 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_find(), c_parser_new_union_naked_type(), rz_base_type_t::kind, NULL, RZ_BASE_TYPE_KIND_UNION, and rz_return_val_if_fail.
Referenced by parse_sole_type_name(), and parse_union_node().
RZ_OWN char* c_parser_new_anonymous_callable_name | ( | CParserState * | state | ) |
Definition at line 915 of file types_storage.c.
References name, and rz_str_newf().
Referenced by parse_type_abstract_declarator_node().
RZ_OWN char* c_parser_new_anonymous_enum_name | ( | CParserState * | state | ) |
Definition at line 909 of file types_storage.c.
References name, and rz_str_newf().
Referenced by parse_enum_node().
RZ_OWN char* c_parser_new_anonymous_structure_name | ( | CParserState * | state | ) |
Definition at line 897 of file types_storage.c.
References name, and rz_str_newf().
Referenced by parse_struct_node().
RZ_OWN char* c_parser_new_anonymous_union_name | ( | CParserState * | state | ) |
Definition at line 903 of file types_storage.c.
References name, and rz_str_newf().
Referenced by parse_union_node().
RZ_OWN RzType* c_parser_new_callable | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new callable based on the name.
If the name matches with the name of one of the base types that are in the hashtable of the existing types in the parser state, then it creates new RzType with the found RzCallable as a base.
In case of the callable found in the hashtable the ownership transfer doesn't happen. If not - it does.
state | The parser state |
name | Name of the callable type to create |
Definition at line 802 of file types_storage.c.
References rz_callable_at::args, found, free(), rz_callable_at::name, NULL, RZ_NEW0, rz_pvector_new(), rz_return_val_if_fail, rz_type_callable_arg_free(), RZ_TYPE_KIND_CALLABLE, strdup(), and type.
Referenced by parse_type_abstract_declarator_node().
bool c_parser_new_callable_argument | ( | CParserState * | state, |
RZ_NONNULL RzCallable * | callable, | ||
RZ_NONNULL const char * | name, | ||
RZ_OWN RZ_NONNULL RzType * | type | ||
) |
Adds a new argument to the callable.
state | The parser state |
callable | Callable type |
name | Name of the argument |
type | Type of the argument |
Definition at line 834 of file types_storage.c.
References arg::name, RZ_NEW0, rz_pvector_foreach, rz_pvector_push(), rz_return_val_if_fail, strdup(), and type.
Referenced by parse_parameter_list().
RZ_OWN ParserTypePair* c_parser_new_enum_forward_definition | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new enum forward definition.
state | The parser state |
name | Name of the enum C type to create |
Definition at line 596 of file types_storage.c.
References c_parser_base_type_exists(), c_parser_base_type_is_forward_definition(), c_parser_new_enum_naked_type(), NULL, and rz_return_val_if_fail.
Referenced by parse_enum_node().
RZ_OWN ParserTypePair* c_parser_new_enum_naked_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new enum naked type (without base type) based on the name.
state | The parser state |
name | Name of the enum C type to create |
Definition at line 497 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_ENUM, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by c_parser_get_enum_type(), c_parser_new_enum_forward_definition(), c_parser_new_enum_type(), and parse_enum_node().
RZ_OWN ParserTypePair* c_parser_new_enum_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
size_t | cases_count | ||
) |
Creates new enumeration type based on the name.
state | The parser state |
name | Name of the primitive C type to create |
cases_count | The count of the enum cases |
Definition at line 526 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), c_parser_new_enum_naked_type(), rz_base_type_enum_t::cases, rz_base_type_t::enum_data, free(), rz_base_type_t::name, NULL, parser_error(), RZ_BASE_TYPE_KIND_ENUM, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_base_type_new(), rz_type_free(), rz_vector_reserve(), strdup(), rz_base_type_t::type, and ParserTypePair::type.
Referenced by parse_enum_node().
RZ_OWN RzType* c_parser_new_naked_callable | ( | CParserState * | state | ) |
Creates new naked callable without storing it.
state | The parser state |
Definition at line 771 of file types_storage.c.
References rz_callable_at::args, free(), rz_callable_at::name, NULL, RZ_NEW0, rz_pvector_new(), rz_return_val_if_fail, rz_type_callable_arg_free(), RZ_TYPE_KIND_CALLABLE, and type.
Referenced by parse_type_declarator_node().
RZ_OWN ParserTypePair* c_parser_new_primitive_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
bool | is_const | ||
) |
Creates new primitive type based on the name.
state | The parser state |
name | Name of the primitive C type to create |
is_const | If the primitive type is const |
Definition at line 150 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), free(), rz_base_type_t::name, NULL, parser_error(), RZ_BASE_TYPE_KIND_ATOMIC, RZ_NEW0, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_base_type_new(), rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by parse_primitive_type(), parse_sized_primitive_type(), and parse_sole_type_name().
RZ_OWN ParserTypePair* c_parser_new_structure_forward_definition | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new structure forward definition.
state | The parser state |
name | Name of the structure C type to create |
Definition at line 340 of file types_storage.c.
References c_parser_base_type_exists(), c_parser_base_type_is_forward_definition(), c_parser_new_structure_naked_type(), NULL, and rz_return_val_if_fail.
Referenced by parse_struct_node().
RZ_OWN ParserTypePair* c_parser_new_structure_naked_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new structure naked type (without base type) based on the name.
state | The parser state |
name | Name of the structure C type to create |
Definition at line 242 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_STRUCT, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by c_parser_get_structure_type(), c_parser_new_structure_forward_definition(), c_parser_new_structure_type(), and parse_struct_node().
RZ_OWN ParserTypePair* c_parser_new_structure_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
size_t | members_count | ||
) |
Creates new structure "type + base type" pair based on the name.
state | The parser state |
name | Name of the structure C type to create |
members_count | The count of the structure members |
Definition at line 271 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), c_parser_new_structure_naked_type(), free(), rz_base_type_struct_t::members, rz_base_type_t::name, NULL, parser_error(), RZ_BASE_TYPE_KIND_STRUCT, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_base_type_new(), rz_type_free(), rz_vector_reserve(), strdup(), rz_base_type_t::struct_data, rz_base_type_t::type, and ParserTypePair::type.
Referenced by parse_struct_node().
RZ_OWN ParserTypePair* c_parser_new_typedef | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
RZ_NONNULL const char * | base | ||
) |
Creates new type alias based on the name.
state | The parser state |
name | Name of the primitive C type to create |
cases_count | The count of the enum cases |
Definition at line 683 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), c_parser_forward_definition_store(), c_parser_new_typedef_naked_type(), free(), rz_base_type_t::name, NULL, parser_error(), RZ_BASE_TYPE_KIND_TYPEDEF, RZ_NEW0, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_base_type_new(), rz_type_free(), RZ_TYPE_KIND_IDENTIFIER, strdup(), type, rz_base_type_t::type, and ParserTypePair::type.
Referenced by parse_typedef_node().
RZ_OWN ParserTypePair* c_parser_new_typedef_forward_definition | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new type alias forward definition.
state | The parser state |
name | Name of the typedef C type to create |
Definition at line 653 of file types_storage.c.
References c_parser_base_type_exists(), c_parser_base_type_is_forward_definition(), c_parser_new_typedef_naked_type(), NULL, and rz_return_val_if_fail.
RZ_OWN ParserTypePair* c_parser_new_typedef_naked_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new type alias naked type (without base type) based on the name.
state | The parser state |
name | Name of the typedef C type to create |
Definition at line 625 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by c_parser_new_typedef(), and c_parser_new_typedef_forward_definition().
RZ_OWN ParserTypePair* c_parser_new_union_forward_definition | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new union forward definition.
state | The parser state |
name | Name of the union C type to create |
Definition at line 468 of file types_storage.c.
References c_parser_base_type_exists(), c_parser_base_type_is_forward_definition(), c_parser_new_union_naked_type(), NULL, and rz_return_val_if_fail.
Referenced by parse_union_node().
RZ_OWN ParserTypePair* c_parser_new_union_naked_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name | ||
) |
Creates new union naked type (without base type) based on the name.
state | The parser state |
name | Name of the union C type to create |
Definition at line 369 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNION, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by c_parser_get_union_type(), c_parser_new_union_forward_definition(), c_parser_new_union_type(), and parse_union_node().
RZ_OWN ParserTypePair* c_parser_new_union_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
size_t | members_count | ||
) |
Creates new union "type + base type" pair based on the name.
state | The parser state |
name | Name of the union C type to create |
members_count | The count of the union members |
Definition at line 398 of file types_storage.c.
References ParserTypePair::btype, c_parser_base_type_exists(), c_parser_new_union_naked_type(), free(), rz_base_type_union_t::members, rz_base_type_t::name, NULL, parser_error(), RZ_BASE_TYPE_KIND_UNION, rz_return_val_if_fail, rz_type_base_type_free(), rz_type_base_type_new(), rz_type_free(), rz_vector_reserve(), strdup(), rz_base_type_t::type, ParserTypePair::type, and rz_base_type_t::union_data.
Referenced by parse_union_node().
RZ_OWN ParserTypePair* c_parser_new_unspecified_naked_type | ( | CParserState * | state, |
RZ_NONNULL const char * | name, | ||
bool | is_const | ||
) |
Creates new unspecified naked type (without base type) based on the name.
state | The parser state |
name | Name of the type to create |
is_const | If the identifier is constant |
Definition at line 121 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, rz_type_free(), RZ_TYPE_IDENTIFIER_KIND_UNSPECIFIED, RZ_TYPE_KIND_IDENTIFIER, strdup(), type, and ParserTypePair::type.
Referenced by parse_sole_type_name().
bool c_parser_pointer_set_subtype | ( | CParserState * | state, |
RZ_BORROW ParserTypePair * | tpair, | ||
RZ_OWN ParserTypePair * | subpair | ||
) |
Definition at line 881 of file types_storage.c.
References rz_return_val_if_fail, and RZ_TYPE_KIND_POINTER.
RZ_OWN ParserTypePair* c_parser_type_wrap_to_array | ( | CParserState * | state, |
ParserTypePair * | tpair, | ||
size_t | size | ||
) |
Definition at line 869 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, RZ_TYPE_KIND_ARRAY, type, and ParserTypePair::type.
RZ_OWN ParserTypePair* c_parser_type_wrap_to_pointer | ( | CParserState * | state, |
ParserTypePair * | tpair, | ||
bool | is_const | ||
) |
Definition at line 857 of file types_storage.c.
References ParserTypePair::btype, NULL, RZ_NEW0, rz_return_val_if_fail, RZ_TYPE_KIND_POINTER, type, and ParserTypePair::type.