void CBotVar::SetInit(CBotVar::InitType initType) { m_binit = initType; if (initType == CBotVar::InitType::IS_POINTER ) m_binit = CBotVar::InitType::DEF; // cas spécial if ( m_type.Eq(CBotTypPointer) && initType == CBotVar::InitType::IS_POINTER ) { CBotVarClass* instance = GetPointer(); if ( instance == nullptr ) { instance = new CBotVarClass(CBotToken(), m_type); // instance->SetClass((static_cast<CBotVarPointer*>(this))->m_classes); SetPointer(instance); } instance->SetInit(CBotVar::InitType::DEF); } if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) ) { CBotVar* p = (static_cast<CBotVarClass*>(this))->m_pVar; while( p != nullptr ) { p->SetInit(initType); p->m_pMyThis = static_cast<CBotVarClass*>(this); p = p->GetNext(); } } }
void CBotVar::SetInit(int bInit) { m_binit = bInit; if ( bInit == 2 ) m_binit = IS_DEF; // cas spécial if ( m_type.Eq(CBotTypPointer) && bInit == 2 ) { CBotVarClass* instance = GetPointer(); if ( instance == NULL ) { instance = new CBotVarClass(NULL, m_type); // instance->SetClass((static_cast<CBotVarPointer*>(this))->m_pClass); SetPointer(instance); } instance->SetInit(1); } if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) ) { CBotVar* p = (static_cast<CBotVarClass*>(this))->m_pVar; while( p != NULL ) { p->SetInit( bInit ); p->m_pMyThis = static_cast<CBotVarClass*>(this); p = p->GetNext(); } } }
bool CBotVarPointer::Ne(CBotVar* left, CBotVar* right) { CBotVarClass* l = left->GetPointer(); CBotVarClass* r = right->GetPointer(); if ( l == r ) return false; if ( l == nullptr && r->GetUserPtr() == OBJECTDELETED ) return false; if ( r == nullptr && l->GetUserPtr() == OBJECTDELETED ) return false; return true; }