Gnash  0.8.11dev
Public Member Functions | Public Attributes | List of all members
gnash::ActionExec Class Reference

Executor of an action_buffer. More...

#include <ActionExec.h>

Inheritance diagram for gnash::ActionExec:

Public Member Functions

 ActionExec (const action_buffer &abuf, as_environment &newEnv, bool abortOnUnloaded=true)
 Create an execution thread. More...
 
 ActionExec (const Function &func, as_environment &newEnv, as_value *nRetVal, as_object *this_ptr)
 Create an execution thread for a function call. More...
 
void pushTryBlock (TryBlock t)
 Use this to push a try block. It will be copied. More...
 
void pushReturn (const as_value &t)
 Set the return value. More...
 
bool isFunction () const
 Is this execution thread a function call ? More...
 
as_objectgetThisPointer ()
 Get the current 'this' pointer, for use in function calls. More...
 
const ScopeStack & getScopeStack () const
 Returns the scope stack associated with this execution thread. More...
 
bool pushWith (const With &entry)
 Push an entry to the with stack. More...
 
void skip_actions (size_t offset)
 Skip the specified number of action tags. More...
 
bool delVariable (const std::string &name)
 Delete named variable, seeking for it in the with stack if any. More...
 
void setVariable (const std::string &name, const as_value &val)
 Set a named variable, seeking for it in the with stack if any. More...
 
void setLocalVariable (const std::string &name, const as_value &val)
 Set a function-local variable. More...
 
as_value getVariable (const std::string &name, as_object **target=nullptr)
 Get a named variable, seeking for it in the with stack if any. More...
 
as_objectgetTarget ()
 Get current target. More...
 
void operator() ()
 Execute. More...
 
bool atActionTag (SWF::ActionType t)
 
size_t getCurrentPC () const
 
void skipRemainingBuffer ()
 
void adjustNextPC (int offset)
 
size_t getNextPC () const
 
void setNextPC (size_t pc)
 
size_t getStopPC () const
 

Public Attributes

const action_buffercode
 The actual action buffer. More...
 
as_environmentenv
 TODO: provide a getter and make private ? More...
 
as_valueretval
 TODO: provide a setter and make private ? More...
 

Detailed Description

Executor of an action_buffer.

Constructor & Destructor Documentation

§ ActionExec() [1/2]

gnash::ActionExec::ActionExec ( const action_buffer abuf,
as_environment newEnv,
bool  abortOnUnloaded = true 
)

Create an execution thread.

Parameters
abufthe action code
newEnvthe timeline context.
abortOnUnloadedIf true (default) execution aborts as soon as the target sprite is unloaded. NOTE: original target is fetched from the environment.

§ ActionExec() [2/2]

gnash::ActionExec::ActionExec ( const Function func,
as_environment newEnv,
as_value nRetVal,
as_object this_ptr 
)

Create an execution thread for a function call.

Parameters
funcThe function
newEnvThe execution environment (variables scope, stack etc.)
nRetvalWhere to return a value. If NULL any return will be discarded.

References code, gnash::VM::currentCall(), gnash::CallFrame::function(), gnash::action_buffer::getDefinitionVersion(), gnash::getVM(), gnash::CallFrame::locals(), and gnash::action_buffer::size().

Member Function Documentation

§ adjustNextPC()

void gnash::ActionExec::adjustNextPC ( int  offset)

§ atActionTag()

bool gnash::ActionExec::atActionTag ( SWF::ActionType  t)
inline

§ delVariable()

bool gnash::ActionExec::delVariable ( const std::string &  name)

Delete named variable, seeking for it in the with stack if any.

Parameters
nameName of the variable. Supports slash and dot syntax.

References gnash::delVariable(), env, and getScopeStack().

§ getCurrentPC()

size_t gnash::ActionExec::getCurrentPC ( ) const
inline

§ getNextPC()

size_t gnash::ActionExec::getNextPC ( ) const
inline

§ getScopeStack()

const ScopeStack& gnash::ActionExec::getScopeStack ( ) const
inline

Returns the scope stack associated with this execution thread.

References gnash::delVariable(), gnash::getVariable(), name, and gnash::setVariable().

Referenced by delVariable(), getVariable(), setLocalVariable(), and setVariable().

§ getStopPC()

size_t gnash::ActionExec::getStopPC ( ) const
inline

References gnash::image::end(), and start.

§ getTarget()

as_object * gnash::ActionExec::getTarget ( )

Get current target.

This function returns top 'with' stack entry, if any. Main use for this function is for calling methods and properly setting the "this" pointer.

TODO: A better, cleaner and less error-prone approach would be providing a callFunction() method in ActionExec. This will likely help debugger too

References env, gnash::getObject(), and gnash::as_environment::target().

Referenced by gnash::SWF::SWFHandlers::execute().

§ getThisPointer()

as_object * gnash::ActionExec::getThisPointer ( )

Get the current 'this' pointer, for use in function calls.

References env, gnash::as_environment::get_original_target(), and gnash::getObject().

§ getVariable()

as_value gnash::ActionExec::getVariable ( const std::string &  name,
as_object **  target = nullptr 
)

Get a named variable, seeking for it in the with stack if any.

Parameters
nameName of the variable. Supports slash and dot syntax.
targetAn output parameter, will be set to point to the object containing any found variable. If you aren't interested, pass null (default). If the variable does not belong to an object, target will be set to null.

References env, getScopeStack(), and gnash::getVariable().

Referenced by gnash::SWF::SWFHandlers::execute().

§ isFunction()

bool gnash::ActionExec::isFunction ( ) const
inline

Is this execution thread a function call ?

Referenced by setLocalVariable().

§ operator()()

void gnash::ActionExec::operator() ( )

§ pushReturn()

void gnash::ActionExec::pushReturn ( const as_value t)

Set the return value.

References retval, and gnash::key::t.

§ pushTryBlock()

void gnash::ActionExec::pushTryBlock ( TryBlock  t)

Use this to push a try block. It will be copied.

§ pushWith()

bool gnash::ActionExec::pushWith ( const With entry)

Push an entry to the with stack.

Returns
true if the entry was pushed, false otherwise. This depends on the with stack limit.

References IF_VERBOSE_ASCODING_ERRORS, gnash::log_aserror(), and gnash::With::object().

§ setLocalVariable()

void gnash::ActionExec::setLocalVariable ( const std::string &  name,
const as_value val 
)

Set a function-local variable.

If we're not in a function, set a normal variable.

Parameters
nameName of the variable. Supports slash and dot syntax.
valThe value to set the variable to.

References env, getScopeStack(), gnash::getURI(), gnash::getVM(), isFunction(), gnash::setLocal(), and gnash::setVariable().

Referenced by operator()().

§ setNextPC()

void gnash::ActionExec::setNextPC ( size_t  pc)
inline

§ setVariable()

void gnash::ActionExec::setVariable ( const std::string &  name,
const as_value val 
)

Set a named variable, seeking for it in the with stack if any.

Parameters
nameName of the variable. Supports slash and dot syntax.

References env, getScopeStack(), and gnash::setVariable().

Referenced by gnash::SWF::SWFHandlers::execute().

§ skip_actions()

void gnash::ActionExec::skip_actions ( size_t  offset)

Skip the specified number of action tags.

The offset is relative to next_pc

References _, code, gnash::key::i, IF_VERBOSE_MALFORMED_SWF, length, gnash::log_swferror(), and gnash::action_buffer::read_int16().

Referenced by gnash::SWF::SWFHandlers::execute().

§ skipRemainingBuffer()

void gnash::ActionExec::skipRemainingBuffer ( )
inline

Member Data Documentation

§ code

const action_buffer& gnash::ActionExec::code

The actual action buffer.

TODO: provide a getter and make private

Referenced by ActionExec(), adjustNextPC(), gnash::SWF::SWFHandlers::execute(), operator()(), and skip_actions().

§ env

as_environment& gnash::ActionExec::env

§ retval

as_value* gnash::ActionExec::retval

TODO: provide a setter and make private ?

Referenced by operator()(), and pushReturn().


The documentation for this class was generated from the following files: