[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/avm2 r9544: Fix the build and improve crea
From: |
Tom Stellard |
Subject: |
[Gnash-commit] /srv/bzr/gnash/avm2 r9544: Fix the build and improve creation of object members at parse time. |
Date: |
Thu, 04 Sep 2008 11:34:04 +0800 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9544
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Thu 2008-09-04 11:34:04 +0800
message:
Fix the build and improve creation of object members at parse time.
modified:
libcore/asClass.cpp
libcore/parser/abc_block.cpp
libcore/vm/Machine.cpp
libcore/vm/Machine.h
libcore/vm/VM.cpp
------------------------------------------------------------
revno: 9542.1.1
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Tue 2008-09-02 01:24:52 +0800
message:
Clean up debug messages for abc_parser.
modified:
libcore/asClass.cpp
libcore/parser/abc_block.cpp
------------------------------------------------------------
revno: 9542.1.2
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Tue 2008-09-02 09:46:18 +0800
message:
Fix creation of Constant and Slot properties at parse time.
modified:
libcore/parser/abc_block.cpp
------------------------------------------------------------
revno: 9542.1.3
committer: Tom Stellard <address@hidden>
branch nick: gnash_dev
timestamp: Tue 2008-09-02 10:19:58 +0800
message:
Do not specify a slot value for properties with slot index = 0.
modified:
libcore/asClass.cpp
libcore/parser/abc_block.cpp
=== modified file 'libcore/asClass.cpp'
--- a/libcore/asClass.cpp 2008-08-31 00:41:54 +0000
+++ b/libcore/asClass.cpp 2008-09-02 02:19:58 +0000
@@ -89,7 +89,12 @@
if (isstatic)
flags |= as_prop_flags::staticProp;
- mPrototype->init_member(name, val, flags, nsname, slotId);
+ if(slotId == 0){
+ mPrototype->init_member(name, val, flags, nsname);
+ }
+ else{
+ mPrototype->init_member(name, val, flags, nsname, slotId);
+ }
return true;
}
@@ -148,7 +153,12 @@
// flags |= as_prop_flags::staticProp;
// log_debug("Before init_member.");
//TODO: Set flags.
- mPrototype->init_member(name, as_value(), 0, nsname, slotId);
+ if(slotId == 0){
+ mPrototype->init_member(name,as_value(), 0, nsname);
+ }
+ else{
+ mPrototype->init_member(name, as_value(), 0, nsname, slotId);
+ }
return true;
}
@@ -168,7 +178,6 @@
asClass::addMethod(string_table::key name, asNamespace* ns, asMethod* method,
bool isstatic)
{
- log_debug("in add method");
as_value val = as_value(new
abc_function(method,mPrototype->getVM().getMachine()));
mPrototype->init_member(name, val);
// int flags = as_prop_flags::readOnly | as_prop_flags::dontDelete
=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp 2008-08-31 00:41:54 +0000
+++ b/libcore/parser/abc_block.cpp 2008-09-02 02:19:58 +0000
@@ -39,7 +39,7 @@
bool
abc_Trait::finalize(abc_block *pBlock, asClass *pClass, bool do_static)
{
- LOG_DEBUG_ABC("In finalize class name=%s
kind=0x%X",pBlock->mStringPool[pClass->getName()],mKind | 0x0);
+ LOG_DEBUG_ABC("In finalize class name=%s trait
kind=0x%X",pBlock->mStringPool[pClass->getName()],mKind | 0x0);
switch (mKind)
{
case KIND_SLOT:
@@ -48,7 +48,7 @@
// Validate the type.
asClass *pType;
if (mTypeIndex){
- LOG_DEBUG_ABC("mTypeIndex = %u\n",mTypeIndex);
+ LOG_DEBUG_ABC("Trait type is
%s",pBlock->mStringPool[pBlock->mMultinamePool[mTypeIndex].getABCName()]);
pType =
pBlock->locateClass(pBlock->mMultinamePool[mTypeIndex]);
}
else{
@@ -61,12 +61,13 @@
}
// The name has been validated in read.
if (mHasValue){
- pClass->addValue(mName, mNamespace, mSlotId, pType,
+ LOG_DEBUG_ABC("Adding property=%s with value=%s
slot=%u",pBlock->mStringPool[mName],mValue.toDebugString(),mSlotId);
+ pClass->addValue(mGlobalName, mNamespace, mSlotId,
pType,
mValue, mKind == KIND_CONST, do_static);
}
else{
- LOG_DEBUG_ABC("In finalize.C");
- pClass->addSlot(mName, mNamespace, mSlotId, pType,
+ LOG_DEBUG_ABC("Adding property=%s
slot=%u",pBlock->mStringPool[mName],mSlotId);
+ pClass->addSlot(mGlobalName, mNamespace, mSlotId, pType,
do_static);
}
break;
@@ -78,12 +79,14 @@
}
case KIND_GETTER:
{
+ LOG_DEBUG_ABC("Finalize getter not implemented.");
break;
pClass->addGetter(mName, mNamespace, mMethod, do_static);
break;
}
case KIND_SETTER:
{
+ LOG_DEBUG_ABC("Finalize setter not implemented.");
break;
pClass->addSetter(mName, mNamespace, mMethod, do_static);
break;
@@ -98,6 +101,7 @@
}
case KIND_FUNCTION:
{
+ LOG_DEBUG_ABC("Finalize function not implemented.");
break;
pClass->addSlotFunction(mName, mNamespace, mSlotId, mMethod,
do_static);
break;
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2008-08-31 02:23:49 +0000
+++ b/libcore/vm/Machine.cpp 2008-09-04 03:34:04 +0000
@@ -27,6 +27,7 @@
#include "abc_function.h"
#include "action.h"
#include "Object.h"
+#include "VM.h"
//#define PRETEND
namespace gnash {
@@ -1168,13 +1169,13 @@
asName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
- as_environment env = get_args(argc);
+ std::auto_ptr< std::vector<as_value> > args = get_args(argc);
//TODO: If multiname is runtime also pop namespace and/or name
values.
as_object *object = pop_stack().to_object().get();
as_value property = object->getMember(a.getGlobalName(),0);
LOG_DEBUG_AVM("Calling method %s on object
%s",property.toDebugString(),object->get_text_value());
- as_value result =
call_method(property,&env,object,argc,env.stack_size() - 1);
- env.drop(argc);
+ as_environment env = as_environment(_vm);
+ as_value result = call_method(property,&env,object,args);
if(opcode == SWF::ABC_ACTION_CALLPROPERTY){
push_stack(result);
@@ -1290,12 +1291,13 @@
// TODO
asName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
- as_environment env = get_args(argc);
+ std::auto_ptr< std::vector<as_value> > args = get_args(argc);
as_object* object = pop_stack().to_object().get();
as_value prop =
object->getMember(a.getGlobalName(),a.getNamespace()->getURI());
as_object* object_to_construct = prop.to_object().get();
as_value property =
object_to_construct->getMember(NSV::PROP_CONSTRUCTOR,0);
- as_value value =
call_method(property,&env,object_to_construct,argc,env.stack_size() - 1);
+ as_environment env = as_environment(_vm);
+ as_value value =
call_method(property,&env,object_to_construct,args);
push_stack(value);
break;
@@ -1384,9 +1386,9 @@
push_stack(as_value(new_class));
//Call the class's static constructor.
- as_environment env;
+ as_environment env = as_environment(_vm);
as_value property =
new_class->getMember(NSV::PROP_uuCONSTRUCTORuu,0);
- as_value value = call_method(property,&env,new_class,0,-1);
+ as_value value =
call_method(property,&env,new_class,get_args(0));
break;
}
@@ -2653,9 +2655,9 @@
executeCodeblock(theClass->getConstructor()->getBody());
}
-Machine::Machine(string_table &ST, ClassHierarchy
*CH):mST(),mRegisters(),mExitWithReturn(false)
+Machine::Machine(VM& vm):mST(),mRegisters(),mExitWithReturn(false),_vm(vm)
{
- mCH = CH;
+ mCH = vm.getClassHierarchy();
//Local registers should be initialized at the beginning of each
function call, but
//we don't currently parse the number of local registers for each
function.
mRegisters.resize(16);
=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h 2008-08-31 03:02:37 +0000
+++ b/libcore/vm/Machine.h 2008-09-04 03:34:04 +0000
@@ -26,6 +26,7 @@
#include "asClass.h"
#include "swf.h"
#include "as_environment.h"
+#include "VM.h"
#define LOG_DEBUG_AVM(fmt,...) IF_VERBOSE_ACTION(log_action("AVM2: " fmt, ##
__VA_ARGS__));
@@ -210,7 +211,7 @@
void instantiateClass(std::string className);
- Machine(string_table &ST, ClassHierarchy *CH);
+ Machine(VM& vm);
private:
/// The state of the machine.
@@ -298,7 +299,7 @@
}
print_scope_stack();
LOG_DEBUG_AVM("Cannot find property in scope stack.");
- as_environment env;
+ as_environment env = as_environment(_vm);
as_object* obj =
env.find_object(mPoolObject->mStringPool[multiname.getNamespace()->getAbcURI()],getScopeStack());
push_stack(as_value(obj));
}
@@ -324,7 +325,7 @@
as_value get_property_value(boost::intrusive_ptr<as_object> obj, asName
multiname){
as_environment::ScopeStack stack;
- as_environment env;
+ as_environment env = as_environment(_vm);
if(obj == NULL){
stack = *getScopeStack();
}
@@ -339,6 +340,7 @@
else{
path = ns + "." +
mPoolObject->mStringPool[multiname.getABCName()];
}
+
return env.get_variable(path,stack,NULL);
}
@@ -366,13 +368,13 @@
LOG_DEBUG_AVM("%s", ss.str());
}
- as_environment get_args(unsigned int argc){
+ std::auto_ptr< std::vector<as_value> > get_args(unsigned int argc){
LOG_DEBUG_AVM("There are %u args",argc);
- as_environment env;
+ std::auto_ptr< std::vector<as_value> > args = std::auto_ptr<
std::vector<as_value> >(new std::vector<as_value>);
for(unsigned int i=0;i<argc;i++){
- env.push(pop_stack());
+ args->push_back(pop_stack());
}
- return env;
+ return args;
}
void load_function(CodeStream* stream){
@@ -415,6 +417,8 @@
bool mIsAS3; // Is the stream an AS3 stream.
bool mExitWithReturn;
abc_block* mPoolObject; // Where all of the pools are stored.
+
+ VM& _vm;
};
} // namespace gnash
=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2008-09-01 21:25:03 +0000
+++ b/libcore/vm/VM.cpp 2008-09-04 03:34:04 +0000
@@ -65,7 +65,7 @@
_singleton->mClassHierarchy = new ClassHierarchy;
_singleton->setGlobal(new Global(*_singleton,
_singleton->mClassHierarchy));
/*?Ask someone if this is correct.*/
- _singleton->mMachine = new
Machine(_singleton->mStringTable,_singleton->mClassHierarchy);
+ _singleton->mMachine = new Machine(*_singleton);
assert(_singleton->getGlobal());
/*ASK*/
return *_singleton;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/avm2 r9544: Fix the build and improve creation of object members at parse time.,
Tom Stellard <=