summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/assert/desugar-visitor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/src/assert/desugar-visitor.cc')
-rw-r--r--tiger-compiler/src/assert/desugar-visitor.cc33
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