Gnash  0.8.10
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:
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.
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 assert, code, gnash::action_buffer::size(), gnash::action_buffer::getDefinitionVersion(), gnash::getVM(), gnash::VM::currentCall(), gnash::CallFrame::function(), and gnash::CallFrame::locals().


Member Function Documentation

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

References _.

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

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

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 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(), setVariable(), getVariable(), and setLocalVariable().

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 gnash::getObject(), env, and gnash::as_environment::target().

as_object * gnash::ActionExec::getThisPointer ( )

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

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

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:
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, 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, and gnash::key::t.

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:
nameName of the variable. Supports slash and dot syntax.
valThe value to set the variable to.

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

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:
nameName 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 gnash::key::i, IF_VERBOSE_MALFORMED_SWF, _, code, length, gnash::action_buffer::read_int16(), and assert.

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

Member Data Documentation

The actual action buffer.

TODO: provide a getter and make private

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

TODO: provide a getter and make private ?

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

TODO: provide a setter and make private ?

Referenced by pushReturn().


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