Commit 1a07ff88 authored by Marius Wachtler's avatar Marius Wachtler

make isCompilerCreatedName() a method of InternedString

parent b145b008
...@@ -108,10 +108,6 @@ static InternedString mangleName(InternedString id, llvm::StringRef private_name ...@@ -108,10 +108,6 @@ static InternedString mangleName(InternedString id, llvm::StringRef private_name
return rtn; return rtn;
} }
static bool isCompilerCreatedName(llvm::StringRef name) {
return name[0] == '!' || name[0] == '#';
}
class ModuleScopeInfo : public ScopeInfo { class ModuleScopeInfo : public ScopeInfo {
public: public:
ScopeInfo* getParent() override { return NULL; } ScopeInfo* getParent() override { return NULL; }
...@@ -121,7 +117,7 @@ public: ...@@ -121,7 +117,7 @@ public:
bool passesThroughClosure() override { return false; } bool passesThroughClosure() override { return false; }
VarScopeType getScopeTypeOfName(InternedString name) override { VarScopeType getScopeTypeOfName(InternedString name) override {
if (isCompilerCreatedName(name)) if (name.isCompilerCreatedName())
return VarScopeType::FAST; return VarScopeType::FAST;
else else
return VarScopeType::GLOBAL; return VarScopeType::GLOBAL;
...@@ -185,7 +181,7 @@ public: ...@@ -185,7 +181,7 @@ public:
bool passesThroughClosure() override { return false; } bool passesThroughClosure() override { return false; }
VarScopeType getScopeTypeOfName(InternedString name) override { VarScopeType getScopeTypeOfName(InternedString name) override {
if (isCompilerCreatedName(name)) if (name.isCompilerCreatedName())
return VarScopeType::FAST; return VarScopeType::FAST;
else if (forced_globals.find(name) != forced_globals.end()) else if (forced_globals.find(name) != forced_globals.end())
return VarScopeType::GLOBAL; return VarScopeType::GLOBAL;
...@@ -341,7 +337,7 @@ public: ...@@ -341,7 +337,7 @@ public:
bool passesThroughClosure() override { return usage->passthrough_accesses.size() > 0 && !createsClosure(); } bool passesThroughClosure() override { return usage->passthrough_accesses.size() > 0 && !createsClosure(); }
VarScopeType getScopeTypeOfName(InternedString name) override { VarScopeType getScopeTypeOfName(InternedString name) override {
if (isCompilerCreatedName(name)) if (name.isCompilerCreatedName())
return VarScopeType::FAST; return VarScopeType::FAST;
if (usage->forced_globals.count(name) > 0) if (usage->forced_globals.count(name) > 0)
......
...@@ -36,4 +36,10 @@ llvm::StringRef InternedString::s() const { ...@@ -36,4 +36,10 @@ llvm::StringRef InternedString::s() const {
const char* InternedString::c_str() const { const char* InternedString::c_str() const {
return _str->c_str(); return _str->c_str();
} }
bool InternedString::isCompilerCreatedName() const {
char c = _str->s()[0];
return c == '!' || c == '#';
}
} }
...@@ -82,6 +82,8 @@ public: ...@@ -82,6 +82,8 @@ public:
operator llvm::StringRef() const { return s(); } operator llvm::StringRef() const { return s(); }
operator BoxedString*() const { return getBox(); } operator BoxedString*() const { return getBox(); }
bool isCompilerCreatedName() const;
friend class InternedStringPool; friend class InternedStringPool;
friend struct std::hash<InternedString>; friend struct std::hash<InternedString>;
friend struct std::less<InternedString>; friend struct std::less<InternedString>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment