Esempio n. 1
0
void Vm::startsWith(const byte* const beg, const byte* const end, const uint64_t startOffset, HitCallback hitFn, void* userData) {
  CurHitFn = hitFn;
  UserData = userData;
  const Instruction* base = &(*Prog)[0];
  uint64_t offset = startOffset;

  if (Prog->First[*beg]) {
    for (ThreadList::const_iterator t(First.begin()); t != First.end(); ++t) {
      Active.emplace_back(
      #ifdef _MSC_VER
        Thread(t->PC, Thread::NOLABEL, offset, Thread::NONE)
      #else
        t->PC, Thread::NOLABEL, offset, Thread::NONE
      #endif
      );
    }

    for (const byte* cur = beg; cur < end; ++cur, ++offset) {
      for (ThreadList::iterator t(Active.begin()); t != Active.end(); ++t) {
        _executeThread(base, t, cur, offset);
      }

      _cleanup();

      if (Active.empty()) {
        // early exit if threads die out
        break;
      }
    }
  }

  closeOut(hitFn, userData);
  reset();
}
Esempio n. 2
0
File: Project3.c Progetto: domen1c/c
int main ( void )
{
    // declare and initialize local array
    char color[MAX_ELEMENTS] = { 'M', 'R', 'O', 'Y', 'L', 'G', 'T', 'B', 'N', 'P', 'K' };
    int today[MAX_ELEMENTS] = { 130, 120, 115, 105, 93, 83, 77, 70, 65, 60, 50 };
    int group[MAX_ELEMENTS] = { 125, 115, 95, 90, 75, 70, 65, 60, 55, 50, 40 };
    int single[MAX_ELEMENTS] = { 125, 127, 110, 100, 88, 78, 72, 65, 60, 55, 45 };

    // declare and initialize local variables
    char runAgain, tempColor, tempType;
    int mainLoop = 0, tempAmount = 0, subTotal = 0, totalTickets = 0, totalPrice = 0;

    // welcome user
    greetingsEarthlings();

    while ( mainLoop == 0 )
    {
        runAgain = looper();
        if ( runAgain == 'Y' )
        {
            tempColor = getColor( color );
            if ( tempColor != 'Q' )
            {
                tempType = getType();
                tempAmount = getAmount( tempType );
                subTotal = confirmPurchase( tempColor, tempType, tempAmount,
                                            today, group, single );
                if ( subTotal != 0 )
                {
                    totalPrice += subTotal;
                    totalTickets += tempAmount;
                    displayCurrent( &totalTickets, &totalPrice );
                }
                else
                    printf ( "Purchase canceled, returning to main menu.\n\n" );
            }
            else
                mainLoop = 1;
        }
        else if ( runAgain == 'N' )
        {
            mainLoop = 1;
        }
    }// end mainLoop

    printf ( "\nTicket Novice closed by user.\n" );
    closeOut( &totalTickets, &totalPrice );

    system( "PAUSE" );
    return;
}// end main