diff --git a/src/analysis/scoping_analysis.cpp b/src/analysis/scoping_analysis.cpp index 5fe6d123e..d70dd3c21 100644 --- a/src/analysis/scoping_analysis.cpp +++ b/src/analysis/scoping_analysis.cpp @@ -108,10 +108,6 @@ static InternedString mangleName(InternedString id, llvm::StringRef private_name return rtn; } -static bool isCompilerCreatedName(llvm::StringRef name) { - return name[0] == '!' || name[0] == '#'; -} - class ModuleScopeInfo : public ScopeInfo { public: ScopeInfo* getParent() override { return NULL; } @@ -121,7 +117,7 @@ class ModuleScopeInfo : public ScopeInfo { bool passesThroughClosure() override { return false; } VarScopeType getScopeTypeOfName(InternedString name) override { - if (isCompilerCreatedName(name)) + if (name.isCompilerCreatedName()) return VarScopeType::FAST; else return VarScopeType::GLOBAL; @@ -185,7 +181,7 @@ class EvalExprScopeInfo : public ScopeInfo { bool passesThroughClosure() override { return false; } VarScopeType getScopeTypeOfName(InternedString name) override { - if (isCompilerCreatedName(name)) + if (name.isCompilerCreatedName()) return VarScopeType::FAST; else if (forced_globals.find(name) != forced_globals.end()) return VarScopeType::GLOBAL; @@ -341,7 +337,7 @@ class ScopeInfoBase : public ScopeInfo { bool passesThroughClosure() override { return usage->passthrough_accesses.size() > 0 && !createsClosure(); } VarScopeType getScopeTypeOfName(InternedString name) override { - if (isCompilerCreatedName(name)) + if (name.isCompilerCreatedName()) return VarScopeType::FAST; if (usage->forced_globals.count(name) > 0) diff --git a/src/core/stringpool.cpp b/src/core/stringpool.cpp index 997c4f262..2642afce6 100644 --- a/src/core/stringpool.cpp +++ b/src/core/stringpool.cpp @@ -36,4 +36,10 @@ llvm::StringRef InternedString::s() const { const char* InternedString::c_str() const { return _str->c_str(); } + +bool InternedString::isCompilerCreatedName() const { + char c = _str->s()[0]; + return c == '!' || c == '#'; +} + } diff --git a/src/core/stringpool.h b/src/core/stringpool.h index 3a2caac57..b7358930b 100644 --- a/src/core/stringpool.h +++ b/src/core/stringpool.h @@ -82,6 +82,8 @@ class InternedString { operator llvm::StringRef() const { return s(); } operator BoxedString*() const { return getBox(); } + bool isCompilerCreatedName() const; + friend class InternedStringPool; friend struct std::hash; friend struct std::less;