Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- Documentation/api.rst | 10 ++++++++++ evaluate.h | 15 +++++++++++++++ expression.h | 18 ++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Documentation/api.rst b/Documentation/api.rst index 8b6f04011..d1a1d3ca4 100644 --- a/Documentation/api.rst +++ b/Documentation/api.rst @@ -9,3 +9,13 @@ Utilities ~~~~~~~~~ .. c:autodoc:: ptrlist.c + +Parsing +~~~~~~~ + +.. c:autodoc:: expression.h + +Typing +~~~~~~ + +.. c:autodoc:: evaluate.h diff --git a/evaluate.h b/evaluate.h index 36de7d696..f68f7fb7c 100644 --- a/evaluate.h +++ b/evaluate.h @@ -6,8 +6,23 @@ struct statement; struct symbol; struct symbol_list; +/// +// evaluate the type of an expression +// @expr: the expression to be evaluated +// @return: the type of the expression or ``NULL`` +// if the expression can't be evaluated struct symbol *evaluate_expression(struct expression *expr); + +/// +// evaluate the type of a statement +// @stmt: the statement to be evaluated +// @return: the type of the statement or ``NULL`` +// if it can't be evaluated struct symbol *evaluate_statement(struct statement *stmt); + +/// +// evaluate the type of a set of symbols +// @list: the list of the symbol to be evaluated void evaluate_symbol_list(struct symbol_list *list); #endif diff --git a/expression.h b/expression.h index b5fa9bc14..ba4157fda 100644 --- a/expression.h +++ b/expression.h @@ -243,9 +243,23 @@ struct expression { }; }; -/* Constant expression values */ -int is_zero_constant(struct expression *); +/// +// Constant expression values +// -------------------------- + +/// +// test if an expression evaluates to the constant ``0``. +// @return: ``1`` if @expr evaluate to ``0``, +// ``0`` otherwise. +int is_zero_constant(struct expression *expr); + +/// +// test the compile time truth value of an expression +// @return: +// * ``-1`` if @expr is not constant, +// * ``0`` or ``1`` depending on the truth value of @expr. int expr_truth_value(struct expression *expr); + long long get_expression_value(struct expression *); long long const_expression_value(struct expression *); long long get_expression_value_silent(struct expression *expr); -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html