1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Better handling of this/base for autocomplete, colorization, goto def

This commit is contained in:
Brian Fiete 2020-02-21 09:26:02 -08:00
parent b856f48006
commit 590df7aec7
6 changed files with 71 additions and 20 deletions

View file

@ -977,6 +977,27 @@ bool BfAstNode::Equals(const StringImpl& str)
return strncmp(str.GetPtr(), source->mSrc + mSrcStart, len) == 0;
}
bool BfAstNode::Equals(const char* str)
{
auto source = GetSourceData();
const char* ptrLhs = source->mSrc + mSrcStart;
const char* ptrLhsEnd = source->mSrc + mSrcEnd;
const char* ptrRhs = str;
while (true)
{
char cRhs = *(ptrRhs++);
if (cRhs == 0)
return ptrLhs == ptrLhsEnd;
if (ptrLhs == ptrLhsEnd)
return false;
char cLhs = *(ptrLhs++);
if (cLhs != cRhs)
return false;
}
}
//////////////////////////////////////////////////////////////////////////
void BfBlock::Init(const SizedArrayImpl<BfAstNode*>& vec, BfAstAllocator* alloc)