blob: 532f2ee358696a995244afe6c1697d4715a0d039 [file] [log] [blame] [view]
# zxdb/expr
This directory handles parsing and evaluating console expressions. These are
what appear in the "print" command, for example.
They are not to be confused with "DWARF expressions" which are small programs
used to evaluate the location of variables.
## Main Components
_Tokenizer:_ The tokenizer is in `expr_tokenizer.cc` and converts input into a
stream of tokens that can be used by the parser.
_Parser:_ The parser is in `expr_parser.cc` and converts tokens into the
Abstract Syntax Tree.
_Abstract Syntax Tree:_ This tree is in `expr_node.cc` where each `ExprNode`
subclass is a node in the tree. These nodes know how to recursively execute
themselves to produce a result.
_Expression Value:_ The `ExprValue` is in `expr_value.cc` and represents a
value when executing the Abstract Syntax Tree. Each value has a type that
describes it (a reference to the DWARF symbol data) and the binary data
associated with the value.
## Integration with the outside world
The abstract syntax tree code that executes doesn't actually refer directly to
the symbol data or the running process. Mostly this is to allow better unit
testing.
_Looking up symbols:_ The abstract syntax tree nodes look up variables using
the abstract `EvalContext`. The `EvalContextImpl` is the normal concrete
implementation of this class that references the symbols associated with a
process (`ProcessSymbols`) and provides access to the `SymbolDataProvider`
implementation that reads data from the running process.
## Helper components
The rest of the code in this directory are helper classes for executing the
syntax tree, in particular for converting names to variable declarations
(`find_variable.*` and `found_*`) and converting various types of variable
accesses to data (`resolve_*`).
An `Identifier` is a parsing of a variable name (or potentially other things
that look like names) and is generated by the parser. The
`TemplateTypeExtractor` helps finding the template parameters in an
`Identifier`.