Add InferredStatementContext
SubstatementContext implies definition in source, which adds state
which is not necessary. Introduce a separate class to hold statement
contexts which are created during inference.
In order to prevent code duplication, StmtContext methods whose
implementation is relevant only in RootStatementContext are refactored
to dispatch to specialized implementations, making them final in
the process. This also happens to improve inference speed, as lookups
like getBehaviourRegistry() used to iterate over parent axis to root,
now they are taking a direct shortcut to root (which may be 'this').
Since InferredStatementContext derives a number of methods from
its prototype (such as raw argument, etc.), these details are taken
out of StatementContextBase and moved to AbstractResumedStatement.
InferredStatementContext is about 10% smaller than an equivalent
SubstatementContext, leading to smaller inference memory footprint.
JIRA: YANGTOOLS-784
Change-Id: I62eea1dc92756536444676e8765fedd73375933e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
3880c99eefb4d8104236fdd17da6d5014f61f63e)