当前位置: 首页>>代码示例>>C++>>正文


C++ CBotVar类代码示例

本文整理汇总了C++中CBotVar的典型用法代码示例。如果您正苦于以下问题:C++ CBotVar类的具体用法?C++ CBotVar怎么用?C++ CBotVar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CBotVar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindLocalOrPublic

void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars, CBotStack* pStack)
{
    CBotTypResult   type;
    CBotFunction*   pt = NULL;
    CBotStack*      pStk1;
    CBotStack*      pStk3;

    // search function to return the ok identifier

    pt = FindLocalOrPublic(nIdent, name, ppVars, type);

    if ( pt != NULL )
    {
        pStk1 = pStack->RestoreStack(pt);
        if ( pStk1 == NULL ) return;

        pStk1->SetBotCall(pt->m_pProg);                 // it may have changed module

        if ( pStk1->GetBlock() < 2 )
        {
            CBotStack* pStk2 = pStk1->RestoreStack(NULL); // used more
            if ( pStk2 == NULL ) return;
            pStk3 = pStk2->RestoreStack(NULL);
            if ( pStk3 == NULL ) return;
        }
        else
        {
            pStk3 = pStk1->RestoreStack(NULL);
            if ( pStk3 == NULL ) return;
        }

        // preparing parameters on the stack

        {
            if ( !pt->m_MasterClass.IsEmpty() )
            {
//                CBotVar* pInstance = m_pProg->m_pInstance;
                // make "this" known
                CBotVar* pThis = pStk1->FindVar("this");
                pThis->SetInit(2);
                pThis->SetUniqNum(-2);
            }
        }

        if ( pStk1->GetState() == 0 )
        {
            pt->m_Param->RestoreState(pStk3, true);
            return;
        }

        // initializes the variables as parameters
        pt->m_Param->RestoreState(pStk3, false);
        pt->m_Block->RestoreState(pStk3, true);
    }
}
开发者ID:PaweX,项目名称:colobot,代码行数:55,代码来源:CBotFunction.cpp

示例2: GetItemRef

CBotVar* CBotClass::GetItemRef(int nIdent)
{
    CBotVar*    p = m_pVar;

    while ( p != NULL )
    {
        if ( p->GetUniqNum() == nIdent ) return p;
        p = p->GetNext();
    }
    if ( m_pParent != NULL ) return m_pParent->GetItemRef(nIdent);
    return NULL;
}
开发者ID:DanielVartanov,项目名称:colobot,代码行数:12,代码来源:CBotClass.cpp

示例3: GetItem

CBotVar* CBotClass::GetItem(const char* name)
{
    CBotVar*    p = m_pVar;

    while ( p != NULL )
    {
        if ( p->GetName() == name ) return p;
        p = p->GetNext();
    }
    if ( m_pParent != NULL ) return m_pParent->GetItem(name);
    return NULL;
}
开发者ID:DanielVartanov,项目名称:colobot,代码行数:12,代码来源:CBotClass.cpp

示例4: TestCatch

bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
{
    if ( !m_Cond->Execute(pile) ) return false;

    if ( val > 0 || pile->GetType() != CBotTypBoolean )
    {
        CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean);
        var->SetValInt( pile->GetVal() == val );
        pile->SetVar(var);                          // calls on the stack
    }

    return true;
}
开发者ID:BTML,项目名称:colobot,代码行数:13,代码来源:CBotWhile.cpp

示例5: while

void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
{
//    int             i = 0;
    CBotDefParam*   p = this;

    while ( p != NULL )
    {
        // creates a local variable on the stack
        CBotVar*    var = pj->FindVar(p->m_token.GetString());
        var->SetUniqNum(p->m_nIdent);
        p = p->m_next;
    }
}
开发者ID:PaweX,项目名称:colobot,代码行数:13,代码来源:CBotFunction.cpp

示例6: CBotTypResult

bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
{
    CBotStack*  pile = pj->AddStack(this, 2);               // one end of stack local to this function
//  if ( pile == EOX ) return true;

    pile->SetBotCall(m_pProg);                              // bases for routines

    if ( pile->GetState() == 0 )
    {
        if ( !m_Param->Execute(ppVars, pile) ) return false;    // define parameters
        pile->IncState();
    }

    if ( pile->GetState() == 1 && !m_MasterClass.IsEmpty() )
    {
        // makes "this" known
        CBotVar* pThis ;
        if ( pInstance == NULL )
        {
            pThis = CBotVar::Create("this", CBotTypResult( CBotTypClass, m_MasterClass ));
            pThis->SetInit(2);
        }
        else
        {
            pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, m_MasterClass ));
            pThis->SetPointer(pInstance);
            pThis->SetInit(2);
        }

