minikconfig: add semantic analysis
commitf7082a9a7cb26bd6531d6cd25914e4fcc30ab0c3
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 23 Jan 2019 06:55:58 +0000 (23 14:55 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 7 Mar 2019 20:45:53 +0000 (7 21:45 +0100)
tree9f50de33e8aefbd24cac9011d651bf90177fcf77
parent53167f562693981dbc18fb0071df4667dabdf7b6
minikconfig: add semantic analysis

There are three parts in the semantic analysis:

1) evaluating expressions.  This is done as a simple visit
of the Expr nodes.

2) ordering clauses.  This is done by constructing a graph of variables.
There is an edge from X to Y if Y depends on X, if X selects Y, or if
X appears in a conditional selection of Y; in other words, if the value
of X can affect the value of Y.  Each clause has a "destination" variable
whose value can be affected by the clause, and clauses will be processed
according to a topological sorting of their destination variables.
Defaults are processed after all other clauses with the same destination.

3) deriving the value of the variables.  This is done by processing
the clauses in the topological order provided by the previous step.
A "depends on" clause will force a variable to False, a "select" clause
will force a variable to True, an assignment will force a variable
to its RHS.  A default will set a variable to its RHS if it has not
been set before.  Because all variables have a default, after visiting
all clauses all variables will have been set.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20190123065618.3520-25-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/minikconf.py