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, boost::uint32_t maxRegisters);
305 void executeCodeblock(CodeStream* stream);
307 void clearRegisters(boost::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(boost::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;