scripts/decodetree: Pass lvalue-formatter function to str_extract()
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 23 May 2023 12:04:44 +0000 (13:04 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 30 May 2023 17:55:39 +0000 (10:55 -0700)
commitaeac22ba1e91a40d1d831cb02a1935391e67c7e2
tree54450f1dd9fcca9971f111253cb1c7eec286c0df
parent7e62609353b88d9aeee9715b534588af351075af
scripts/decodetree: Pass lvalue-formatter function to str_extract()

To support referring to other named fields in field definitions, we
need to pass the str_extract() method a function which tells it how
to emit the code for a previously initialized named field.  (In
Pattern::output_code() the other field will be "u.f_foo.field", and
in Format::output_extract() it is "a->field".)

Refactor the two callsites that currently do "output code to
initialize each field", and have them pass a lambda that defines how
to format the lvalue in each case.  This is then used both in
emitting the LHS of the assignment and also passed down to
str_extract() as a new argument (unused at the moment, but will be
used in the following patch).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230523120447.728365-4-peter.maydell@linaro.org>
scripts/decodetree.py