diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/assert/desugar-visitor.cc | |
Diffstat (limited to 'tiger-compiler/src/assert/desugar-visitor.cc')
| -rw-r--r-- | tiger-compiler/src/assert/desugar-visitor.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tiger-compiler/src/assert/desugar-visitor.cc b/tiger-compiler/src/assert/desugar-visitor.cc new file mode 100644 index 0000000..5f18a07 --- /dev/null +++ b/tiger-compiler/src/assert/desugar-visitor.cc @@ -0,0 +1,33 @@ +/** + ** \file assert/desugar-visitor.cc + ** \brief Implementation of assert::DesugarVisitor. + */ + +#include <assert/desugar-visitor.hh> + +namespace assert +{ + + DesugarVisitor::DesugarVisitor(const bool desugar_for_p, + const bool desugar_string_cmp_p) + : super_type(desugar_for_p, desugar_string_cmp_p) + {} + + void DesugarVisitor::operator()(const ast::AssertExp& e) + { + // FIXME DONE: Some code was deleted here. (replace the AssertExp to a CallExp) + const ast::Location location = e.location_get(); + + const auto args = new ast::exps_type; + + const std::string condition_text = get_formatted_assert_cond(e); + const std::string filename = get_formatted_location(e.location_get()); + + args->push_back(recurse(e.cond_get())); + args->push_back(new ast::StringExp(location, condition_text)); + args->push_back(new ast::StringExp(location, filename)); + + result_ = new ast::CallExp(location, "assertion", args); + } + +} // namespace assert |
