diff options
Diffstat (limited to 'tiger-compiler/src/assert/libassert.hh')
| -rw-r--r-- | tiger-compiler/src/assert/libassert.hh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tiger-compiler/src/assert/libassert.hh b/tiger-compiler/src/assert/libassert.hh new file mode 100644 index 0000000..aba01b1 --- /dev/null +++ b/tiger-compiler/src/assert/libassert.hh @@ -0,0 +1,79 @@ +/** + ** \file assert/libassert.hh + ** \brief Declare functions and variables exported by assert module. + */ + +#pragma once + +#include <ast/fwd.hh> +#include <misc/error.hh> + +namespace assert +{ + /*-------. + | Bind. | + `-------*/ + + /// \brief Bind the whole AST in place, return the error code + /// + /// \param last the ast you want to bind + /// + /// \return a misc::error that serve to indicate possible failure + misc::error bind(ast::Ast& last); + + /*----------------. + | Compute types. | + `----------------*/ + + /** \brief Check types allowing assertions. + + \param tree abstract syntax tree's root. + + \return success of the type-checking. */ + misc::error types_check(ast::Ast& tree); + + /*---------. + | Rename. | + `---------*/ + + /// \brief Rename the whole ast in place + /// + /// \param ast the ast you want to rename + /// + /// \return a misc::error that serve to indicate possible failure + misc::error rename(ast::Ast& ast); + + /*---------------------. + | Desugar assertions. | + `---------------------*/ + + /** \brief Remove assertions constructs from an AST. + + \param tree abstract syntax tree's root, whose bindings + and types have been computed, and whose + identifiers are all unique. + \param class_names the names of the class types of the AST + + \return the desugared, bound and type-checked AST. */ + template <typename A> + A* desugar(const A& tree, bool desugar_for_p, bool desugar_string_cmp_p); + + /** \brief Remove assertions constructs from an AST without recomputing + its bindings nor its types. + + This function acts like assertions::assertions_desugar, but stops just + after the desugaring step (in fact, assertions::desugar is built + upon this function). It is meant to be used as a test of + DesugarVisitor (i.e., even if the desugared tree is badly bound + or typed, it can still be pretty-printed). + + \param tree AST to desugar. + \param class_names the names of the class types of the AST + + \return the desugared AST. */ + template <typename A> + A* raw_desugar(const A& tree, bool desugar_for_p, bool desugar_string_cmp_p); + +} + +#include <assert/libassert.hxx> |
