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/lib/misc/symbol.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tiger-compiler/lib/misc/symbol.cc (limited to 'tiger-compiler/lib/misc/symbol.cc') diff --git a/tiger-compiler/lib/misc/symbol.cc b/tiger-compiler/lib/misc/symbol.cc new file mode 100644 index 0000000..edd8c86 --- /dev/null +++ b/tiger-compiler/lib/misc/symbol.cc @@ -0,0 +1,32 @@ +/** + ** \file misc/symbol.cc + ** \brief Implementation of misc::symbol. + */ + +#include +#include + +#include + +namespace misc +{ + symbol::symbol(const std::string& s) + : unique(s) + {} + + symbol::symbol(const char* s) + : unique(std::string(s)) + {} + + symbol symbol::fresh() { return fresh("a"); } + + symbol symbol::fresh(const symbol& s) + { + /// Counter of unique symbols. + static unsigned counter_ = 0; + std::string str = s.get() + "_" + std::to_string(counter_); + ++counter_; + return symbol(str); + } + +} // namespace misc -- cgit v1.2.3