//      pThis->SetUniqNum(m_nThisIdent);
        pThis->SetUniqNum(-2);
        pile->AddVar(pThis);

        pile->IncState();
    }

    if ( pile->IfStep() ) return false;

    if ( !m_Block->Execute(pile) )
    {
        if ( pile->GetError() < 0 )
            pile->SetError( 0 );
        else
            return false;
    }

    return pj->Return(pile);
}
开发者ID:PaweX,项目名称:colobot,代码行数:48,代码来源:CBotFunction.cpp

示例7: rSpace

BOOL rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
{
    CBotVar*    pSub;
    float       rMin, rMax, dist;

    rMin =  5.0f*UNIT;
    rMax = 50.0f*UNIT;
    dist =  4.0f*UNIT;

    if ( var == 0 )
    {
//      center = pThis->RetPosition(0);
    }
    else
    {
        if ( var != 0 )
        {
            rMin = var->GivValFloat()*UNIT;
            var = var->GivNext();

            if ( var != 0 )
            {
                rMax = var->GivValFloat()*UNIT;
                var = var->GivNext();

                if ( var != 0 )
                {
                    dist = var->GivValFloat()*UNIT;
                    var = var->GivNext();
                }
            }
        }
    }

    if ( result != 0 )
    {
        pSub = result->GivItemList();
        if ( pSub != 0 )
        {
            pSub->SetValFloat(1);
            pSub = pSub->GivNext();  // "y"
            pSub->SetValFloat(2);
            pSub = pSub->GivNext();  // "z"
//          pSub->SetValFloat(3);
        }
    }
    return TRUE;
}
开发者ID:Zaba999,项目名称:colobot,代码行数:48,代码来源:TestCBotDoc.cpp

示例8: roRadar

BOOL roRadar( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
    pResult->SetPointer( NULL );
    compt+=45671;
    if (compt&0x11) return TRUE;

    CBotVar* pAutre = CBotVar::Create("autre", CBotTypResult( CBotTypClass, "object" ));
    pAutre->SetUserPtr( (void*)2 );
    pResult->SetPointer( pAutre );

    if (!pResult->IsElemOfClass("object"))
        return TRUE;

    delete pAutre;
    return TRUE;
}
开发者ID:Zaba999,项目名称:colobot,代码行数:16,代码来源:TestCBotDoc.cpp

示例9: GetValString

void CBotVar::debug()
{
//    const char*    p = static_cast<const char*>( m_token->GetString());
    CBotString  s = static_cast<const char*>( GetValString());
//    const char* v = static_cast<const char*> (s);

    if ( m_type.Eq(CBotTypClass) )
    {
        CBotVar*    pv = (static_cast<CBotVarClass*>(this))->m_pVar;
        while (pv != NULL)
        {
            pv->debug();
            pv = pv->GetNext();
        }
    }
}
开发者ID:colobotLeaner,项目名称:colobot,代码行数:16,代码来源:CBotVar.cpp

示例10: rCPoint

// exécution
BOOL	rCPoint( CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception )
{
	CString		s;

	if ( pVar == NULL )return TRUE;			// constructeur sans paramètres est ok

	CBotVar*	pX = pThis->GivItem("x");
	pX->SetValFloat( pVar->GivValFloat() );
	pVar	= pVar->GivNext();

	CBotVar*	pY = pThis->GivItem("y");
	pY->SetValFloat( pVar->GivValFloat() );
	pVar	= pVar->GivNext();

	return	TRUE;			// pas d'interruption
}
开发者ID:PaweX,项目名称:colobot,代码行数:17,代码来源:Routines.cpp

示例11: CBotVar

