From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/assert/desugar-visitor.cc | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tiger-compiler/src/assert/desugar-visitor.cc (limited to 'tiger-compiler/src/assert/desugar-visitor.cc') 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 + +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 -- cgit v1.2.3