From cf92b7626c2a0db3308602fbf02637d889526020 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 19 May 2019 13:07:06 -0700 Subject: [PATCH] Migrate event_block's event into block_t --- src/parser.cpp | 5 +++-- src/parser.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 8bd8a694f..872b34ce1 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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(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) { diff --git a/src/parser.h b/src/parser.h index 0911701d6..ca29302a9 100644 --- a/src/parser.h +++ b/src/parser.h @@ -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; + 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); };