Go to the documentation of this file.
19 #ifndef GNASH_ACTIONEXEC_H
20 #define GNASH_ACTIONEXEC_H
25 #include <boost/noncopyable.hpp>
53 TryBlock(
size_t cur_off,
size_t try_size,
size_t catch_size,
54 size_t finally_size, std::string catchName)
56 _catchOffset(cur_off + try_size),
57 _finallyOffset(cur_off + try_size + catch_size),
58 _afterTriedOffset(cur_off + try_size + catch_size + finally_size),
61 _name(std::move(catchName)),
67 TryBlock(
size_t cur_off,
size_t try_size,
size_t catch_size,
68 size_t finally_size, std::uint8_t register_index)
70 _catchOffset(cur_off + try_size),
71 _finallyOffset(cur_off + try_size + catch_size),
72 _afterTriedOffset(cur_off + try_size + catch_size + finally_size),
76 _registerIndex(register_index),
83 size_t _finallyOffset;
84 size_t _afterTriedOffset;
85 size_t _savedEndOffset;
88 unsigned int _registerIndex;
105 return _block_end_pc;
114 size_t _block_end_pc;
133 bool abortOnUnloaded =
true);
255 void dumpActions(
size_t start,
size_t end, std::ostream& os);
287 void cleanupAfterRun();
290 std::vector<With> _withStack;
293 ScopeStack _scopeStack;
309 size_t _initialStackSize;
313 int _origExecSWFVersion;
315 std::stack<TryBlock> _tryList;
335 #endif // GNASH_ACTIONEXEC_H
const action_buffer & code
The actual action buffer.
Definition: ActionExec.h:153
static const SWFHandlers & instance()
Return the singleton instance of SWFHandlers class.
Definition: ASHandlers.cpp:421
size_t end_pc() const
Definition: ActionExec.h:104
size_t size() const
Definition: action_buffer.h:65
void operator()()
Execute.
Definition: ActionExec.cpp:125
as_object * getThisPointer()
Get the current 'this' pointer, for use in function calls.
Definition: ActionExec.cpp:706
std::string name
Definition: LocalConnection_as.cpp:149
void setSWFVersion(int v)
Set SWF version of the currently executing code.
Definition: VM.cpp:74
bool is_exception() const
Definition: as_value.h:348
void pushReturn(const as_value &t)
Set the return value.
Definition: ActionExec.cpp:659
A singleton containing the supported SWF Action handlers.
Definition: ASHandlers.h:74
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
The base class for all ActionScript objects.
Definition: as_object.h:162
void restart()
Restart the clock.
Definition: SystemClock.cpp:53
bool isFunction() const
Is this execution thread a function call ?
Definition: ActionExec.h:162
void log_action(StringType msg, Args... args)
Definition: log.h:307
@ TRY_END
Definition: ActionExec.h:50
size_t getNextPC() const
Definition: ActionExec.h:234
void log_debug(StringType msg, Args... args)
Definition: log.h:301
as_value * retval
TODO: provide a setter and make private ?
Definition: ActionExec.h:159
@ i
Definition: GnashKey.h:155
bool delVariable(const as_environment &ctx, const std::string &varname, const as_environment::ScopeStack &scope)
Delete a variable, without support for the path, using a ScopeStack.
Definition: as_environment.cpp:357
std::string disasm(size_t pc) const
Disassemble instruction at given offset and return as a string.
Definition: action_buffer.cpp:454
virtual const std::string & get_url() const =0
Return the URL of the SWF stream this definition has been read from.
std::string typeName(const T &inst)
Definition: utility.h:93
void setLocal(CallFrame &c, const ObjectURI &name, const as_value &val)
Set a local variable in this CallFrame.
Definition: CallStack.cpp:80
A simple SWF-defined Function.
Definition: Function.h:64
as_value getVariable(const as_environment &env, const std::string &varname, const as_environment::ScopeStack &scope, as_object **retTarget)
Return the (possibly undefined) value of the named var.
Definition: as_environment.cpp:289
#define _(String)
Definition: log.h:44
movie_root & getRoot() const
Get a pointer to this VM's Root movie (stage)
Definition: VM.cpp:143
Provides information about timeline context.
Definition: as_environment.h:51
ActionType
SWF action ids. Symbolic names copied from Ming.
Definition: SWF.h:125
The AVM1 virtual machine.
Definition: VM.h:72
void setLocalVariable(const std::string &name, const as_value &val)
Set a function-local variable.
Definition: ActionExec.cpp:627
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
void skip_actions(size_t offset)
Skip the specified number of action tags.
Definition: ActionExec.cpp:554
const movie_definition & getMovieDefinition() const
Definition: action_buffer.h:185
@ start
Definition: klash_part.cpp:330
std::string DSOEXPORT getTarget() const
Return full path to this object, in dot notation.
Definition: DisplayObject.cpp:621
Executor of an action_buffer.
Definition: ActionExec.h:119
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
@ ACTION_END
Definition: SWF.h:126
as_value getVariable(const std::string &name, as_object **target=nullptr)
Get a named variable, seeking for it in the with stack if any.
Definition: ActionExec.cpp:621
void setVariable(const std::string &name, const as_value &val)
Set a named variable, seeking for it in the with stack if any.
Definition: ActionExec.cpp:615
bool pushWith(const With &entry)
Push an entry to the with stack.
Definition: ActionExec.cpp:590
Definition: ActionExec.h:94
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
as_object * object() const
Definition: ActionExec.h:108
size_t getStopPC() const
Definition: ActionExec.h:238
@ t
Definition: GnashKey.h:166
tryState
Definition: ActionExec.h:46
bool queryInterface(const std::string &what) const
Ask the host interface a question.
Definition: movie_root.cpp:246
void pushTryBlock(TryBlock t)
Use this to push a try block. It will be copied.
Definition: ActionExec.cpp:649
void push(const as_value &val)
Push a value on the stack.
Definition: as_environment.h:83
size_t stack_size() const
Definition: as_environment.h:117
#define IF_VERBOSE_ASCODING_ERRORS(x)
Definition: log.h:397
code
Definition: GnashKey.h:44
@ length
Definition: klash_part.cpp:329
void setRegister(size_t index, const as_value &val)
Set value of a register (local or global).
Definition: VM.cpp:206
ActionExec(const action_buffer &abuf, as_environment &newEnv, bool abortOnUnloaded=true)
Create an execution thread.
Definition: ActionExec.cpp:103
std::vector< as_object * > ScopeStack
A stack of objects used for variables/members lookup.
Definition: as_environment.h:55
std::int16_t read_int16(size_t pc) const
Get a signed integer value from given offset.
Definition: action_buffer.h:105
std::uint16_t getTimeoutLimit() const
Definition: movie_root.h:777
@ TRY_FINALLY
Definition: ActionExec.h:49
TryBlock(size_t cur_off, size_t try_size, size_t catch_size, size_t finally_size, std::string catchName)
Definition: ActionExec.h:53
void setNextPC(size_t pc)
Definition: ActionExec.h:236
as_object * getTarget()
Get current target.
Definition: ActionExec.cpp:640
DisplayObject * target() const
Definition: as_environment.h:61
int getSWFVersion() const
Get SWF version context for the currently running actions.
Definition: VM.h:106
bool atActionTag(SWF::ActionType t)
Definition: ActionExec.h:226
unsigned long int elapsed() const
Return number of milliseconds elapsed since start.
Definition: SystemClock.cpp:47
void unflag_exception()
Definition: as_value.h:363
const ScopeStack & getScopeStack() const
Returns the scope stack associated with this execution thread.
Definition: ActionExec.h:168
ActionScript value type.
Definition: as_value.h:95
@ TRY_TRY
Definition: ActionExec.h:47
void skipRemainingBuffer()
Definition: ActionExec.h:230
bool unloaded() const
Return true if this DisplayObject was unloaded from the stage.
Definition: DisplayObject.h:785
size_t getCurrentPC() const
Definition: ActionExec.h:228
void drop(size_t count)
Drop 'count' values off the top of the stack.
Definition: as_environment.h:111
UserFunction & function()
Get the function for which this CallFrame provides a scope.
Definition: CallStack.h:78
void log_aserror(StringType msg, Args... args)
Definition: log.h:331
void setVariable(const as_environment &env, const std::string &varname, const as_value &val, const as_environment::ScopeStack &scope)
Given a path to variable, set its value.
Definition: as_environment.cpp:328
@ TRY_CATCH
Definition: ActionExec.h:48
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
#define IF_VERBOSE_ACTION(x)
Definition: log.h:384
An ActionScript limit exception.
Definition: GnashException.h:136
DisplayObject * get_original_target() const
Definition: as_environment.h:77
as_object * getObject(const DisplayObject *d)
Return the as_object associated with a DisplayObject if it exists.
Definition: DisplayObject.h:1160
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
TryBlock(size_t cur_off, size_t try_size, size_t catch_size, size_t finally_size, std::uint8_t register_index)
Definition: ActionExec.h:67
void set_target(DisplayObject *target)
Set default target for timeline opcodes.
Definition: as_environment.h:68
as_environment & env
TODO: provide a getter and make private ?
Definition: ActionExec.h:156
void dumpState(std::ostream &o, size_t limit=0)
Print stack, call stack, and registers to the specified ostream.
Definition: VM.cpp:299
as_value pop()
Pops an as_value off the stack top and return it.
Definition: as_environment.h:88
void flushHigherPriorityActionQueues()
Definition: movie_root.cpp:1428
#define STACK_DUMP_LIMIT
Definition: ActionExec.cpp:52
ObjectURI getURI(const VM &vm, const std::string &str, bool lowerCaseHint=false)
Definition: VM.h:290
void adjustNextPC(int offset)
Definition: ActionExec.cpp:668
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
A code segment.
Definition: action_buffer.h:50
bool delVariable(const std::string &name)
Delete named variable, seeking for it in the with stack if any.
Definition: ActionExec.cpp:609
A system-clock based virtual clock.
Definition: SystemClock.h:37
A CallFrame is an element of a CallStack.
Definition: CallStack.h:44
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
void execute(ActionType type, ActionExec &thread) const
Execute the action identified by 'type' action type.
Definition: ASHandlers.cpp:428
With(as_object *obj, size_t end)
Definition: ActionExec.h:97
Definition: ActionExec.h:41
as_object & locals()
Access the local variables for this function call.
Definition: CallStack.h:73
int getDefinitionVersion() const
Return version of the SWF this action block was found in.
Definition: action_buffer.cpp:479
as_value & top(size_t dist) const
Get stack value at the given distance from top.
Definition: as_environment.h:102
CallFrame & currentCall()
Return the CallFrame of the currently executing function.
Definition: VM.cpp:229
bool scriptsDisabled() const
Return true if scripts execution is disabled.
Definition: movie_root.h:607