Migrate event_block's event into block_t

This commit is contained in:
ridiculousfish 2019-05-19 13:07:06 -07:00
parent 8697fa063b
commit cf92b7626c
2 changed files with 6 additions and 3 deletions

View file

@ -353,7 +353,8 @@ void parser_t::stack_trace_internal(size_t block_idx, wcstring *buff) const {
if (b->type() == EVENT) {
// This is an event handler.
const event_block_t *eb = static_cast<const event_block_t *>(b);
wcstring description = event_get_desc(eb->event);
assert(eb->event && "Should have an event");
wcstring description = event_get_desc(*eb->event);
append_format(*buff, _(L"in event handler: %ls\n"), description.c_str());
// Stop recursing at event handler. No reason to believe that any other code is relevant.
@ -836,7 +837,7 @@ wcstring block_t::description() const {
if_block_t::if_block_t() : block_t(IF) {}
event_block_t::event_block_t(const event_t &evt) : block_t(EVENT), event(evt) {}
event_block_t::event_block_t(const event_t &evt) : block_t(EVENT) { this->event = evt; }
function_block_t::function_block_t(wcstring name, wcstring_list_t args, bool shadows)
: block_t(shadows ? FUNCTION_CALL : FUNCTION_CALL_NO_SHADOW) {

View file

@ -84,6 +84,9 @@ struct block_t {
// Otherwise nothing.
const wchar_t *sourced_file{};
// If this is an event block, the event. Otherwise ignored.
maybe_t<event_t> event;
block_type_t type() const { return this->block_type; }
/// Description of the block, for debugging.
@ -98,7 +101,6 @@ struct if_block_t : public block_t {
};
struct event_block_t : public block_t {
event_t const event;
explicit event_block_t(const event_t &evt);
};