Public Member Functions | Public Attributes

gnash::ActionExec Class Reference

Executor of an action_buffer. More...

#include <ActionExec.h>

List of all members.

Public Member Functions

 ActionExec (const action_buffer &abuf, as_environment &newEnv, bool abortOnUnloaded=true)
 Create an execution thread.
 ActionExec (const Function &func, as_environment &newEnv, as_value *nRetVal, as_object *this_ptr)
 Create an execution thread for a function call.
void pushTryBlock (TryBlock t)
 Use this to push a try block. It will be copied.
void pushReturn (const as_value &t)
 Set the return value.
bool isFunction () const
 Is this execution thread a function call ?
as_objectgetThisPointer ()
 Get the current 'this' pointer, for use in function calls.
const ScopeStack & getScopeStack () const
 Returns the scope stack associated with this execution thread.
bool pushWith (const With &entry)
 Push an entry to the with stack.
void skip_actions (size_t offset)
 Skip the specified number of action tags.
bool delVariable (const std::string &name)
 Delete named variable, seeking for it in the with stack if any.
void setVariable (const std::string &name, const as_value &val)
 Set a named variable, seeking for it in the with stack if any.
void setLocalVariable (const std::string &name, const as_value &val)
 Set a function-local variable.
as_value getVariable (const std::string &name, as_object **target=0)
 Get a named variable, seeking for it in the with stack if any.
as_objectgetTarget ()
 Get current target.
void operator() ()
 Execute.
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.
as_environmentenv
 TODO: provide a getter and make private ?
as_valueretval
 TODO: provide a setter and make private ?

Detailed Description

Executor of an action_buffer.


Constructor & Destructor Documentation

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

Create an execution thread.

Parameters:
abuf the action code
newEnv the timeline context.
abortOnUnloaded If true (default) execution aborts as soon as the target sprite is unloaded. NOTE: original target is fetched from the environment.
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:
func The function
newEnv The execution environment (variables scope, stack etc.)
nRetval Where to return a value. If NULL any return will be discarded.

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


Member Function Documentation

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

References _.

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

References code.

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

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

Parameters:
name Name of the variable. Supports slash and dot syntax.

References env, and getScopeStack().

size_t gnash::ActionExec::getCurrentPC (  )  const [inline]
size_t gnash::ActionExec::getNextPC (  )  const [inline]
const ScopeStack& gnash::ActionExec::getScopeStack (  )  const [inline]

Returns the scope stack associated with this execution thread.

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

size_t gnash::ActionExec::getStopPC (  )  const [inline]
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().

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().

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

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

Parameters:
name Name of the variable. Supports slash and dot syntax.
target An 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, and getScopeStack().

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

Is this execution thread a function call ?

Referenced by setLocalVariable().

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

Set the return value.

References retval.

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

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

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, and gnash::With::object().

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:
name Name of the variable. Supports slash and dot syntax.
val The value to set the variable to.

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

void gnash::ActionExec::setNextPC ( size_t  pc  )  [inline]
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:
name Name of the variable. Supports slash and dot syntax.

References env, and getScopeStack().

Referenced by setLocalVariable().

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

Skip the specified number of action tags.

The offset is relative to next_pc

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

void gnash::ActionExec::skipRemainingBuffer (  )  [inline]

Member Data Documentation

The actual action buffer.

TODO: provide a getter and make private

Referenced by ActionExec(), atActionTag(), operator()(), and skip_actions().

TODO: provide a getter and make private ?

Referenced by delVariable(), getTarget(), getThisPointer(), getVariable(), operator()(), setLocalVariable(), and setVariable().

TODO: provide a setter and make private ?

Referenced by pushReturn().


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