[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnash-commit
Subject:    [Gnash-commit] /srv/bzr/gnash/avm2 r9575: Add a reference to
From:       Tom Stellard <tstellar () gmail ! com>
Date:       2008-09-30 14:02:04
Message-ID: E1KkjZ2-0000y2-6r () sv ! gnu ! org
[Download RAW message or body]

------------------------------------------------------------
revno: 9575
committer: Tom Stellard <tstellar@gmail.com>
branch nick: gnash_dev
timestamp: Tue 2008-09-30 22:02:04 +0800
message:
  Add a reference to Machine for the function that is being executed.
modified:
  libcore/abc_function.cpp
  libcore/abc_function.h
  libcore/vm/Machine.cpp
  libcore/vm/Machine.h

["r9575.diff" (r9575.diff)]

=== modified file 'libcore/abc_function.cpp'
--- a/libcore/abc_function.cpp	2008-09-28 13:23:03 +0000
+++ b/libcore/abc_function.cpp	2008-09-30 14:02:04 +0000
@@ -33,7 +33,7 @@
 abc_function::operator()(const fn_call& fn)
 {
 	log_debug("Calling an abc_function id=%u.",mMethodInfo->mMethodID);
-	as_value val = mMachine->executeFunction(mMethodInfo->getBody(),mMethodInfo->getMaxRegisters(),fn);
 +	as_value val = mMachine->executeFunction(mMethodInfo,fn);
 	log_debug("Done calling abc_function id=%u \
value=%s",mMethodInfo->mMethodID,val.toDebugString());  return val;
 

=== modified file 'libcore/abc_function.h'
--- a/libcore/abc_function.h	2008-09-28 13:23:03 +0000
+++ b/libcore/abc_function.h	2008-09-30 14:02:04 +0000
@@ -25,6 +25,7 @@
 #include "as_function.h"
 #include "as_value.h"
 #include "CodeStream.h"
+#include "asClass.h"
 
 namespace gnash {
 
@@ -44,6 +45,9 @@
 
 	as_value operator()(const fn_call& fn);
 
+	CodeStream* getCodeStream(){ return mMethodInfo->getBody();}
+
+	boost::uint32_t getMaxRegisters(){ return mMethodInfo->getMaxRegisters(); }
 };
 
 

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp	2008-09-28 13:23:03 +0000
+++ b/libcore/vm/Machine.cpp	2008-09-30 14:02:04 +0000
@@ -1479,7 +1479,7 @@
 		asName a = pool_name(mStream->read_V32(), mPoolObject);
 	
 		as_value val = find_prop_strict(a);
-
+		LOG_DEBUG_AVM("VALUE FOUND.");
 		pop_stack();
 
 		push_stack(val);
@@ -2571,6 +2571,7 @@
 	mScopeStack.setAllSizes(s.mScopeTotalSize, s.mScopeStackDepth);
 	mStream = s.mStream;
 	mRegisters = s.mRegisters;
+	mCurrentFunction = s.mFunction;
 //	mExitWithReturn = s.mReturn;
 //	mDefaultXMLNamespace = s.mDefaultXMLNamespace;
 //	mCurrentScope = s.mCurrentScope;
@@ -2595,6 +2596,7 @@
 	s.mStream = mStream;
 	s.to_debug_string();
 	s.mRegisters = mRegisters;
+	s.mFunction = mCurrentFunction;
 //	s.mReturn = mExitWithReturn;
 //	s.mDefaultXMLNamespace = mDefaultXMLNamespace;
 //	s.mCurrentScope = mCurrentScope;
@@ -2608,20 +2610,11 @@
 	log_debug("Getting entry script.");
 	asClass* start_script = pool_block->mScripts.back();
 	log_debug("Getting constructor.");
-	asMethod* method = start_script->getConstructor();
-	clearRegisters(method->getMaxRegisters());
-//	mRegisters.push(global);
- 	int i;
- 	for(i=0;i<start_script->mTraits.size();i++){
- 		abc_Trait trait = start_script->mTraits[i];
-		asMethod* constructor = \
                pool_block->mClasses[trait.mClassInfoIndex]->getStaticConstructor();
- 		boost::uint8_t opcode;
- 		log_debug("AVM2: TraitConstructor flags: 0x%X, class index=%u Code:",trait.mKind \
                | 0x0,trait.mClassInfoIndex);
-		constructor->print_body();
-		//executeCodeblock(stream);		
-	}
+	asMethod* constructor = start_script->getConstructor();
+	clearRegisters(constructor->getMaxRegisters());
 	log_debug("Loding code stream.");
-	mStream = method->getBody();
+	mStream = constructor->getBody();
+	mCurrentFunction = constructor->getPrototype();
 	mRegisters[0] = as_value(global);
 	mGlobalObject = global;
 }
@@ -2629,11 +2622,13 @@
 //This is called by abc_functions to execute their code stream.
 //TODO: There is probably a better way to do this, once we understand what the VM is \
supposed  //todo, this should be fixed.
-as_value Machine::executeFunction(CodeStream* stream, boost::uint32_t maxRegisters, \
const fn_call& fn){ +as_value Machine::executeFunction(asMethod* function, const \
fn_call& fn){  
 //TODO: Figure out a good way to use the State object to handle returning values.
+	mCurrentFunction = function->getPrototype();
 	bool prev_ext = mExitWithReturn;
-	load_function(stream, maxRegisters);
+	CodeStream *stream = function->getBody();
+	load_function(stream, function->getMaxRegisters());
 	mExitWithReturn = true;
 	mRegisters[0] = as_value(fn.this_ptr);
 	for(unsigned int i=0;i<fn.nargs;i++){
@@ -2656,6 +2651,7 @@
 
 	asClass* theClass = mPoolObject->locateClass(className);
 	clearRegisters(theClass->getConstructor()->getMaxRegisters());
+	mCurrentFunction = theClass->getConstructor()->getPrototype();
 	mStack.clear();
 	mScopeStack.clear();
 	mRegisters[0] = as_value(global);
@@ -2688,13 +2684,14 @@
 	}
 
 	LOG_DEBUG_AVM("Cannot find property in scope stack.  Trying again using \
                as_environment.");
-	as_object *target;
+	as_object *target = NULL;
 	as_environment env = as_environment(_vm);
 	std::string name = mPoolObject->mStringPool[multiname.getABCName()];
 	std::string ns = mPoolObject->mStringPool[multiname.getNamespace()->getAbcURI()];
 	std::string path = ns.size() == 0 ? name : ns + "." + name;
 	val = env.get_variable(path,*getScopeStack(),&target);
-	push_stack(as_value(target));
+	LOG_DEBUG_AVM("Got value.");
+	push_stack(as_value(target));	
 	mScopeStack.pop();
 	return val;
 }

=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h	2008-09-28 06:37:27 +0000
+++ b/libcore/vm/Machine.h	2008-09-30 14:02:04 +0000
@@ -207,7 +207,7 @@
 
 	void initMachine(abc_block* pool_block,as_object* global);
 
-	as_value executeFunction(CodeStream* stream, boost::uint32_t maxRegisters, const \
fn_call& fn); +	as_value executeFunction(asMethod* function, const fn_call& fn);
 
 	void instantiateClass(std::string className, as_object* global);
 
@@ -229,7 +229,7 @@
 		as_value *mGlobalReturn;
 		as_object *mThis;
 		std::vector<as_value> mRegisters;
-
+		abc_function* mFunction;
 	void to_debug_string(){
 		LOG_DEBUG_AVM("StackDepth=%u StackTotalSize=%u ScopeStackDepth=%u \
ScopeTotalSize=%u",mStackDepth,mStackTotalSize,mScopeStackDepth,mScopeTotalSize);  
@@ -330,6 +330,8 @@
 	bool mExitWithReturn;
 	abc_block* mPoolObject; // Where all of the pools are stored.
 
+	abc_function* mCurrentFunction;
+
 	VM& _vm;
 };
 



_______________________________________________
Gnash-commit mailing list
Gnash-commit@gnu.org
http://lists.gnu.org/mailman/listinfo/gnash-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic