20 #ifndef GNASH_MACHINE_H
21 #define GNASH_MACHINE_H
44 template <
typename T>
class FunctionArgs;
232 unsigned char stack_in,
short stack_out);
235 as_value& storage,
unsigned char stack_in,
short stack_out);
238 unsigned char stack_in,
short stack_out) {
262 unsigned int _stackDepth;
263 unsigned int _stackTotalSize;
264 unsigned int _scopeStackDepth;
265 unsigned int mScopeTotalSize;
272 std::vector<as_value> _registers;
274 void to_debug_string(){
275 log_abc(
"StackDepth=%u StackTotalSize=%u ScopeStackDepth=%u ScopeTotalSize=%u",_stackDepth,_stackTotalSize,_scopeStackDepth,mScopeTotalSize);
283 unsigned int mHeightAfterPop;
286 Scope() : mHeightAfterPop(0), mScope(NULL) {}
287 Scope(
unsigned int i, as_object *
o) : mHeightAfterPop(i),
295 as_value find_prop_strict(MultiName multiname);
299 void print_scope_stack();
301 void get_args(
size_t argc, FunctionArgs<as_value>& args);
303 void load_function(CodeStream* stream, std::uint32_t maxRegisters);
305 void executeCodeblock(CodeStream* stream);
307 void clearRegisters(std::uint32_t maxRegsiters);
309 const as_value& getRegister(
int index){
310 log_abc(
"Getting value at a register %d ", index);
311 return _registers[index];
314 void setRegister(
size_t index,
const as_value& val) {
315 log_abc(
"Putting %s in register %s", val, index);
316 if (_registers.size() <= index) {
317 log_abc(
"Register doesn't exist! Adding new registers!");
318 _registers.resize(index + 1);
320 _registers[index] = val;
323 void push_stack(as_value
object){
324 log_abc(
"Pushing value %s onto stack.",
object);
328 as_value pop_stack(){
329 as_value value = _stack.pop();
330 log_abc(
"Popping value %s off the stack.", value);
334 void push_scope_stack(as_value
object);
336 as_object* pop_scope_stack() {
337 log_abc(
"Popping value %s off the scope stack. There will be "
338 "%u items left.", as_value(_scopeStack.top(0)),
339 _scopeStack.size()-1);
340 return _scopeStack.pop();
343 as_object* get_scope_stack(std::uint8_t depth)
const {
344 log_abc(
"Getting value from scope stack %u from the bottom.",
346 return _scopeStack.value(depth);
349 SafeStack<as_value> _stack;
350 SafeStack<State> mStateStack;
351 std::vector<as_value> _registers;
361 SafeStack<as_object*> _scopeStack;
367 Namespace* mDefaultXMLNamespace;
368 as_object* mCurrentScope;
369 as_object* mGlobalScope;
370 as_object* mDefaultThis;
376 as_value mGlobalReturn;
377 as_value mIgnoreReturn;
379 bool mExitWithReturn;
380 AbcBlock* mPoolObject;
382 abc_function* mCurrentFunction;
int completeName(MultiName &name, int initial=0)
Definition: Machine.cpp:2986
The ActionScript bytecode of a single ABC tag in a SWF.
Definition: AbcBlock.h:208
Definition: klash_part.cpp:329
Property * findProperty(MultiName &)
Definition: Machine.h:165
void immediateFunction(const as_function *to_call, as_object *pThis, as_value &storage, unsigned char stack_in, short stack_out)
Definition: Machine.cpp:3033
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
ActionScript value type.
Definition: as_value.h:95
void setMember(Class *, MultiName &, as_value &target, as_value &val)
Definition: Machine.cpp:2954
An abstract property.
Definition: Property.h:276
Global_as * global()
Return the Global object for this Machine.
Definition: Machine.cpp:365
Class * findSuper(as_value &obj, bool find_primitive)
Definition: Machine.cpp:3012
void getMember(Class *pDefinition, MultiName &name, as_value &source)
Definition: Machine.cpp:2930
void initMachine(AbcBlock *pool_block)
Definition: Machine.cpp:3154
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Represent an ActionScript Namespace.
Definition: Namespace.h:48
The base class for all ActionScript objects.
Definition: as_object.h:161
Definition: GnashKey.h:161
void pushCall(as_function *func, as_object *pThis, as_value &return_slot, unsigned char stack_in, short stack_out)
Definition: Machine.cpp:3084
void pushGet(as_object *this_obj, as_value &return_slot, Property *prop)
Definition: Machine.cpp:3057
Definition: CodeStream.h:40
DisplayObject * getTarget()
The DisplayObject which initiated these actions.
A class to represent AS3 Classes.
Definition: Class.h:75
as_value executeFunction(Method *function, const fn_call &fn)
Definition: Machine.cpp:3172
void execute()
Definition: Machine.cpp:381
void markReachableResources() const
Definition: Machine.cpp:3218
void init()
Initialize the AS resources.
Definition: Machine.cpp:351
void setTarget(DisplayObject *target)
void immediateProcedure(const as_function *to_call, as_object *pthis, unsigned char stack_in, short stack_out)
Definition: Machine.h:237
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:49
The virtual machine for executing ABC (ActionScript Bytecode).
Definition: Machine.h:73
void pushSet(as_object *this_obj, as_value &value, Property *prop)
Definition: Machine.cpp:3070
The AVM1 virtual machine.
Definition: VM.h:71
Machine(VM &vm)
Create an AS3 interpreter.
Definition: Machine.cpp:327
Definition: GnashKey.h:155
An MultiName represents a single ABC multiname.
Definition: MultiName.h:51
ABC-defined Function.
Definition: abc_function.h:40
void log_abc(StringType msg, Args...args)
Definition: log.h:337
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:117
std::string name
Definition: LocalConnection_as.cpp:149
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:62
void instantiateClass(std::string className, as_object *global)
Definition: Machine.cpp:3224