Beispiel #1
0
FALCON_FUNC  Dictionary_do ( ::Falcon::VMachine *vm )
{
	Item* i_func = vm->param(0);

   if ( i_func == 0 || ! i_func->isCallable() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
         .extra( "C, ..." ) );
   }

   // Save the parameters as the stack may change greatly.
   CoreDict* dict = vm->self().asDict();
   if ( dict->empty() )
   {
   	vm->retnil();
   	return;
   }


   Iterator* iter = new Iterator(&dict->items());
   vm->addLocals(1);
   *vm->local(0) = new GarbagePointer(iter);
   vm->returnHandler( Dictionary_do_next );

   // do the first call.
   vm->pushParam( iter->getCurrentKey() );
	vm->pushParam( iter->getCurrent() );
	vm->callFrame( *vm->param(0), 2 );
}