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


C++ CBotStack类代码示例

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


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

示例1: RestoreState

void CBotIf :: RestoreState(CBotStack* &pj, BOOL bMain)
{
	if ( !bMain ) return;

	CBotStack* pile = pj->RestoreStack(this);		// ajoute un élément à la pile
	if ( pile == NULL ) return;

	// selon la reprise, on peut être dans l'un des 2 états
	if( pile->GivState() == 0 )
	{
		// évalue la condition
		m_Condition->RestoreState(pile, bMain);	// interrompu ici !
		return;
	}
	
	// second état, évalue les instructions associées
	// le résultat de la condition est sur la pile

	if ( pile->GivVal() == TRUE )							// condition était vraie ?
	{
		if ( m_Block != NULL )								// bloc peut être absent
			 m_Block->RestoreState(pile, bMain);			// interrompu ici !
	}
	else
	{
		if ( m_BlockElse != NULL )							// s'il existe un bloc alternatif
			 m_BlockElse->RestoreState(pile, bMain);		// interrompu ici !
	}
}
开发者ID:Programerus,项目名称:colobot,代码行数:29,代码来源:CBotIf.cpp

示例2: RestoreState

void CBotListExpression::RestoreState(CBotStack* &pj, bool bMain)
{
    CBotStack*  pile = pj;
    int     state = 0x7000;

    if ( bMain )
    {
        pile = pj->RestoreStack();
        if ( pile == nullptr ) return;
        state = pile->GetState();
    }

    CBotInstr*  p = m_Expr;                                     // the first expression

    while (p != nullptr && state-->0)
    {
        p->RestoreState(pile, false);
        p = p->GetNext();                           // returns to the interrupted operation
    }

    if ( p != nullptr )
    {
        p->RestoreState(pile, bMain);
    }
}
开发者ID:BTML,项目名称:colobot,代码行数:25,代码来源:CBotWhile.cpp

示例3: RestoreState

void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
{
    if ( !bMain ) return;

    CBotStack* pile = pj->RestoreStack(this);       // adds an item to the stack
    if ( pile == nullptr ) return;

    // according to recovery, it may be in one of two states
    if( pile->GetState() == 0 )
    {
        // evaluates the condition
        m_condition->RestoreState(pile, bMain); // interrupted here!
        return;
    }

    // second state, evaluates the associated instructions
    // the result of the condition is on the stack

    if ( pile->GetVal() == true )                           // condition was true?
    {
        if (m_block != nullptr )                              // block may be absent
             m_block->RestoreState(pile, bMain);            // interrupted here!
    }
    else
    {
        if (m_blockElse != nullptr )                          // if there is an alternate block
             m_blockElse->RestoreState(pile, bMain);        // interrupted here!
    }
}
开发者ID:2asoft,项目名称:colobot,代码行数:29,代码来源:CBotIf.cpp

示例4: Execute

bool CBotExprLitNum::Execute(CBotStack* &pj)
{
    CBotStack*    pile = pj->AddStack(this);

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

    CBotVar*    var = CBotVar::Create("", m_numtype);

    std::string    nombre ;
    if (m_token.GetType() == TokenTypDef)
    {
        nombre = m_token.GetString();
    }

    switch (m_numtype)
    {
    case CBotTypShort:
    case CBotTypInt:
        var->SetValInt(m_valint, nombre);
        break;
    case CBotTypFloat:
        var->SetValFloat(m_valfloat);
        break;
    default:
        assert(false);
    }
    pile->SetVar(var);                            // place on the stack

    return pj->Return(pile);                        // it's ok
}
开发者ID:2asoft,项目名称:colobot,代码行数:30,代码来源:CBotExprLitNum.cpp

示例5: RestoreState

void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
{
    if ( !bMain ) return;

    CBotStack*  pile  = pj->RestoreStack(this);
    if ( pile == NULL ) return;

//    CBotStack*  pile1 = pile;

    int         i = 0;
    CBotVar*    ppVars[1000];
    CBotInstr*  p = m_Parameters;
    // evaluate parameters
    // and place the values on the stack
    // for allow of interruption at any time
    if ( p != NULL) while ( true )
    {
        pile = pile->RestoreStack();                        // place on the stack for the results
        if ( pile == NULL ) return;
        if ( pile->GetState() == 0 )
        {
            p->RestoreState(pile, bMain);                   // interrupt here!
            return;
        }
        ppVars[i++] = pile->GetVar();               // constructs the list of parameters
        p = p->GetNext();
        if ( p == NULL) break;
    }
    ppVars[i] = NULL;

    CBotStack* pile2 = pile->RestoreStack();
    if ( pile2 == NULL ) return;

    pile2->RestoreCall(m_nFuncIdent, GetToken(), ppVars);
}
开发者ID:PaweX,项目名称:colobot,代码行数:35,代码来源:CBotFunction.cpp

示例6: Execute

bool CBotBreak :: Execute(CBotStack* &pj)
{
    CBotStack* pile = pj->AddStack(this);
//  if ( pile == EOX ) return true;

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

    pile->SetBreak(m_token.GetType()==ID_BREAK ? 1 : 2, m_label);
    return pj->Return(pile);
}
开发者ID:BTML,项目名称:colobot,代码行数:10,代码来源:CBotWhile.cpp

示例7: RestoreState

void CBotExprRetVar::RestoreState(CBotStack* &pj, bool bMain)
{
    if (!bMain) return;

    CBotStack* pile = pj->RestoreStack();
    if ( pile == nullptr ) return;

    if (pile->GetState() == 0)
        m_next3->RestoreStateVar(pile, bMain);
}
开发者ID:2asoft,项目名称:colobot,代码行数:10,代码来源:CBotExprRetVar.cpp

示例8: Execute

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

示例9: RestoreState

void CBotListArray::RestoreState(CBotStack* &pj, bool bMain)
{
    if (bMain)
    {
        CBotStack*    pile  = pj->RestoreStack(this);
        if (pile == nullptr) return;

        CBotInstr* p = m_expr;

        int    state = pile->GetState();

        while(state-- > 0) p = p->GetNext3b() ;

        p->RestoreState(pile, bMain);                    // size calculation //interrupted!
    }
}
开发者ID:CHmSID,项目名称:colobot,代码行数:16,代码来源:CBotListArray.cpp

示例10: RestoreState

void CBotListInstr::RestoreState(CBotStack* &pj, bool bMain)
{
    if (!bMain) return;

    CBotStack*    pile = pj->RestoreStack(this);
    if (pile == nullptr) return;

    CBotInstr*    p = m_instr;                                    // the first expression

    int        state = pile->GetState();
    while ( p != nullptr && state-- > 0)
    {
        p->RestoreState(pile, false);
        p = p->GetNext();                            // returns to the interrupted operation
    }

    if (p != nullptr) p->RestoreState(pile, true);
}
开发者ID:melex750,项目名称:colobot,代码行数:18,代码来源:CBotListInstr.cpp

示例11: Execute

bool CBotInstrCall::Execute(CBotStack* &pj)
{
    CBotVar*    ppVars[1000];
    CBotStack*  pile  = pj->AddStack(this);
    if ( pile->StackOver() ) return pj->Return( pile );

    CBotStack* pile3 = nullptr;
    if (m_exprRetVar != nullptr) // func().member
    {
        pile3 = pile->AddStack2();
        if (pile3->GetState() == 1) // function call is done?
        {
            if (!m_exprRetVar->Execute(pile3)) return false;
            return pj->Return(pile3);
        }
    }

//    CBotStack*  pile1 = pile;

    int     i = 0;

    CBotInstr*  p = m_parameters;
    // evaluates parameters
    // and places the values ​​on the stack
    // for allow of interruption at any time
    if ( p != nullptr) while ( true )
    {
        pile = pile->AddStack();                        // place on the stack for the results
        if ( pile->GetState() == 0 )
        {
            if (!p->Execute(pile)) return false;        // interrupted here?
            pile->SetState(1);                          // set state to remember that parameters were executed
        }
        ppVars[i++] = pile->GetVar();
        p = p->GetNext();
        if ( p == nullptr) break;
    }
    ppVars[i] = nullptr;

    CBotStack* pile2 = pile->AddStack();
    if ( pile2->IfStep() ) return false;

    if ( !pile2->ExecuteCall(m_nFuncIdent, GetToken(), ppVars, m_typRes)) return false; // interrupt

    if (m_exprRetVar != nullptr) // func().member
    {
        pile3->SetCopyVar( pile2->GetVar() ); // copy the result
        pile2->SetVar(nullptr);
        pile3->SetState(1);      // set call is done
        return false;            // go back to the top ^^^
    }

    return pj->Return(pile2);   // release the entire stack
}
开发者ID:2asoft,项目名称:colobot,代码行数:54,代码来源:CBotInstrCall.cpp

示例12: RestoreState

