29 std::unordered_map<std::string, std::string> identMap;
30 std::string rename(
const std::string& name) {
31 auto it = identMap.find(name);
32 if (it != identMap.end()) {
35 std::string canonicalName =
"i" + std::to_string(identMap.size());
36 identMap[name] = canonicalName;
41 if (node->kind() == TK_IDENT) {
44 if (node->kind() == TK_APPLY) {
46 <<
"canonicalize is only valid on trees after Sema has been run "
47 <<
"but it encountered a TK_APPLY node, which Sema removes";
49 return node->map([&](
TreeRef ref) {
return apply(ref); });
54 return ctx.apply(tree);
Definition: tree_views.h:109
TreeRef canonicalize(TreeRef tree)
Definition: canonicalize.h:27
static TreeRef create(const SourceRange &range, const std::string &name)
Definition: tree_views.h:127
Definition: error_report.h:22
std::shared_ptr< Tree > TreeRef
Definition: tree.h:44