Gnash
0.8.11dev
|
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. 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_object * | getThisPointer () |
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_object * | getTarget () |
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_buffer & | code |
The actual action buffer. More... | |
as_environment & | env |
TODO: provide a getter and make private ? More... | |
as_value * | retval |
TODO: provide a setter and make private ? More... | |
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 code, gnash::VM::currentCall(), gnash::CallFrame::function(), gnash::action_buffer::getDefinitionVersion(), gnash::getVM(), gnash::CallFrame::locals(), and gnash::action_buffer::size().
void gnash::ActionExec::adjustNextPC | ( | int | offset | ) |
References _, code, gnash::action_buffer::disasm(), length, gnash::log_unimpl(), and gnash::action_buffer::read_int16().
|
inline |
References gnash::key::t.
Referenced by gnash::SWF::SWFHandlers::execute().
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 gnash::delVariable(), env, and getScopeStack().
|
inline |
Referenced by gnash::SWF::SWFHandlers::execute().
|
inline |
|
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().
|
inline |
References gnash::image::end(), and start.
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().
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().
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, getScopeStack(), and gnash::getVariable().
Referenced by gnash::SWF::SWFHandlers::execute().
|
inline |
Is this execution thread a function call ?
Referenced by setLocalVariable().
void gnash::ActionExec::operator() | ( | ) |
Execute.
References _, gnash::SWF::ACTION_END, code, gnash::action_buffer::disasm(), gnash::as_environment::drop(), gnash::VM::dumpState(), gnash::SystemClock::elapsed(), env, gnash::SWF::SWFHandlers::execute(), gnash::movie_root::flushHigherPriorityActionQueues(), gnash::movie_definition::get_url(), gnash::action_buffer::getDefinitionVersion(), gnash::action_buffer::getMovieDefinition(), gnash::VM::getRoot(), gnash::getRoot(), gnash::VM::getSWFVersion(), gnash::DisplayObject::getTarget(), gnash::movie_root::getTimeoutLimit(), gnash::getVM(), IF_VERBOSE_ACTION, IF_VERBOSE_MALFORMED_SWF, gnash::SWF::SWFHandlers::instance(), gnash::as_value::is_exception(), length, gnash::log_action(), gnash::log_debug(), gnash::log_swferror(), gnash::as_environment::pop(), gnash::as_environment::push(), gnash::movie_root::queryInterface(), gnash::action_buffer::read_int16(), gnash::SystemClock::restart(), retval, gnash::movie_root::scriptsDisabled(), gnash::as_environment::set_target(), setLocalVariable(), gnash::VM::setRegister(), gnash::VM::setSWFVersion(), gnash::action_buffer::size(), STACK_DUMP_LIMIT, gnash::as_environment::stack_size(), gnash::key::t, gnash::as_environment::target(), gnash::as_environment::top(), gnash::TryBlock::TRY_CATCH, gnash::TryBlock::TRY_END, gnash::TryBlock::TRY_FINALLY, gnash::TryBlock::TRY_TRY, gnash::typeName(), gnash::as_value::unflag_exception(), and gnash::DisplayObject::unloaded().
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, gnash::log_aserror(), 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 env, getScopeStack(), gnash::getURI(), gnash::getVM(), isFunction(), gnash::setLocal(), and gnash::setVariable().
Referenced by operator()().
|
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, getScopeStack(), and gnash::setVariable().
Referenced by gnash::SWF::SWFHandlers::execute().
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().
|
inline |
Referenced by gnash::SWF::SWFHandlers::execute().
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().
as_environment& gnash::ActionExec::env |
TODO: provide a getter and make private ?
Referenced by delVariable(), gnash::SWF::SWFHandlers::execute(), getTarget(), getThisPointer(), getVariable(), operator()(), setLocalVariable(), and setVariable().
as_value* gnash::ActionExec::retval |
TODO: provide a setter and make private ?
Referenced by operator()(), and pushReturn().