void CMachine::Clear() { ProcList::iterator it = m_ProcList.begin(); while( m_ProcList.end() != it ) { ProcStack *st = *it++; while( !st->empty() ) { delete st->top(); st->pop(); } delete st; } m_ProcList.clear(); }
//-----------------------------------------------------------------------------// // Processor 실행 // return value : -2 = NotRun // -1 = Success // 0 = Halt 0 Normal End // 1 = Halt 1 ScriptEnd // 2 = Halt 2 ScriptExit // 3 = New Execute Script //-----------------------------------------------------------------------------// int CMachine::Run() { if( m_ProcList.empty() ) return -2; ProcList::iterator it = m_ProcList.begin(); while( m_ProcList.end() != it ) { ProcStack *st = *it; //int result = st->top()->Run(); CProcessor *p = st->top(); int result = p->Run(); if( 0 <= result ) { // ScriptEnd, Normal End if( 0 == result || 1 == result ) { CProcessor *p = st->top(); st->pop(); delete p; if( st->empty() ) delete st; it = m_ProcList.erase( it ); } // ScriptExit else if( 2 == result ) { Clear(); } // New ExecuteScript else if( 3 == result ) { CProcessor *proc = st->top(); ExecuteScriptChild( st, proc->GetArgumentStr(0), proc->m_pCallFunc, NULL ); } } ++it; } return -1; }
void printLoop(ProcStack& path){ proc * p = path.top(); path.pop(); ProcStack loop; loop.push(p); while(path.top() != p){ loop.push(path.top()); path.pop(); } loop.push(p); cout << "loop:" << endl; while(!loop.empty()){ cout << " " << loop.top()->f << endl; loop.pop(); } }