Better CBot class destructor parsing (#257)
The previous one broke the NOT (~) operation parsing
This reverts commit 7c8a31c074
.
dev-time-step
parent
45a433525f
commit
c9e0249008
|
@ -616,8 +616,11 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
|
||||
while (pStack->IsOk())
|
||||
{
|
||||
CBotToken* pp = p;
|
||||
IsOfType(p, ID_NOT); // skips ~ eventual (destructor)
|
||||
std::string pp = p->GetString();
|
||||
if ( IsOfType(p, ID_NOT) )
|
||||
{
|
||||
pp = std::string("~") + p->GetString();
|
||||
}
|
||||
|
||||
if (IsOfType(p, TokenTypVar))
|
||||
{
|
||||
|
@ -670,12 +673,12 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
CBotFunction* prev = nullptr;
|
||||
while ( pf != nullptr )
|
||||
{
|
||||
if (pf->GetName() == pp->GetString()) break;
|
||||
if (pf->GetName() == pp) break;
|
||||
prev = pf;
|
||||
pf = pf->Next();
|
||||
}
|
||||
|
||||
bool bConstructor = (pp->GetString() == GetName());
|
||||
bool bConstructor = (pp == GetName());
|
||||
CBotCStack* pile = pStack->TokenStack(nullptr, true);
|
||||
|
||||
// make "this" known
|
||||
|
@ -760,7 +763,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
|
|||
|
||||
if ( !bSecond )
|
||||
{
|
||||
CBotVar* pv = CBotVar::Create(pp->GetString(), type);
|
||||
CBotVar* pv = CBotVar::Create(pp, type);
|
||||
pv -> SetStatic( bStatic );
|
||||
pv -> SetPrivate( mProtect );
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class CBotCStack;
|
|||
* classObject->AddItem("category", CBotTypResult(CBotTypInt), CBotVar::ProtectionType::ReadOnly);
|
||||
* classObject->AddItem("position", CBotTypResult(CBotTypClass, classPoint), CBotVar::ProtectionType::ReadOnly);
|
||||
* classObject->AddFunction("func", rFunc, cFunc); // TODO: Document function format for class methods (different from standard CBotProgram::AddFunction()!)
|
||||
*
|
||||
*
|
||||
* // This class can be used in CBot like so:
|
||||
* // object item = radar(Me);
|
||||
* // goto(item.position);
|
||||
|
|
|
@ -285,6 +285,13 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
|
|||
{
|
||||
CBotToken* pp = p;
|
||||
func->m_token = *p;
|
||||
|
||||
if ( IsOfType(p, ID_NOT) )
|
||||
{
|
||||
CBotToken d(std::string("~") + p->GetString());
|
||||
func->m_token = d;
|
||||
}
|
||||
|
||||
// un nom de fonction est-il là ?
|
||||
if (IsOfType(p, TokenTypVar))
|
||||
{
|
||||
|
|
|
@ -232,17 +232,6 @@ CBotToken* CBotToken::NextToken(char* &program, int& error, bool first)
|
|||
mot = c; // built the word
|
||||
c = *(program++); // next character
|
||||
|
||||
// special case for destructors
|
||||
if ( mot[0] == '~')
|
||||
{
|
||||
while (c != 0 && !CharInList(c, sep1))
|
||||
{
|
||||
mot += c;
|
||||
c = *(program++);
|
||||
}
|
||||
stop = true;
|
||||
}
|
||||
|
||||
// special case for strings
|
||||
if ( mot[0] == '\"' )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue