diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2022-07-12 16:44:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 16:44:58 -0700 |
commit | 6ce01c552ef4ac2cdc44f74e6e55797ea512f539 (patch) | |
tree | de08449698f07b8b39279dd3a802009e9004ee51 /src/binaryen-c.h | |
parent | 65875f3fdbf09c46aa63f54337662d404e4f1c40 (diff) | |
download | binaryen-6ce01c552ef4ac2cdc44f74e6e55797ea512f539.tar.gz binaryen-6ce01c552ef4ac2cdc44f74e6e55797ea512f539.tar.bz2 binaryen-6ce01c552ef4ac2cdc44f74e6e55797ea512f539.zip |
[Parser][NFC] Refactor to use context callbacks (#4799)
The parser functions previously both parsed the input and controlled what was
done with the results using `constexpr` if-else chains. As the number of parsing
contexts grew, these if-else chains became increasingly complex and distracting
from the core parsing logic of the parsing functions.
To simplify the code, refactor the parsing functions to replace the `constexpr`
if-else chains with unconditional calls to methods on the context. To avoid
duplicating most method definitions for multiple parsing contexts, introduce new
utility contexts that implement common methods and (ab)use inheritance and
multiple inheritance to reuse their methods from the main parsing contexts.
This change will also make it easier to reuse the parser code for entirely
different purposes in the future by providing new context implementations. For
example, V8 could reuse the code and provide different parser contexts that
construct V8-internal data structures rather than Binaryen data structures.
Diffstat (limited to 'src/binaryen-c.h')
0 files changed, 0 insertions, 0 deletions