BObject ExportScript::call( unsigned PC, 
                                BObjectImp* p0, 
                                BObjectImpRefVec& pmore )
{
    try
    {
        uoexec.initForFnCall( PC );

        uoexec.pushArg(p0);
        unsigned n = pmore.size();
        for( unsigned i = 0; i < n; ++i )
        { 
            uoexec.pushArg( pmore[i].get() ); 
        }
        
        uoexec.exec();
        if (uoexec.error())
            return BObject( new BError( "Error during execution" ) );
        if (uoexec.ValueStack.empty())
            return BObject( new BError( "There was no return value??" ) );
        BObjectImp* ret = uoexec.ValueStack.top()->impptr()->copy();
        uoexec.ValueStack.pop();
        return BObject(ret);
    }
    catch(std::exception&)//...
    {
        return BObject( new BError( "Exception during execution" ) );
    }
}
예제 #2
0
	BObject ExportScript::call( unsigned PC,
								BObjectImp* p0,
								BObjectImpRefVec& pmore )
	{
	  try
	  {
		//build backup if function is called inside the same script
		BackupStruct backup;
		SaveStack( backup );

		uoexec.initForFnCall( PC );

		uoexec.pushArg( p0 );
		size_t n = pmore.size();
		for ( size_t i = 0; i < n; ++i )
		{
		  uoexec.pushArg( pmore[i].get() );
		}

		uoexec.exec();
		BObjectImp* ret;

		if ( uoexec.error() )
		  ret = new BError( "Error during execution" );
		else if ( uoexec.ValueStack.empty() )
		  ret = new BError( "There was no return value??" );
		else
		{
		  ret = uoexec.ValueStack.back()->impptr()->copy();
		  uoexec.ValueStack.pop_back();
		}

		// delete current state and reenable backup
		LoadStack( backup );

		return BObject( ret );
	  }
	  catch ( std::exception& )//...
	  {
		return BObject( new BError( "Exception during execution" ) );
	  }
	}