From 6127f227880af506d806179ac622aba44c35fd4b Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Thu, 20 Aug 2020 20:15:08 -0400 Subject: Module name scope support --- frontends/ast/simplify.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'frontends') diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 7f9795d29..19dd5af10 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1597,6 +1597,13 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, if (type == AST_IDENTIFIER) { if (current_scope.count(str) == 0) { AstNode *current_scope_ast = (current_ast_mod == nullptr) ? current_ast : current_ast_mod; + const std::string& mod_scope = current_scope_ast->str; + if (str[0] == '\\' && str.substr(0, mod_scope.size()) == mod_scope) { + std::string new_str = "\\" + str.substr(mod_scope.size() + 1); + if (current_scope.count(new_str)) { + str = new_str; + } + } for (auto node : current_scope_ast->children) { //log("looking at mod scope child %s\n", type2str(node->type).c_str()); switch (node->type) { -- cgit v1.2.3