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/overload/over-table.hxx | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tiger-compiler/src/overload/over-table.hxx (limited to 'tiger-compiler/src/overload/over-table.hxx') diff --git a/tiger-compiler/src/overload/over-table.hxx b/tiger-compiler/src/overload/over-table.hxx new file mode 100644 index 0000000..de8f98b --- /dev/null +++ b/tiger-compiler/src/overload/over-table.hxx @@ -0,0 +1,64 @@ +/** + ** \file overload/over-table.hxx + ** \brief Inline methods and template implementations for overload/over-table.hh. + */ + +#pragma once + +#include +#include + +#include + +namespace overload +{ + template OverTable::OverTable() + { + oversymtab_.emplace_back(); + } + + template void OverTable::put(misc::symbol key, T& value) + { + oversymtab_.back().emplace(key, &value); + } + + template + typename OverTable::range_type OverTable::get(misc::symbol key) + { + precondition(!oversymtab_.empty()); + auto& map = oversymtab_.back(); + return map.equal_range(key); + } + + template void OverTable::scope_begin() + { + oversymtab_.emplace_back(oversymtab_.back()); + } + + template void OverTable::scope_end() + { + precondition(!oversymtab_.empty()); + oversymtab_.pop_back(); + } + + template + std::ostream& OverTable::dump(std::ostream& ostr) const + { + ostr << "\n"; + for (const auto& m : oversymtab_ | std::views::reverse) + { + ostr << "\n"; + for (const auto& im : m) + ostr << im.first << " : " << im->second.size() << '\n'; + ostr << "\n"; + } + return ostr << "\n"; + } + + template + std::ostream& operator<<(std::ostream& ostr, const OverTable& tbl) + { + return tbl.dump(ostr); + } + +} // namespace overload -- cgit v1.2.3