[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/avm2 r9508: Initial changes to get functio
From: |
Tom Stellard |
Subject: |
[Gnash-commit] /srv/bzr/gnash/avm2 r9508: Initial changes to get function traits to work. |
Date: |
Fri, 22 Aug 2008 11:07:31 +0800 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9508
committer: Tom Stellard <address@hidden>
branch nick: gnash_traits
timestamp: Fri 2008-08-22 11:07:31 +0800
message:
Initial changes to get function traits to work.
modified:
libcore/asClass.cpp
libcore/asClass.h
libcore/parser/abc_block.cpp
libcore/parser/abc_block.h
libcore/swf/DoABCTag.h
libcore/vm/Machine.cpp
=== modified file 'libcore/asClass.cpp'
--- a/libcore/asClass.cpp 2008-08-05 03:45:40 +0000
+++ b/libcore/asClass.cpp 2008-08-22 03:07:31 +0000
@@ -25,6 +25,7 @@
#include "VM.h"
#include "namedStrings.h"
#include "as_value.h"
+#include "abc_function.h"
namespace gnash {
#define STV(x) VM::get().getStringTable().value(x).c_str()
@@ -153,26 +154,27 @@
bool
asMethod::addMethod(string_table::key name, asNamespace* ns, asMethod* method)
{
- string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
- as_value val(method->getPrototype());
-
- mPrototype->init_member(name, val, as_prop_flags::readOnly |
- as_prop_flags::dontDelete | as_prop_flags::dontEnum, nsname);
- return true;
+// string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
+// as_value val(method->getPrototype());
+// as value val = new
as_value(abc_function(asMethod->getBody,mPrototype->getVM().getMachine()));
+// mPrototype->init_member(name, val, as_prop_flags::readOnly |
+// as_prop_flags::dontDelete | as_prop_flags::dontEnum, nsname);
+// return true;
+return false;
}
bool
asClass::addMethod(string_table::key name, asNamespace* ns, asMethod* method,
bool isstatic)
{
- string_table::key nsname = ns ? ns->getURI() : string_table::key(0);
- as_value val(method->getPrototype());
- int flags = as_prop_flags::readOnly | as_prop_flags::dontDelete
- | as_prop_flags::dontEnum;
- if (isstatic)
- flags |= as_prop_flags::staticProp;
+ log_debug("in add method");
+ as_value val = as_value(new
abc_function(method->getBody(),mPrototype->getVM().getMachine()));
+ mPrototype->init_member(name, val);
+// int flags = as_prop_flags::readOnly | as_prop_flags::dontDelete
+// | as_prop_flags::dontEnum;
+// if (isstatic)
+// flags |= as_prop_flags::staticProp;
- mPrototype->init_member(name, val, flags, nsname);
return true;
}
=== modified file 'libcore/asClass.h'
--- a/libcore/asClass.h 2008-08-05 03:02:31 +0000
+++ b/libcore/asClass.h 2008-08-22 03:07:31 +0000
@@ -587,6 +587,8 @@
string_table::key getName() const { return mName; }
+ void initPrototype(){ mPrototype = new as_object();}
+
/// Set our Name
void setName(string_table::key name) { mName = name; }
=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp 2008-08-21 15:15:20 +0000
+++ b/libcore/parser/abc_block.cpp 2008-08-22 03:07:31 +0000
@@ -39,12 +39,14 @@
bool
abc_Trait::finalize(abc_block *pBlock, asClass *pClass, bool do_static)
{
- LOG_DEBUG_ABC("In finalize pClass=%u.",pClass);
+ LOG_DEBUG_ABC("In finalize class name=%s
kind=0x%X",pBlock->mStringPool[pClass->getName()],mKind | 0x0);
switch (mKind)
{
case KIND_SLOT:
case KIND_CONST:
{
+ //TODO: Remove break.
+ break;
// Validate the type.
LOG_DEBUG_ABC("In finalize.A");
asClass *pType;
@@ -79,27 +81,31 @@
}
case KIND_METHOD:
{
- pClass->addMethod(mName, mNamespace, mMethod, do_static);
+ pClass->addMethod(mGlobalName, mNamespace, mMethod, false);
break;
}
case KIND_GETTER:
{
+ break;
pClass->addGetter(mName, mNamespace, mMethod, do_static);
break;
}
case KIND_SETTER:
{
+ break;
pClass->addSetter(mName, mNamespace, mMethod, do_static);
break;
}
case KIND_CLASS:
{
+ break;
pClass->addMemberClass(mName, mNamespace, mSlotId,
pBlock->mClasses[mClassInfoIndex], do_static);
break;
}
case KIND_FUNCTION:
{
+ break;
pClass->addSlotFunction(mName, mNamespace, mSlotId, mMethod,
do_static);
break;
}
@@ -114,6 +120,8 @@
bool
abc_Trait::finalize_mbody(abc_block *pBlock, asMethod *pMethod)
{
+ LOG_DEBUG_ABC("Finalize_mbody doesn't work. Returning.");
+ return true;
switch (mKind)
{
case KIND_SLOT:
@@ -187,12 +195,15 @@
ERR((_("ABC: Trait name must be fully qualified.\n")));
return false;
}
+ asName multiname = pBlock->mMultinamePool[name];
mName = pBlock->mMultinamePool[name].getABCName();
+ mGlobalName = pBlock->mMultinamePool[name].getGlobalName();
mNamespace = pBlock->mMultinamePool[name].getNamespace();
boost::uint8_t kind = in->read_u8();
mKind = static_cast<kinds> (kind & 0x0F);
+ LOG_DEBUG_ABC("Trait kind is 0x%X", kind | 0x0);
switch (mKind)
{
case KIND_SLOT:
@@ -219,6 +230,7 @@
in->skip_V32();
boost::uint32_t moffset = in->read_V32();
+ LOG_DEBUG_ABC("Method index=%u",moffset);
if (moffset >= pBlock->mMethods.size())
{
ERR((_("Bad method id in trait.\n")));
@@ -1000,6 +1012,7 @@
// mMethods[moffset]->setOwner(pClass);
boost::uint32_t tcount = mS->read_V32();
+ LOG_DEBUG_ABC("This class has %u traits.",tcount);
for (unsigned int j = 0; j < tcount; ++j)
{
abc_Trait &aTrait = newTrait();
=== modified file 'libcore/parser/abc_block.h'
--- a/libcore/parser/abc_block.h 2008-08-17 10:08:45 +0000
+++ b/libcore/parser/abc_block.h 2008-08-22 03:07:31 +0000
@@ -69,6 +69,7 @@
boost::uint32_t mClassInfoIndex;
as_value mValue;
string_table::key mName;
+ string_table::key mGlobalName;
asNamespace *mNamespace;
asMethod *mMethod;
bool mValueSet;
=== modified file 'libcore/swf/DoABCTag.h'
--- a/libcore/swf/DoABCTag.h 2008-08-14 17:49:07 +0000
+++ b/libcore/swf/DoABCTag.h 2008-08-22 03:07:31 +0000
@@ -55,6 +55,17 @@
virtual void execute(sprite_instance* m, DisplayList& /* dlist */) const
{
+ std::vector<asClass*>::iterator ci = mABC->mClasses.begin();
+ for(; ci != mABC->mClasses.end(); ++ci){
+ (*ci)->initPrototype();
+ }
+ std::vector<abc_Trait*>::iterator i = mABC->mTraits.begin();
+
+ for ( ; i != mABC->mTraits.end(); ++i)
+ {
+ (*i)->finalize(mABC);
+ }
+ mABC->mTraits.clear();
log_debug("Begin execute abc_block.");
VM& vm = VM::get();
log_debug("getting machine.");
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2008-08-21 17:44:20 +0000
+++ b/libcore/vm/Machine.cpp 2008-08-22 03:07:31 +0000
@@ -26,10 +26,10 @@
#include "fn_call.h"
#include "abc_function.h"
#include "action.h"
+#include "Object.h"
//#define PRETEND
namespace gnash {
-
/// The type of exceptions thrown by ActionScript.
class ASException
{
@@ -1311,16 +1311,16 @@
/// NB: This builds an object from its properties, it's not a constructor.
case SWF::ABC_ACTION_NEWOBJECT:
{
- as_object *obj = new as_object;
+ as_object *obj = new as_object(getObjectInterface());
boost::uint32_t argc = mStream->read_V32();
int i = argc;
while (i--)
{
- obj->set_member(mST.find(mStack.top(i * 2 +
1).to_string()),
- mStack.top(i * 2));
+ as_value val = pop_stack();
+ as_value name = pop_stack();
+ obj->init_member(name.to_string(),val,0,0);
}
- mStack.drop(argc * 2 - 1);
- mStack.top(0) = obj;
+ push_stack(as_value(obj));
break;
}
/// 0x56 ABC_ACTION_NEWARRAY
@@ -1371,7 +1371,7 @@
LOG_DEBUG_AVM("Creating new class id=%u
name=%s",c->getName(),mPoolObject->mStringPool[c->getName()]);
as_object* base_class = pop_stack().to_object().get();
- as_object* new_class = new as_object(base_class);
+ as_object* new_class = c->getPrototype();
//Create the class.
abc_function* constructor = new
abc_function(c->getConstructor()->getBody(),this);
new_class->init_member(NSV::PROP_uuCONSTRUCTORuu,as_value(constructor),0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/avm2 r9508: Initial changes to get function traits to work.,
Tom Stellard <=