Gnash
0.8.10
|
Executor of an action_buffer. More...
#include <ActionExec.h>
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_object * | getThisPointer () |
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_object * | getTarget () |
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_buffer & | code |
The actual action buffer. | |
as_environment & | env |
TODO: provide a getter and make private ? | |
as_value * | retval |
TODO: provide a setter and make private ? |
Executor of an action_buffer.
gnash::ActionExec::ActionExec | ( | const action_buffer & | abuf, |
as_environment & | newEnv, | ||
bool | abortOnUnloaded = true |
||
) |
Create an execution thread.
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.
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::action_buffer::size(), gnash::action_buffer::getDefinitionVersion(), gnash::getVM(), gnash::VM::currentCall(), gnash::CallFrame::function(), and gnash::CallFrame::locals().
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.
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(), 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().
Get a named variable, seeking for it in the with stack if any.
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() | ( | ) |
Execute.
References gnash::getVM(), env, gnash::VM::getRoot(), gnash::movie_root::scriptsDisabled(), gnash::VM::getSWFVersion(), code, gnash::action_buffer::getDefinitionVersion(), gnash::VM::setSWFVersion(), gnash::key::SWF, gnash::SWF::SWFHandlers::instance(), gnash::as_environment::target(), gnash::as_environment::stack_size(), IF_VERBOSE_ACTION, _, gnash::action_buffer::size(), gnash::VM::dumpState(), STACK_DUMP_LIMIT, gnash::getRoot(), gnash::movie_root::getTimeoutLimit(), gnash::as_environment::top(), gnash::as_value::is_exception(), gnash::as_environment::drop(), gnash::key::t, assert, gnash::action_buffer::disasm(), length, gnash::action_buffer::read_int16(), IF_VERBOSE_MALFORMED_SWF, gnash::SWF::ACTION_END, gnash::SWF::SWFHandlers::execute(), gnash::DisplayObject::unloaded(), gnash::DisplayObject::getTarget(), gnash::typeName(), gnash::SystemClock::elapsed(), gnash::action_buffer::getMovieDefinition(), gnash::movie_definition::get_url(), gnash::movie_root::queryInterface(), and gnash::SystemClock::restart().
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.
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.
name | Name of the variable. Supports slash and dot syntax. |
val | The 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.
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 gnash::key::i, IF_VERBOSE_MALFORMED_SWF, _, code, length, gnash::action_buffer::read_int16(), and assert.
void gnash::ActionExec::skipRemainingBuffer | ( | ) | [inline] |
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().