Rizin
unix-like reverse engineering framework and cli tools
|
#include "./alloc.h"
#include "./language.h"
#include "./subtree.h"
#include "./array.h"
#include "./stack.h"
#include "./length.h"
#include <assert.h>
#include <stdio.h>
Go to the source code of this file.
Classes | |
struct | StackLink |
struct | StackNode |
struct | StackIterator |
struct | StackHead |
struct | Stack |
struct | SummarizeStackSession |
Macros | |
#define | MAX_LINK_COUNT 8 |
#define | MAX_NODE_POOL_SIZE 50 |
#define | MAX_ITERATOR_COUNT 64 |
#define | inline static inline __attribute__((always_inline)) |
Typedefs | |
typedef struct StackNode | StackNode |
typedef unsigned | StackAction |
typedef StackAction(* | StackCallback) (void *, const StackIterator *) |
Enumerations | |
enum | { StackActionNone , StackActionStop = 1 , StackActionPop = 2 } |
Variables | |
StackStatus | |
#define inline static inline __attribute__((always_inline)) |
typedef unsigned StackAction |
typedef StackAction(* StackCallback) (void *, const StackIterator *) |
anonymous enum |
typedef Array | ( | StackNode * | ) |
|
inline |
Definition at line 564 of file stack.c.
References StackActionNone, and StackActionPop.
Referenced by ts_stack_pop_all().
|
inline |
Definition at line 498 of file stack.c.
References StackActionNone, StackActionPop, and StackActionStop.
Referenced by ts_stack_pop_count().
|
inline |
Definition at line 533 of file stack.c.
References StackActionNone, StackActionPop, StackActionStop, and ts_subtree_is_error().
Referenced by ts_stack_pop_error().
|
inline |
Definition at line 511 of file stack.c.
References StackActionNone, StackActionPop, and StackActionStop.
Referenced by ts_stack_pop_pending().
|
inline |
Definition at line 308 of file stack.c.
References test-lz4-speed::action, array_back, array_clear, array_erase, array_get, array_new, array_push, array_reserve, test-lz4-versions::head, i, StackIterator::is_pending, link, StackNode::link_count, StackNode::links, MAX_ITERATOR_COUNT, StackIterator::node, StackActionPop, StackActionStop, StackIterator::subtree_count, StackIterator::subtrees, ts_stack__add_slice(), ts_subtree_alloc_size(), ts_subtree_array_copy(), ts_subtree_array_delete(), ts_subtree_array_reverse(), ts_subtree_extra(), and ts_subtree_retain().
Referenced by ts_stack_pop_all(), ts_stack_pop_count(), ts_stack_pop_error(), ts_stack_pop_pending(), and ts_stack_record_summary().
Definition at line 166 of file stack.c.
References bytes, Subtree::ptr, ts_subtree_child_count(), ts_subtree_error_cost(), ts_subtree_external_scanner_state_eq(), ts_subtree_extra(), ts_subtree_padding(), ts_subtree_size(), and ts_subtree_symbol().
Referenced by stack_node_add_link().
|
static |
Definition at line 250 of file stack.c.
References array_delete, stack_node_release(), ts_free, and ts_subtree_release().
Referenced by ts_stack_clear(), ts_stack_delete(), ts_stack_remove_version(), and ts_stack_renumber_version().
|
static |
Definition at line 185 of file stack.c.
References Length::bytes, i, link, MAX_LINK_COUNT, StackLink::node, StackNode::position, stack__subtree_is_equivalent(), stack_node_retain(), StackNode::state, StackLink::subtree, ts_subtree_dynamic_precedence(), ts_subtree_node_count(), ts_subtree_release(), and ts_subtree_retain().
Referenced by ts_stack_merge().
|
static |
Definition at line 123 of file stack.c.
References array_pop, StackNode::dynamic_precedence, StackNode::error_cost, length_add(), length_zero(), StackNode::link_count, StackNode::links, StackLink::node, StackNode::node_count, StackNode::position, Subtree::ptr, StackNode::ref_count, ts_malloc, ts_subtree_dynamic_precedence(), ts_subtree_error_cost(), ts_subtree_node_count(), and ts_subtree_total_size().
Referenced by ts_stack_new(), and ts_stack_push().
|
static |
Definition at line 89 of file stack.c.
References array_push, assert(), i, link, StackNode::links, MAX_NODE_POOL_SIZE, StackLink::node, NULL, ts_free, and ts_subtree_release().
Referenced by stack_head_delete(), and ts_stack_delete().
|
static |
Definition at line 81 of file stack.c.
References assert().
Referenced by stack_node_add_link(), ts_stack__add_version(), ts_stack_clear(), and ts_stack_copy_version().
|
inline |
Definition at line 578 of file stack.c.
References array_push, i, SummarizeStackSession::max_depth, StackActionNone, StackActionStop, and SummarizeStackSession::summary.
Referenced by ts_stack_record_summary().
|
static |
Definition at line 288 of file stack.c.
References array_insert, array_push, i, and ts_stack__add_version().
Referenced by stack__iter().
|
static |
Definition at line 270 of file stack.c.
References array_push, test-lz4-versions::head, NULL_SUBTREE, stack_node_retain(), and ts_subtree_retain().
Referenced by ts_stack__add_slice().
bool ts_stack_can_merge | ( | Stack * | self, |
StackVersion | version1, | ||
StackVersion | version2 | ||
) |
Definition at line 693 of file stack.c.
References Length::bytes, StackNode::error_cost, StackHead::last_external_token, StackHead::node, StackNode::position, StackNode::state, StackHead::status, and ts_subtree_external_scanner_state_eq().
Referenced by ts_parser__better_version_exists(), and ts_stack_merge().
void ts_stack_clear | ( | Stack * | self | ) |
Definition at line 737 of file stack.c.
References array_clear, array_push, i, stack_head_delete(), and stack_node_retain().
Referenced by parser__start(), parser_parse(), ts_parser_reset(), and ts_stack_new().
StackVersion ts_stack_copy_version | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 669 of file stack.c.
References array_back, array_push, assert(), test-lz4-versions::head, NULL, stack_node_retain(), and ts_subtree_retain().
Referenced by parser__recover(), parser__reduce(), and ts_parser__handle_error().
void ts_stack_delete | ( | Stack * | self | ) |
Definition at line 424 of file stack.c.
References array_clear, array_delete, i, stack_head_delete(), stack_node_release(), and ts_free.
Referenced by parser_destroy(), and ts_parser_delete().
int ts_stack_dynamic_precedence | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 615 of file stack.c.
References array_get.
Referenced by ts_parser__better_version_exists(), and ts_parser__version_status().
unsigned ts_stack_error_cost | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 466 of file stack.c.
References array_get, ERROR_COST_PER_RECOVERY, ERROR_STATE, and test-lz4-versions::head.
Referenced by ts_parser__condense_stack(), ts_parser__recover(), ts_parser__version_status(), and ts_stack_print_dot_graph().
StackSummary* ts_stack_get_summary | ( | Stack * | self, |
StackVersion | version | ||
) |
void ts_stack_halt | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 705 of file stack.c.
References array_get.
Referenced by parser__accept(), parser__better_version_exists(), parser__handle_error(), parser__repair_error(), ts_parser__accept(), ts_parser__recover(), and ts_parser__recover_to_state().
bool ts_stack_has_advanced_since_error | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 619 of file stack.c.
References array_get, StackNode::error_cost, test-lz4-versions::head, StackNode::link_count, StackNode::links, StackLink::node, StackNode::node_count, Subtree::ptr, StackLink::subtree, ts_subtree_error_cost(), and ts_subtree_total_bytes().
Referenced by ts_parser__lex().
bool ts_stack_is_active | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 716 of file stack.c.
References array_get.
Referenced by ts_parser__better_version_exists(), ts_parser__recover(), and ts_parser_parse().
bool ts_stack_is_halted | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 720 of file stack.c.
References array_get.
Referenced by parser__advance(), parser__better_version_exists(), parser__condense_stack(), parser_parse(), and ts_parser__condense_stack().
bool ts_stack_is_paused | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 724 of file stack.c.
References array_get.
Referenced by ts_parser__condense_stack(), and ts_parser__version_status().
Subtree ts_stack_last_external_token | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 455 of file stack.c.
References array_get.
Referenced by ts_parser__advance(), and ts_parser__lex().
bool ts_stack_merge | ( | Stack * | self, |
StackVersion | version1, | ||
StackVersion | version2 | ||
) |
Definition at line 679 of file stack.c.
References ERROR_STATE, i, StackNode::link_count, StackNode::links, StackHead::node, StackNode::node_count, StackHead::node_count_at_last_error, stack_node_add_link(), StackNode::state, ts_stack_can_merge(), and ts_stack_remove_version().
Referenced by parser__condense_stack(), parser__handle_error(), parser__reduce(), ts_parser__condense_stack(), ts_parser__do_all_potential_reductions(), ts_parser__handle_error(), and ts_parser__reduce().
Stack* ts_stack_new | ( | SubtreePool * | subtree_pool | ) |
Definition at line 405 of file stack.c.
References array_init, array_reserve, MAX_NODE_POOL_SIZE, NULL, NULL_SUBTREE, stack_node_new(), ts_calloc, and ts_stack_clear().
Referenced by parser_init(), and ts_parser_new().
unsigned ts_stack_node_count_since_error | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 477 of file stack.c.
References array_get, and test-lz4-versions::head.
Referenced by ts_parser__better_version_exists(), ts_parser__recover(), ts_parser__version_status(), ts_parser_has_outstanding_parse(), and ts_stack_print_dot_graph().
void ts_stack_pause | ( | Stack * | self, |
StackVersion | version, | ||
Subtree | lookahead | ||
) |
Definition at line 709 of file stack.c.
References array_get, and test-lz4-versions::head.
Referenced by ts_parser__advance().
StackSliceArray ts_stack_pop_all | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 569 of file stack.c.
References NULL, pop_all_callback(), and stack__iter().
Referenced by parser__accept(), and ts_parser__accept().
StackSliceArray ts_stack_pop_count | ( | Stack * | self, |
StackVersion | version, | ||
uint32_t | count | ||
) |
Definition at line 507 of file stack.c.
References count, pop_count_callback(), and stack__iter().
Referenced by parser__reduce(), ts_parser__recover(), ts_parser__recover_to_state(), and ts_parser__reduce().
SubtreeArray ts_stack_pop_error | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 547 of file stack.c.
References array_get, assert(), i, StackNode::link_count, StackNode::links, pop_error_callback(), Subtree::ptr, stack__iter(), StackLink::subtree, ts_stack_renumber_version(), and ts_subtree_is_error().
Referenced by ts_parser__recover_to_state().
StackSliceArray ts_stack_pop_pending | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 524 of file stack.c.
References NULL, pop_pending_callback(), stack__iter(), ts_stack_renumber_version(), and version.
Referenced by parser__breakdown_top_of_stack(), and ts_parser__breakdown_top_of_stack().
Length ts_stack_position | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 451 of file stack.c.
References array_get.
Referenced by ts_parser__advance(), ts_parser__better_version_exists(), ts_parser__handle_error(), ts_parser__lex(), ts_parser__recover(), and ts_parser_parse().
bool ts_stack_print_dot_graph | ( | Stack * | self, |
const TSLanguage * | language, | ||
FILE * | f | ||
) |
Definition at line 751 of file stack.c.
References Array(), array_back, array_clear, array_delete, array_new, array_push, array_reserve, c, TSPoint::column, StackNode::dynamic_precedence, StackNode::error_cost, ERROR_STATE, Length::extent, f, test-lz4-versions::head, i, link, StackNode::link_count, StackNode::links, StackIterator::node, StackNode::node_count, NULL, StackNode::position, Subtree::ptr, TSPoint::row, StackNode::state, StackLink::subtree, ts_external_scanner_state_data(), ts_language_symbol_name(), ts_stack_error_cost(), ts_stack_node_count_since_error(), ts_subtree_dynamic_precedence(), ts_subtree_error_cost(), ts_subtree_extra(), ts_subtree_named(), ts_subtree_symbol(), and ts_subtree_visible().
void ts_stack_push | ( | Stack * | self, |
StackVersion | version, | ||
Subtree | subtree, | ||
bool | pending, | ||
TSStateId | state | ||
) |
Definition at line 485 of file stack.c.
References array_get, test-lz4-versions::head, StackNode::node_count, Subtree::ptr, and stack_node_new().
Referenced by parser__accept(), parser__breakdown_top_of_stack(), parser__handle_error(), parser__push(), parser__reduce(), parser__shift(), ts_parser__accept(), ts_parser__breakdown_top_of_stack(), ts_parser__handle_error(), ts_parser__recover(), ts_parser__recover_to_state(), ts_parser__reduce(), and ts_parser__shift().
void ts_stack_record_summary | ( | Stack * | self, |
StackVersion | version, | ||
unsigned | max_depth | ||
) |
Definition at line 596 of file stack.c.
References array_delete, array_init, test-lz4-versions::head, stack__iter(), summarize_stack_callback(), SummarizeStackSession::summary, ts_free, ts_malloc, and version.
Referenced by ts_parser__handle_error().
void ts_stack_remove_version | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 643 of file stack.c.
References array_erase, array_get, and stack_head_delete().
Referenced by parser__accept(), parser__condense_stack(), parser__do_potential_reductions(), parser__recover(), parser__reduce(), parser__repair_error(), ts_parser__accept(), ts_parser__condense_stack(), ts_parser__do_all_potential_reductions(), ts_parser__recover(), ts_parser__reduce(), and ts_stack_merge().
void ts_stack_renumber_version | ( | Stack * | self, |
StackVersion | v1, | ||
StackVersion | v2 | ||
) |
Definition at line 648 of file stack.c.
References array_erase, assert(), NULL, stack_head_delete(), StackHead::summary, and v1.
Referenced by parser__advance(), parser__do_potential_reductions(), parser__repair_error(), ts_parser__advance(), ts_parser__do_all_potential_reductions(), ts_parser__recover(), ts_stack_pop_error(), and ts_stack_pop_pending().
Subtree ts_stack_resume | ( | Stack * | self, |
StackVersion | version | ||
) |
Definition at line 728 of file stack.c.
References array_get, assert(), test-lz4-versions::head, and NULL_SUBTREE.
Referenced by ts_parser__condense_stack().
void ts_stack_set_last_external_token | ( | Stack * | self, |
StackVersion | version, | ||
Subtree | token | ||
) |
Definition at line 459 of file stack.c.
References array_get, test-lz4-versions::head, Subtree::ptr, ts_subtree_release(), and ts_subtree_retain().
Referenced by ts_parser__recover(), and ts_parser__shift().
TSStateId ts_stack_state | ( | const Stack * | self, |
StackVersion | version | ||
) |
Definition at line 447 of file stack.c.
References array_get.
Referenced by ts_parser__advance(), ts_parser__breakdown_top_of_stack(), ts_parser__do_all_potential_reductions(), ts_parser__handle_error(), ts_parser__recover(), ts_parser__recover_to_state(), ts_parser__reduce(), ts_parser__reuse_node(), ts_parser__version_status(), ts_parser_has_outstanding_parse(), and ts_parser_parse().
void ts_stack_swap_versions | ( | Stack * | self, |
StackVersion | v1, | ||
StackVersion | v2 | ||
) |
Definition at line 443 of file stack.c.
Referenced by parser__better_version_exists(), parser__condense_stack(), parser__do_potential_reductions(), parser__handle_error(), parser__reduce(), parser__shift(), parser_parse(), ts_parser__better_version_exists(), ts_parser__condense_stack(), ts_parser__do_all_potential_reductions(), ts_parser__handle_error(), ts_parser__recover(), ts_parser__reduce(), and ts_parser_parse().