gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/avm2 r9577: Capture the scope stack when w


From: Tom Stellard
Subject: [Gnash-commit] /srv/bzr/gnash/avm2 r9577: Capture the scope stack when we create a function and use that scope stack when call the function.
Date: Tue, 30 Sep 2008 23:54:41 +0800
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9577
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Tue 2008-09-30 23:54:41 +0800
message:
  Capture the scope stack when we create a function and use that scope stack 
when call the function.
modified:
  libcore/abc_function.cpp
  libcore/abc_function.h
  libcore/vm/Machine.cpp
=== modified file 'libcore/abc_function.cpp'
--- a/libcore/abc_function.cpp  2008-09-30 14:02:04 +0000
+++ b/libcore/abc_function.cpp  2008-09-30 15:54:41 +0000
@@ -23,7 +23,7 @@
 
 namespace gnash{
 
-abc_function::abc_function(asMethod *methodInfo, Machine* 
machine):as_function(){
+abc_function::abc_function(asMethod *methodInfo, Machine* 
machine):mScopeStack(),as_function(){
                mMethodInfo = methodInfo;
                mMachine = machine;
 }

=== modified file 'libcore/abc_function.h'
--- a/libcore/abc_function.h    2008-09-30 14:02:04 +0000
+++ b/libcore/abc_function.h    2008-09-30 15:54:41 +0000
@@ -26,6 +26,8 @@
 #include "as_value.h"
 #include "CodeStream.h"
 #include "asClass.h"
+#include "SafeStack.h"
+#include "as_object.h"
 
 namespace gnash {
 
@@ -48,6 +50,9 @@
        CodeStream* getCodeStream(){ return mMethodInfo->getBody();}
 
        boost::uint32_t getMaxRegisters(){ return 
mMethodInfo->getMaxRegisters(); }
+
+       SafeStack<boost::intrusive_ptr<as_object> > mScopeStack;
+
 };
 
 

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2008-09-30 14:20:10 +0000
+++ b/libcore/vm/Machine.cpp    2008-09-30 15:54:41 +0000
@@ -1020,7 +1020,11 @@
                boost::int32_t method_index = mStream->read_V32();
                LOG_DEBUG_AVM("Creating new abc_function: method 
index=%u",method_index);
                asMethod *m = pool_method(method_index, mPoolObject);
-               push_stack(as_value(m->getPrototype()));
+               abc_function* new_function = m->getPrototype();
+               //TODO: SafeStack contains all the scope objects in for all 
functions in the call stack.
+               //We should only copy the relevent scope objects to the 
function's scope stacks.
+               new_function->mScopeStack = mScopeStack;
+               push_stack(as_value(new_function));
                break;
        }
 /// 0x41 ABC_ACTION_CALL
@@ -2638,6 +2642,13 @@
        execute();
        mExitWithReturn = prev_ext;
        stream->seekTo(0);
+       
+//TODO:  There is probably a better way to do this.  Maybe we should remove 
the mScopeStack property
+//             of Machine and always have functions reference their own scope 
stack.
+       for(unsigned int i=0;i<mCurrentFunction->mScopeStack.size();++i){
+               push_scope_stack(mCurrentFunction->mScopeStack.top(i));
+       }
+
        return mGlobalReturn;
 }
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]