Skip to content

Commit

Permalink
make isCompilerCreatedName() a method of InternedString
Browse files Browse the repository at this point in the history
  • Loading branch information
undingen committed Nov 18, 2015
1 parent ca2384a commit b1d9ab9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/analysis/scoping_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/core/stringpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '#';
}

}
2 changes: 2 additions & 0 deletions src/core/stringpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<InternedString>;
friend struct std::less<InternedString>;
Expand Down

0 comments on commit b1d9ab9

Please sign in to comment.