bool CBotAddExpr::Execute(CBotStack* &pStack)
{
    CBotStack* pStk1 = pStack->AddStack(this);  // adds an item to the stack
                                                // or is found in case of recovery
//  if ( pSk1 == EOX ) return TRUE;


    // according to recovery, it may be in one of two states

    if ( pStk1->GetState() == 0 &&              // first state, evaluates the left operand
        !m_leftop->Execute(pStk1) ) return FALSE; // interrupted here?

    // passes to the next step
    pStk1->SetState(1);                         // ready for further

    // requires a little more stack to not touch the result of the left
    // which is on the stack, precisely.

    CBotStack* pStk2 = pStk1->AddStack();       // adds an item to the stack
                                                // or is found in case of recovery

    // Second state, evaluates the right operand
    if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrupted here?

    int     type1 = pStk1->GetType();           // what kind of results?
    int     type2 = pStk2->GetType();

    // creates a temporary variable to put the result
    CBotVar*    result = new CBotVar( nullptr, MAX(type1, type2));

    // is the operation as requested
    switch (GetTokenType())
    {
    case ID_ADD:
        result->Add(pStk1->GetVar(), pStk2->GetVar());      // addition
        break;
    case ID_SUB:
        result->Sub(pStk1->GetVar(), pStk2->GetVar());      // subtraction
        break;
    }
    pStk2->SetVar(result);                      // puts the result on the stack

    pStk1->Return(pStk2);                       // frees the stack
    return pStack->Return(pStk1);               // transmits the result
}
开发者ID:BTML,项目名称:colobot,代码行数:45,代码来源:CBotAddExpr.cpp

示例12: CBotVar

BOOL CBotAddExpr::Execute(CBotStack* &pStack)
{
    CBotStack* pStk1 = pStack->AddStack(this);  // ajoute un élément à la pile
                                                // ou le retrouve en cas de reprise
//  if ( pSk1 == EOX ) return TRUE;


    // selon la reprise, on peut être dans l'un des 2 états

    if ( pStk1->GetState() == 0 &&              // 1er état, évalue l'opérande de gauche
        !m_leftop->Execute(pStk1) ) return FALSE; // interrompu ici ?

    // passe à l'étape suivante
    pStk1->SetState(1);                         // prêt pour la suite

    // demande un peu plus de stack pour ne pas toucher le résultat de gauche
    // qui se trouve sur la pile, justement.

    CBotStack* pStk2 = pStk1->AddStack();       // ajoute un élément à la pile
                                                // ou le retrouve en cas de reprise

    // 2e état, évalue l'opérande de droite
    if ( !m_rightop->Execute(pStk2) ) return FALSE; // interrompu ici ?

    int     type1 = pStk1->GetType();           // de quels types les résultats ?
    int     type2 = pStk2->GetType();

    // crée une variable temporaire pour y mettre le résultat
    CBotVar*    result = new CBotVar( NULL, MAX(type1, type2));

    // fait l'opération selon la demande
    switch (GetTokenType())
    {
    case ID_ADD:
        result->Add(pStk1->GetVar(), pStk2->GetVar());      // additionne
        break;
    case ID_SUB:
        result->Sub(pStk1->GetVar(), pStk2->GetVar());      // soustrait
        break;
    }
    pStk2->SetVar(result);                      // met le résultat sur la pile

    pStk1->Return(pStk2);                       // libère la pile
    return pStack->Return(pStk1);               // transmet le résultat
}
开发者ID:Zaba999,项目名称:colobot,代码行数:45,代码来源:CBotAddExpr.cpp

示例13: while

CBotVar* CBotStack::FindVar(const char* name)
{
    CBotStack*    p = this;
    while (p != NULL)
    {
        CBotVar*    pp = p->m_listVar;
        while ( pp != NULL)
        {
            if (pp->GetName() == name)
            {
                return pp;
            }
            pp = pp->m_next;
        }
        p = p->m_prev;
    }
    return NULL;
}
开发者ID:PaweX,项目名称:colobot,代码行数:18,代码来源:CBotStack.cpp

示例14: token

CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass)
{
    CBotToken    token( name, "" );
    CBotVar*    pVar = Create( &token, type );

    if ( type == CBotTypPointer && pClass == NULL )        // pointer "null" ?
        return pVar;

    if ( type == CBotTypClass || type == CBotTypPointer ||
         type == CBotTypIntrinsic )
    {
        if (pClass == NULL)
        {
            delete pVar;
            return NULL;
        }
        pVar->SetClass( pClass );
    }
    return pVar;
}
开发者ID:colobotLeaner,项目名称:colobot,代码行数:20,代码来源:CBotVar.cpp

示例15: token

CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pClass)
{
    CBotToken    token( name, "" );
    CBotVar*    pVar = Create( token, type );

    if ( type == CBotTypPointer && pClass == nullptr )        // pointer "null" ?
        return pVar;

    if ( type == CBotTypClass || type == CBotTypPointer ||
         type == CBotTypIntrinsic )
    {
        if (pClass == nullptr)
        {
            delete pVar;
            return nullptr;
        }
        pVar->SetClass( pClass );
    }
    return pVar;
}
开发者ID:Grunaka,项目名称:colobot,代码行数:20,代码来源:CBotVar.cpp


注:本文中的CBotVar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。