void CBotWhile::RestoreState(CBotStack* &pj, bool bMain)
{
    if ( !bMain ) return;
    CBotStack* pile = pj->RestoreStack(this);   // adds an item to the stack
    if ( pile == nullptr ) return;

    switch( pile->GetState() )
    {                                           // there are two possible states (depending on recovery)
    case 0:
        // evaluates the condition
        m_condition->RestoreState(pile, bMain);
        return;

    case 1:
        // evaluates the associated statement block
        if (m_block != nullptr ) m_block->RestoreState(pile, bMain);
        return;
    }
}
开发者ID:2asoft,项目名称:colobot,代码行数:19,代码来源:CBotWhile.cpp

示例13: Execute

bool CBotWhile::Execute(CBotStack* &pj)
{
    CBotStack* pile = pj->AddStack(this);   // adds an item to the stack
                                            // or find in case of recovery
//  if ( pile == EOX ) return true;

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

    while( true ) switch( pile->GetState() )    // executes the loop
    {                                           // there are two possible states (depending on recovery)
    case 0:
        // evaluates the condition
        if ( !m_condition->Execute(pile) ) return false; // interrupted here?

        // the result of the condition is on the stack

        // terminates if an error or if the condition is false
        if ( !pile->IsOk() || pile->GetVal() != true )
        {
            return pj->Return(pile);                    // sends the results and releases the stack
        }

        // the condition is true, pass in the second mode

        if (!pile->SetState(1)) return false;           // ready for further

    case 1:
        // evaluates the associated statement block
        if (m_block != nullptr &&
            !m_block->Execute(pile) )
        {
            if (pile->IfContinue(0, m_label)) continue; // if continued, will return to test
            return pj->BreakReturn(pile, m_label);      // sends the results and releases the stack
        }

        // terminates if there is an error
        if ( !pile->IsOk() )
        {
            return pj->Return(pile);                    // sends the results and releases the stack
        }

        // returns to the test again
        if (!pile->SetState(0, 0)) return false;
        continue;
    }
}
开发者ID:2asoft,项目名称:colobot,代码行数:46,代码来源:CBotWhile.cpp

示例14: Execute

bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array)
{
    CBotStack*    pile = pj->AddStack();

    CBotVar*     var1 = nullptr;
    CBotVar*     var2 = nullptr;
    // fetch a variable (not copy)
    if (!ExecuteVar(var1, array, nullptr, false)) return false;

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

    if (var1)
    {
        var2 = pj->GetVar();    // result on the input stack
        if (var2)
        {
            CBotTypResult t1 = var1->GetTypResult();
            CBotTypResult t2 = var2->GetTypResult();
            if (t2.Eq(CBotTypPointer))
            {
                CBotClass*    c1 = t1.GetClass();
                CBotClass*    c2 = var2->GetClass();
                if ( !c2->IsChildOf(c1))
                {
                    CBotToken* pt = &m_token;
                    pile->SetError(CBotErrBadType1, pt);
                    return pj->Return(pile);    // operation performed
                }
                var1->SetVal(var2);     // set pointer
                var1->SetType(t1);      // keep pointer type
            }
            else
                var1->SetVal(var2);     // do assignment
        }
        pile->SetCopyVar(var1);     // replace the stack with the copy of the variable
                                    // (for name)
    }

    return pj->Return(pile);    // operation performed
}
开发者ID:2asoft,项目名称:colobot,代码行数:40,代码来源:CBotLeftExpr.cpp

示例15: FindLocalOrPublic

void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotStack* pStack, CBotClass* pClass)
{
    CBotTypResult   type;
    CBotFunction*   pt = FindLocalOrPublic(nIdent, name, ppVars, type);

    if ( pt != NULL )
    {
        CBotStack*  pStk = pStack->RestoreStack(pt);
        if ( pStk == NULL ) return;
        pStk->SetBotCall(pt->m_pProg);                  // it may have changed module

        CBotVar*    pthis = pStk->FindVar("this");
        pthis->SetUniqNum(-2);

        CBotStack*  pStk3 = pStk->RestoreStack(NULL);   // to set parameters passed
        if ( pStk3 == NULL ) return;

        pt->m_Param->RestoreState(pStk3, true);                 // parameters

        if ( pStk->GetState() > 1 &&                        // latching is effective?
             pt->m_bSynchro )
            {
                CBotProgram* pProgBase = pStk->GetBotCall(true);
                pClass->Lock(pProgBase);                    // locks the class
            }

        // finally calls the found function

        pt->m_Block->RestoreState(pStk3, true);                 // interrupt !
    }
}
开发者ID:PaweX,项目名称:colobot,代码行数:31,代码来源:CBotFunction.cpp


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