Public Member Functions | Public Attributes

gnash::ActionExec Class Reference

Executor of an action_buffer. More...

#include <ActionExec.h>

Collaboration diagram for gnash::ActionExec:
Collaboration graph
[legend]

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. t 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.
bool delObjectMember (as_object &obj, const std::string &name)
 Delete a named object member.
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)
 If in a function context set a local variable, otherwise, set a normal variable.
as_value getVariable (const std::string &name)
 Get a named variable, seeking for it in the with stack if any.
as_value getVariable (const std::string &name, as_object **target)
 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 execution environment (variables scope, stack etc.)
abortOnUnloaded If true (the 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 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::delObjectMember ( as_object obj,
const std::string &  name 
)

Delete a named object member.

Parameters:
obj The object to remove the member/property from.
name Name of the member. Name is converted to lowercase if SWF version is < 7.
Returns:
true if the member was successfully removed, false otherwise.

References gnash::as_object::delProperty(), env, gnash::string_table::find(), and gnash::getStringTable().

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. Name is converted to lowercase if SWF version is < 7.

References gnash::as_environment::delVariableRaw(), 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::as_environment::get_target(), and gnash::getObject().

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 
)

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

Parameters:
name Name of the variable. Supports slash and dot syntax. Name is converted to lowercase if SWF version is < 7.
target An output parameter, will be set to point to the object containing any found variable. The pointer may be set to NULL if the variable was not found or it belongs to no object (absolute references, for instance).

References env, gnash::as_environment::get_variable(), and getScopeStack().

as_value gnash::ActionExec::getVariable ( const std::string &  name  ) 

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

Parameters:
name Name of the variable. Supports slash and dot syntax. Name is converted to lowercase if SWF version is < 7.

References env, gnash::as_environment::get_variable(), 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. t 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 
)

If in a function context set a local variable, otherwise, set a normal variable.

Parameters:
name Name of the variable. Supports slash and dot syntax. Name is converted to lowercase if SWF version is < 7.

References env, gnash::string_table::find(), getScopeStack(), gnash::getStringTable(), gnash::getVM(), isFunction(), gnash::as_environment::set_variable(), and gnash::setLocal().

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. Name is converted to lowercase if SWF version is < 7.

References env, getScopeStack(), and gnash::as_environment::set_variable().

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, 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 delObjectMember(), 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: