[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11203: AS3 classes are not function
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11203: AS3 classes are not functions, but become global objects with a constructor |
Date: |
Mon, 06 Jul 2009 11:45:21 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11203
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-07-06 11:45:21 +0200
message:
AS3 classes are not functions, but become global objects with a constructor
function. Implement MovieClip more like this (it may be more correct to
use the MovieClip prototype object) as an example; more testing and
improvement is needed before this is done everywhere.
CONSTRUCTSUPER now looks for the constructor function, which fixes behaviour
for built-in class. Eventually CONSTRUCTSUPER and CONSTRUCTPROP opcodes
should only do this, and not expect properties to be a constructor function
at all.
modified:
libcore/ClassHierarchy.cpp
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/asobj/flash/ui/Keyboard_as.cpp
libcore/vm/Machine.cpp
libcore/vm/Machine.h
testsuite/as3compile.all/MovieClip.as
testsuite/as3compile.all/class.as
------------------------------------------------------------
revno: 11202.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:13:44 +0200
message:
Object prototypes appear never to be functions in AS3 (unlike AS2), so
always use the constructor property in CONSTRUCTSUPER.
modified:
libcore/vm/Machine.cpp
------------------------------------------------------------
revno: 11202.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:14:31 +0200
message:
Passing inheritance tests, some new tests.
modified:
testsuite/as3compile.all/class.as
------------------------------------------------------------
revno: 11202.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:28:38 +0200
message:
Drop unused and obsolete functions.
modified:
libcore/vm/Machine.cpp
libcore/vm/Machine.h
------------------------------------------------------------
revno: 11202.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:30:15 +0200
message:
The Machine has no as_environment::ScopeStack any more.
modified:
libcore/vm/Machine.cpp
libcore/vm/Machine.h
------------------------------------------------------------
revno: 11202.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:32:36 +0200
message:
Rename variables.
modified:
libcore/vm/Machine.cpp
libcore/vm/Machine.h
------------------------------------------------------------
revno: 11202.1.6
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:36:45 +0200
message:
Check inheritance from built-in MovieClip class.
modified:
testsuite/as3compile.all/MovieClip.as
------------------------------------------------------------
revno: 11202.1.7
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 08:59:34 +0200
message:
Clean up, comment.
modified:
libcore/vm/Machine.cpp
------------------------------------------------------------
revno: 11202.1.8
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 09:05:26 +0200
message:
Drop debugging.
modified:
libcore/vm/Machine.cpp
------------------------------------------------------------
revno: 11202.1.9
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 09:25:38 +0200
message:
Don't use VM singleton unnecessarily.
modified:
libcore/ClassHierarchy.cpp
------------------------------------------------------------
revno: 11202.1.10
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 09:30:29 +0200
message:
Drop all the unnecessary stuff from Keyboard_as.
modified:
libcore/asobj/flash/ui/Keyboard_as.cpp
------------------------------------------------------------
revno: 11202.1.11
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 09:50:10 +0200
message:
Make AS3 MovieClip class a prototype object with ctor, not a function.
modified:
libcore/asobj/flash/display/MovieClip_as.cpp
------------------------------------------------------------
revno: 11202.1.12
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 11:15:43 +0200
message:
More tests for MovieClip.
modified:
testsuite/as3compile.all/MovieClip.as
------------------------------------------------------------
revno: 11202.1.13
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Mon 2009-07-06 11:28:29 +0200
message:
Test passes.
modified:
testsuite/as3compile.all/MovieClip.as
testsuite/as3compile.all/class.as
=== modified file 'libcore/ClassHierarchy.cpp'
--- a/libcore/ClassHierarchy.cpp 2009-07-01 12:20:58 +0000
+++ b/libcore/ClassHierarchy.cpp 2009-07-06 07:25:38 +0000
@@ -143,9 +143,9 @@
//init_member("constructor",
as_function::getFunctionConstructor().get());
}
- virtual as_value operator()(const fn_call& /*fn*/)
+ virtual as_value operator()(const fn_call& fn)
{
- string_table& st = VM::get().getStringTable();
+ string_table& st = fn.getVM().getStringTable();
log_debug("Loading native class %s", st.value(mDeclaration.name));
mDeclaration.initializer(*mTarget);
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2009-07-03 08:44:41
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2009-07-06 07:50:10
+0000
@@ -125,18 +125,15 @@
{
if (isAS3(where.getVM())) {
- static boost::intrusive_ptr<builtin_function> cl;
-
- if (!cl) {
- cl = new builtin_function(&movieclip_as3_ctor,
- getMovieClipAS3Interface());
-
- where.getVM().addStatic(cl.get());
- }
+ static boost::intrusive_ptr<as_object> cl =
+ new as_object(getMovieClipAS3Interface());
- log_debug("AVM2 MovieClip, ctor %s", cl.get());
-
- where.init_member("MovieClip", cl.get());
+ cl->init_member(NSV::PROP_CONSTRUCTOR,
+ new builtin_function(movieclip_as3_ctor));
+
+ log_debug("AVM2 MovieClip, proto %s", cl);
+
+ where.init_member("MovieClip", cl);
return;
}
=== modified file 'libcore/asobj/flash/ui/Keyboard_as.cpp'
--- a/libcore/asobj/flash/ui/Keyboard_as.cpp 2009-06-08 21:40:22 +0000
+++ b/libcore/asobj/flash/ui/Keyboard_as.cpp 2009-07-06 07:30:29 +0000
@@ -37,64 +37,6 @@
namespace gnash {
-// Forward declarations
-namespace {
- as_value keyboard_BACKSPACE(const fn_call& fn);
- as_value keyboard_C(const fn_call& fn);
- as_value keyboard_CAPS_LOCK(const fn_call& fn);
- as_value keyboard_CONTROL(const fn_call& fn);
- as_value keyboard_DELETE(const fn_call& fn);
- as_value keyboard_DOWN(const fn_call& fn);
- as_value keyboard_END(const fn_call& fn);
- as_value keyboard_ENTER(const fn_call& fn);
- as_value keyboard_ESCAPE(const fn_call& fn);
- as_value keyboard_F1(const fn_call& fn);
- as_value keyboard_F10(const fn_call& fn);
- as_value keyboard_F11(const fn_call& fn);
- as_value keyboard_F12(const fn_call& fn);
- as_value keyboard_F13(const fn_call& fn);
- as_value keyboard_F14(const fn_call& fn);
- as_value keyboard_F15(const fn_call& fn);
- as_value keyboard_F2(const fn_call& fn);
- as_value keyboard_F3(const fn_call& fn);
- as_value keyboard_F4(const fn_call& fn);
- as_value keyboard_F5(const fn_call& fn);
- as_value keyboard_F6(const fn_call& fn);
- as_value keyboard_F7(const fn_call& fn);
- as_value keyboard_F8(const fn_call& fn);
- as_value keyboard_F9(const fn_call& fn);
- as_value keyboard_G(const fn_call& fn);
- as_value keyboard_HOME(const fn_call& fn);
- as_value keyboard_INSERT(const fn_call& fn);
- as_value keyboard_LEFT(const fn_call& fn);
- as_value keyboard_NUMPAD_0(const fn_call& fn);
- as_value keyboard_NUMPAD_1(const fn_call& fn);
- as_value keyboard_NUMPAD_2(const fn_call& fn);
- as_value keyboard_NUMPAD_3(const fn_call& fn);
- as_value keyboard_NUMPAD_4(const fn_call& fn);
- as_value keyboard_NUMPAD_5(const fn_call& fn);
- as_value keyboard_NUMPAD_6(const fn_call& fn);
- as_value keyboard_NUMPAD_7(const fn_call& fn);
- as_value keyboard_NUMPAD_8(const fn_call& fn);
- as_value keyboard_NUMPAD_9(const fn_call& fn);
- as_value keyboard_NUMPAD_ADD(const fn_call& fn);
- as_value keyboard_NUMPAD_DECIMAL(const fn_call& fn);
- as_value keyboard_NUMPAD_DIVIDE(const fn_call& fn);
- as_value keyboard_NUMPAD_ENTER(const fn_call& fn);
- as_value keyboard_NUMPAD_MULTIPLY(const fn_call& fn);
- as_value keyboard_NUMPAD_SUBTRACT(const fn_call& fn);
- as_value keyboard_PAGE_DOWN(const fn_call& fn);
- as_value keyboard_PAGE_UP(const fn_call& fn);
- as_value keyboard_RIGHT(const fn_call& fn);
- as_value keyboard_SHIFT(const fn_call& fn);
- as_value keyboard_SPACE(const fn_call& fn);
- as_value keyboard_TAB(const fn_call& fn);
- as_value keyboard_UP(const fn_call& fn);
- as_value keyboard_ctor(const fn_call& fn);
- void attachKeyboardInterface(as_object& o);
- as_object* getKeyboardInterface();
-}
-
Keyboard_as::Keyboard_as()
:
as_object(getObjectInterface()),
@@ -335,595 +277,6 @@
global.init_member("Key", key_obj);
}
-namespace {
-
-void
-attachKeyboardInterface(as_object& o)
-{
- o.init_member("BACKSPACE", new builtin_function(keyboard_BACKSPACE));
- o.init_member("C", new builtin_function(keyboard_C));
- o.init_member("CAPS_LOCK", new builtin_function(keyboard_CAPS_LOCK));
- o.init_member("CONTROL", new builtin_function(keyboard_CONTROL));
- o.init_member("DELETE", new builtin_function(keyboard_DELETE));
- o.init_member("DOWN", new builtin_function(keyboard_DOWN));
- o.init_member("END", new builtin_function(keyboard_END));
- o.init_member("ENTER", new builtin_function(keyboard_ENTER));
- o.init_member("ESCAPE", new builtin_function(keyboard_ESCAPE));
- o.init_member("F1", new builtin_function(keyboard_F1));
- o.init_member("F10", new builtin_function(keyboard_F10));
- o.init_member("F11", new builtin_function(keyboard_F11));
- o.init_member("F12", new builtin_function(keyboard_F12));
- o.init_member("F13", new builtin_function(keyboard_F13));
- o.init_member("F14", new builtin_function(keyboard_F14));
- o.init_member("F15", new builtin_function(keyboard_F15));
- o.init_member("F2", new builtin_function(keyboard_F2));
- o.init_member("F3", new builtin_function(keyboard_F3));
- o.init_member("F4", new builtin_function(keyboard_F4));
- o.init_member("F5", new builtin_function(keyboard_F5));
- o.init_member("F6", new builtin_function(keyboard_F6));
- o.init_member("F7", new builtin_function(keyboard_F7));
- o.init_member("F8", new builtin_function(keyboard_F8));
- o.init_member("F9", new builtin_function(keyboard_F9));
- o.init_member("G", new builtin_function(keyboard_G));
- o.init_member("HOME", new builtin_function(keyboard_HOME));
- o.init_member("INSERT", new builtin_function(keyboard_INSERT));
- o.init_member("LEFT", new builtin_function(keyboard_LEFT));
- o.init_member("NUMPAD_0", new builtin_function(keyboard_NUMPAD_0));
- o.init_member("NUMPAD_1", new builtin_function(keyboard_NUMPAD_1));
- o.init_member("NUMPAD_2", new builtin_function(keyboard_NUMPAD_2));
- o.init_member("NUMPAD_3", new builtin_function(keyboard_NUMPAD_3));
- o.init_member("NUMPAD_4", new builtin_function(keyboard_NUMPAD_4));
- o.init_member("NUMPAD_5", new builtin_function(keyboard_NUMPAD_5));
- o.init_member("NUMPAD_6", new builtin_function(keyboard_NUMPAD_6));
- o.init_member("NUMPAD_7", new builtin_function(keyboard_NUMPAD_7));
- o.init_member("NUMPAD_8", new builtin_function(keyboard_NUMPAD_8));
- o.init_member("NUMPAD_9", new builtin_function(keyboard_NUMPAD_9));
- o.init_member("NUMPAD_ADD", new builtin_function(keyboard_NUMPAD_ADD));
- o.init_member("NUMPAD_DECIMAL", new
builtin_function(keyboard_NUMPAD_DECIMAL));
- o.init_member("NUMPAD_DIVIDE", new
builtin_function(keyboard_NUMPAD_DIVIDE));
- o.init_member("NUMPAD_ENTER", new builtin_function(keyboard_NUMPAD_ENTER));
- o.init_member("NUMPAD_MULTIPLY", new
builtin_function(keyboard_NUMPAD_MULTIPLY));
- o.init_member("NUMPAD_SUBTRACT", new
builtin_function(keyboard_NUMPAD_SUBTRACT));
- o.init_member("PAGE_DOWN", new builtin_function(keyboard_PAGE_DOWN));
- o.init_member("PAGE_UP", new builtin_function(keyboard_PAGE_UP));
- o.init_member("RIGHT", new builtin_function(keyboard_RIGHT));
- o.init_member("SHIFT", new builtin_function(keyboard_SHIFT));
- o.init_member("SPACE", new builtin_function(keyboard_SPACE));
- o.init_member("TAB", new builtin_function(keyboard_TAB));
- o.init_member("UP", new builtin_function(keyboard_UP));
-}
-
-
-as_object*
-getKeyboardInterface()
-{
- static boost::intrusive_ptr<as_object> o;
- if ( ! o ) {
- o = new as_object();
- attachKeyboardInterface(*o);
- }
- return o.get();
-}
-
-as_value
-keyboard_BACKSPACE(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_C(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_CAPS_LOCK(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_CONTROL(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_DELETE(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_DOWN(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_END(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_ENTER(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_ESCAPE(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F1(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F10(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F11(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F12(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F13(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F14(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F15(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F2(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F3(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F4(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F5(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F6(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F7(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F8(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_F9(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_G(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_HOME(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_INSERT(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_LEFT(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_0(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_1(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_2(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_3(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_4(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_5(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_6(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_7(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_8(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_9(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_ADD(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_DECIMAL(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_DIVIDE(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_ENTER(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_MULTIPLY(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_NUMPAD_SUBTRACT(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_PAGE_DOWN(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_PAGE_UP(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_RIGHT(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_SHIFT(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_SPACE(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_TAB(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_UP(const fn_call& fn)
-{
- boost::intrusive_ptr<Keyboard_as> ptr =
- ensureType<Keyboard_as>(fn.this_ptr);
- UNUSED(ptr);
- log_unimpl (__FUNCTION__);
- return as_value();
-}
-
-as_value
-keyboard_ctor(const fn_call& fn)
-{
- boost::intrusive_ptr<as_object> obj = new Keyboard_as;
-
- return as_value(obj.get()); // will keep alive
-}
-
-} // anonymous namespace
} // gnash namespace
// local Variables:
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2009-07-03 08:19:37 +0000
+++ b/libcore/vm/Machine.cpp 2009-07-06 07:05:26 +0000
@@ -313,9 +313,9 @@
Machine::Machine(VM& vm)
:
- mStack(),
+ _stack(),
_registers(),
- mScopeStack(),
+ _scopeStack(),
mStream(0),
mST(vm.getStringTable()),
mDefaultXMLNamespace(0),
@@ -386,7 +386,7 @@
/// Equivalent: ACTIONTHROW
case SWF::ABC_ACTION_THROW:
{
- throw ASException(mStack.pop());
+ throw ASException(_stack.pop());
break;
}
@@ -405,12 +405,12 @@
// Get the name.
asName a = pool_name(mStream->read_V32(), mPoolObject);
// Finish it, if necessary.
- mStack.drop(completeName(a));
+ _stack.drop(completeName(a));
// Get the target object.
- ENSURE_OBJECT(mStack.top(0));
+ ENSURE_OBJECT(_stack.top(0));
// Use get_super?
- as_object *super = mStack.top(0).to_object()->
+ as_object *super = _stack.top(0).to_object()->
get_prototype().get();
// If we don't have a super, throw.
@@ -418,7 +418,7 @@
Property *b = super->findProperty(a.getABCName(),
a.getNamespace()->getURI());
// The object is on the top already.
- pushGet(super, mStack.top(0), b);
+ pushGet(super, _stack.top(0), b);
break;
}
@@ -435,19 +435,19 @@
{
// Get and finish the name.
asName a = pool_name(mStream->read_V32(), mPoolObject);
- as_value vobj = mStack.pop(); // The value
-
- mStack.drop(completeName(a));
-
- ENSURE_OBJECT(mStack.top(0));
+ as_value vobj = _stack.pop(); // The value
+
+ _stack.drop(completeName(a));
+
+ ENSURE_OBJECT(_stack.top(0));
// Use get_super?
- as_object* super = mStack.pop().to_object()->
+ as_object* super = _stack.pop().to_object()->
get_prototype().get();
if (!super) throw ASReferenceError();
Property* b = super->findProperty(a.getABCName(),
a.getNamespace()->getURI());
- mStack.push(vobj);
+ _stack.push(vobj);
pushSet(super, vobj, b);
break;
}
@@ -476,12 +476,12 @@
/// not the stream.
case SWF::ABC_ACTION_DXNSLATE:
{
- ENSURE_STRING(mStack.top(0));
- const std::string& uri = mStack.top(0).to_string();
+ ENSURE_STRING(_stack.top(0));
+ const std::string& uri = _stack.top(0).to_string();
ClassHierarchy& ch = _global->classHierarchy();
mDefaultXMLNamespace = ch.anonNamespace(mST.find(uri));
- mStack.drop(1);
+ _stack.drop(1);
break;
}
@@ -516,9 +516,9 @@
case SWF::ABC_ACTION_IFNLT:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(1), mStack.top(0),
+ ABSTRACT_COMPARE(truth, _stack.top(1), _stack.top(0),
false);
- mStack.drop(2);
+ _stack.drop(2);
JUMPIF(!truth); // truth is: a < b
break;
}
@@ -535,8 +535,8 @@
case SWF::ABC_ACTION_IFNLE:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
true);
- mStack.drop(2);
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
true);
+ _stack.drop(2);
JUMPIF(truth); // truth is: b < a
break;
}
@@ -553,9 +553,9 @@
case SWF::ABC_ACTION_IFNGT:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
false);
- mStack.drop(2);
+ _stack.drop(2);
JUMPIF(!truth); // truth is: b < a
break;
}
@@ -572,8 +572,8 @@
case SWF::ABC_ACTION_IFNGE:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(1), mStack.top(0),
true);
- mStack.drop(2);
+ ABSTRACT_COMPARE(truth, _stack.top(1), _stack.top(0),
true);
+ _stack.drop(2);
JUMPIF(truth); // truth is: a < b
break;
}
@@ -718,8 +718,8 @@
case SWF::ABC_ACTION_IFLE:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
true);
- mStack.drop(2);
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
true);
+ _stack.drop(2);
JUMPIF(!truth); // truth is: b < a
break;
}
@@ -737,8 +737,8 @@
boost::int32_t bytes = mStream->read_S24();
bool truth;
// If b < a, then a > b, with undefined as false
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
false);
- mStack.drop(2);
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
false);
+ _stack.drop(2);
if (truth) {
log_abc("Jumping %d bytes.",bytes);
mStream->seekBy(bytes);
@@ -761,8 +761,8 @@
case SWF::ABC_ACTION_IFGE:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
true);
- mStack.drop(2);
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
true);
+ _stack.drop(2);
JUMPIF(!truth); // truth is: a < b
break;
}
@@ -778,9 +778,9 @@
/// ABC_ACTION_JUMP
case SWF::ABC_ACTION_IFSTRICTEQ:
{
- bool truth = abstractEquality(mStack.top(1), mStack.top(0),
+ bool truth = abstractEquality(_stack.top(1), _stack.top(0),
true);
- mStack.drop(2);
+ _stack.drop(2);
JUMPIF(truth);
break;
}
@@ -796,9 +796,9 @@
/// ABC_ACTION_JUMP
case SWF::ABC_ACTION_IFSTRICTNE:
{
- const bool truth = abstractEquality(mStack.top(1),
- mStack.top(0), true);
- mStack.drop(2);
+ const bool truth = abstractEquality(_stack.top(1),
+ _stack.top(0), true);
+ _stack.drop(2);
JUMPIF(!truth);
break;
}
@@ -816,11 +816,11 @@
case SWF::ABC_ACTION_LOOKUPSWITCH:
{
std::size_t npos = mStream->tellg();
- if (!mStack.top(0).is_number()) throw ASException();
+ if (!_stack.top(0).is_number()) throw ASException();
boost::uint32_t index =
- mStack.top(0).to_number<boost::uint32_t>();
- mStack.drop(1);
+ _stack.top(0).to_number<boost::uint32_t>();
+ _stack.drop(1);
mStream->seekBy(3); // Skip the intial offset.
boost::uint32_t cases = mStream->read_V32();
@@ -864,25 +864,25 @@
{
log_unimpl("ABC_ACTION_PUSHWITH");
// A scope object is just a regular object.
- // ENSURE_OBJECT(mStack.top(0));
- // as_object *a = mStack.top(0).to_object().get();
+ // ENSURE_OBJECT(_stack.top(0));
+ // as_object *a = _stack.top(0).to_object().get();
//
- // if (!mScopeStack.empty())
- //
a->set_prototype(mScopeStack.top(0).mScope);
+ // if (!_scopeStack.empty())
+ //
a->set_prototype(_scopeStack.top(0).mScope);
// else
// a->set_prototype(NULL);
//
// if (opcode == SWF::ABC_ACTION_PUSHWITH &&
- // mScopeStack.totalSize() ==
mScopeStack.size())
+ // _scopeStack.totalSize() ==
_scopeStack.size())
// {
- // mScopeStack.push(Scope(0, a));
+ // _scopeStack.push(Scope(0, a));
// }
// else
// {
- //
mScopeStack.push(Scope(mScopeStack.size(), a));
+ //
_scopeStack.push(Scope(_scopeStack.size(), a));
// }
// mCurrentScope = a;
- // mStack.drop(1);
+ // _stack.drop(1);
break;
}
@@ -903,24 +903,24 @@
/// name -- the key name of the property at index in obj
case SWF::ABC_ACTION_NEXTNAME:
{
- ENSURE_NUMBER(mStack.top(0));
- ENSURE_OBJECT(mStack.top(1));
- as_object *obj = mStack.top(1).to_object().get();
+ ENSURE_NUMBER(_stack.top(0));
+ ENSURE_OBJECT(_stack.top(1));
+ as_object *obj = _stack.top(1).to_object().get();
const boost::uint32_t index =
- mStack.top(0).to_number<boost::uint32_t>();
+ _stack.top(0).to_number<boost::uint32_t>();
if (!obj) {
// TODO: check what to do here.
log_debug("ABC_ACTION_NEXTNAME: expecting object on "
- "stack, got %s", mStack.top(1));
- mStack.drop(2);
+ "stack, got %s", _stack.top(1));
+ _stack.drop(2);
break;
}
- mStack.drop(1);
+ _stack.drop(1);
const Property *b = obj->getByIndex(index);
- if (b) mStack.top(0) = mST.value(b->getName());
- else mStack.top(0) = "";
+ if (b) _stack.top(0) = mST.value(b->getName());
+ else _stack.top(0) = "";
break;
}
@@ -935,14 +935,14 @@
/// this directly.
case SWF::ABC_ACTION_HASNEXT:
{
- ENSURE_NUMBER(mStack.top(0));
- ENSURE_OBJECT(mStack.top(1));
- as_object *obj = mStack.top(1).to_object().get();
+ ENSURE_NUMBER(_stack.top(0));
+ ENSURE_OBJECT(_stack.top(1));
+ as_object *obj = _stack.top(1).to_object().get();
boost::uint32_t index =
- mStack.top(0).to_number<boost::uint32_t>();
- mStack.drop(1);
+ _stack.top(0).to_number<boost::uint32_t>();
+ _stack.drop(1);
assert(obj);
- mStack.top(0) = obj->nextIndex(index);
+ _stack.top(0) = obj->nextIndex(index);
break;
}
@@ -962,8 +962,8 @@
/// n -- an Undefined object.
case SWF::ABC_ACTION_PUSHUNDEFINED:
{
- mStack.grow(1);
- mStack.top(0).set_undefined();
+ _stack.grow(1);
+ _stack.top(0).set_undefined();
break;
}
@@ -975,17 +975,17 @@
/// value -- the value of the key value pair in obj at index.
case SWF::ABC_ACTION_NEXTVALUE:
{
- ENSURE_NUMBER(mStack.top(0));
- ENSURE_OBJECT(mStack.top(1));
- as_object *obj = mStack.top(1).to_object().get();
+ ENSURE_NUMBER(_stack.top(0));
+ ENSURE_OBJECT(_stack.top(1));
+ as_object *obj = _stack.top(1).to_object().get();
const boost::uint32_t index =
- mStack.top(0).to_number<boost::uint32_t>();
+ _stack.top(0).to_number<boost::uint32_t>();
const Property *b = obj->getByIndex(index);
- mStack.drop(1);
- if (!b) mStack.top(0).set_undefined();
+ _stack.drop(1);
+ if (!b) _stack.top(0).set_undefined();
else {
- mStack.drop(1);
- pushGet(obj, mStack.top(0), const_cast<Property*>(b));
+ _stack.drop(1);
+ pushGet(obj, _stack.top(0), const_cast<Property*>(b));
}
break;
}
@@ -1017,8 +1017,8 @@
/// Stack Out:
/// true -- the True object
case SWF::ABC_ACTION_PUSHTRUE:
- mStack.grow(1);
- mStack.top(0).set_bool(true);
+ _stack.grow(1);
+ _stack.top(0).set_bool(true);
break;
/// 0x27 ABC_ACTION_PUSHFALSE
@@ -1032,8 +1032,8 @@
/// Stack Out:
/// NaN -- the NaN object
case SWF::ABC_ACTION_PUSHNAN:
- mStack.grow(1);
- mStack.top(0).set_nan();
+ _stack.grow(1);
+ _stack.top(0).set_nan();
break;
/// 0x29 ABC_ACTION_POP
@@ -1052,8 +1052,8 @@
/// a
/// a
case SWF::ABC_ACTION_DUP:
- mStack.grow(1);
- mStack.top(0) = mStack.top(1);
+ _stack.grow(1);
+ _stack.top(0) = _stack.top(1);
break;
/// 0x2B ABC_ACTION_SWAP
@@ -1065,9 +1065,9 @@
/// a
case SWF::ABC_ACTION_SWAP:
{
- as_value inter = mStack.top(0);
- mStack.top(0) = mStack.top(1);
- mStack.top(1) = inter;
+ as_value inter = _stack.top(0);
+ _stack.top(0) = _stack.top(1);
+ _stack.top(1) = inter;
break;
}
@@ -1093,8 +1093,8 @@
/// value -- Unsigned Integer object from
unsigned_integer_pool[index]
case SWF::ABC_ACTION_PUSHUINT:
{
- mStack.grow(1);
- mStack.top(0) = pool_uint(mStream->read_V32(),
mPoolObject);
+ _stack.grow(1);
+ _stack.top(0) = pool_uint(mStream->read_V32(),
mPoolObject);
break;
}
@@ -1116,8 +1116,8 @@
{
asNamespace *ns = pool_namespace(mStream->read_V32(),
mPoolObject);
- mStack.grow(1);
- mStack.top(0) = *ns;
+ _stack.grow(1);
+ _stack.top(0) = *ns;
break;
}
@@ -1208,19 +1208,19 @@
case SWF::ABC_ACTION_CALL:
{
boost::uint32_t argc = mStream->read_V32();
- ENSURE_OBJECT(mStack.top(argc + 1)); // The func
- ENSURE_OBJECT(mStack.top(argc)); // The 'this'
- as_function *f = mStack.top(argc + 1).to_as_function();
- as_object *obj = mStack.top(argc).to_object().get();
+ ENSURE_OBJECT(_stack.top(argc + 1)); // The func
+ ENSURE_OBJECT(_stack.top(argc)); // The 'this'
+ as_function *f = _stack.top(argc + 1).to_as_function();
+ as_object *obj = _stack.top(argc).to_object().get();
// We start with argc + 2 values related to this call
// on the stack. We want to end with 1 value. We pass
// argc values (the parameters), so we need to drop
// one more than we pass and store the return just
// below that one. Thus:
- // return is mStack.top(argc + 1)
+ // return is _stack.top(argc + 1)
// bottom of arguments is argc deep
// drop 1 more value than is passed, on return
- pushCall(f, obj, mStack.top(argc + 1), argc, -1);
+ pushCall(f, obj, _stack.top(argc + 1), argc, -1);
break;
}
@@ -1235,13 +1235,13 @@
case SWF::ABC_ACTION_CONSTRUCT:
{
boost::uint32_t argc = mStream->read_V32();
- as_function *f = mStack.top(argc).to_as_function();
+ as_function *f = _stack.top(argc).to_as_function();
if (!f) {
log_abc("CONSTRUCT: No function on stack!");
break;
}
Property b(0, 0, f, NULL);
- pushCall(f, NULL, mStack.top(argc), argc, 0);
+ pushCall(f, NULL, _stack.top(argc), argc, 0);
break;
}
@@ -1257,8 +1257,8 @@
{
boost::uint32_t dispatch_id = mStream->read_V32() - 1;
boost::uint32_t argc = mStream->read_V32();
- ENSURE_OBJECT(mStack.top(argc));
- as_object *obj = mStack.top(argc).to_object().get();
+ ENSURE_OBJECT(_stack.top(argc));
+ as_object *obj = _stack.top(argc).to_object().get();
const Property *f = obj->getByIndex(dispatch_id);
as_function* func;
#if 0
@@ -1276,7 +1276,7 @@
// Definitely an error, and not the kind we can handle.
throw ASException();
}
- pushCall(func, obj, mStack.top(argc), argc, 0);
+ pushCall(func, obj, _stack.top(argc), argc, 0);
break;
}
@@ -1293,9 +1293,9 @@
asMethod *m = pool_method(mStream->read_V32(),
mPoolObject);
boost::uint32_t argc = mStream->read_V32();
as_function *func = m->getPrototype();
- ENSURE_OBJECT(mStack.top(argc));
- as_object *obj = mStack.top(argc).to_object().get();
- pushCall(func, obj, mStack.top(argc), argc, 0);
+ ENSURE_OBJECT(_stack.top(argc));
+ as_object *obj = _stack.top(argc).to_object().get();
+ pushCall(func, obj, _stack.top(argc), argc, 0);
break;
}
/// 0x45 ABC_ACTION_CALLSUPER
@@ -1315,12 +1315,12 @@
asName a = pool_name(mStream->read_V32(), mPoolObject);
boost::uint32_t argc = mStream->read_V32();
int dropsize = completeName(a);
- ENSURE_OBJECT(mStack.top(argc + dropsize));
- mStack.drop(dropsize);
+ ENSURE_OBJECT(_stack.top(argc + dropsize));
+ _stack.drop(dropsize);
// Why get_super() here and get_prototype everywhere else?
as_object* super =
- mStack.top(argc).to_object()->get_super();
+ _stack.top(argc).to_object()->get_super();
if (!super) throw ASReferenceError();
@@ -1333,7 +1333,7 @@
b->getValue(super).to_as_function();
if (opcode == SWF::ABC_ACTION_CALLSUPER) {
- pushCall(f, super, mStack.top(argc), argc, 0);
+ pushCall(f, super, _stack.top(argc), argc, 0);
}
else {
// Void call
@@ -1368,11 +1368,11 @@
get_args(argc);
if (a.isRuntime()) {
- mStack.drop(completeName(a));
+ _stack.drop(completeName(a));
}
log_abc("CALL_PROP*: calling property %s of object %s",
- mST.value(a.getGlobalName()), mStack.top(0));
+ mST.value(a.getGlobalName()), _stack.top(0));
as_value object_val = pop_stack();
@@ -1408,8 +1408,8 @@
}
/* int shift = completeName(a, argc);
- ENSURE_OBJECT(mStack.top(shift + argc));
- as_object *obj = mStack.top(argc +
shift).to_object().get();
+ ENSURE_OBJECT(_stack.top(shift + argc));
+ as_object *obj = _stack.top(argc +
shift).to_object().get();
Property *b = obj->findProperty(a.getABCName(),
a.getNamespace()->getURI());
if (!b)
@@ -1420,8 +1420,8 @@
{
if (lex_only)
{
- mStack.top(argc + shift).set_undefined();
- mStack.drop(argc + shift);
+ _stack.top(argc + shift).set_undefined();
+ _stack.drop(argc + shift);
break;
}
#if 0
@@ -1439,7 +1439,7 @@
if (opcode == SWF::ABC_ACTION_CALLPROPVOID)
pushCall(func, obj, mIgnoreReturn, argc, -shift - 1);
else
- pushCall(func, obj, mStack.top(argc + shift), argc,
-shift);*/
+ pushCall(func, obj, _stack.top(argc + shift), argc,
-shift);*/
break;
}
@@ -1483,32 +1483,24 @@
boost::uint32_t argc = mStream->read_V32();
get_args(argc);
- as_object* obj = mStack.top(argc).to_object().get();
+ as_object* obj = _stack.top(argc).to_object().get();
// Using get_super() here fails; is it broken, or is
// prototype what we want?
as_object* super = obj ? obj->get_prototype().get() : 0;
log_abc("CONSTRUCTSUPER: object %s, super %s, args %s",
- mStack.top(argc), super, argc);
+ _stack.top(argc), super, argc);
if (!super) {
log_error("ABC_ACTION_CONSTRUCTSUPER: No super found");
throw ASException();
}
- as_function *func = super->to_function();
- if (!func) {
- log_abc("CONSTRUCTSUPER: %s has no constructor",
- super);
- break;
- }
-
- // 'obj' is the 'this' for the call, we ignore the
- // return, there are argc arguments, and we drop all
- // of the arguments plus 'obj' from the stack.
- pushCall(func, super, mIgnoreReturn, argc, -1);
-
+ as_value c = super->getMember(NSV::PROP_CONSTRUCTOR, 0);
+ pushCall(c.to_as_function(), super, mIgnoreReturn,
+ argc, -1);
break;
+
}
/// 0x4A ABC_ACTION_CONSTRUCTPROP
@@ -1530,7 +1522,7 @@
log_abc("CONSTRUCT_PROP: will try to construct property "
"%s on object %s", mST.value(a.getGlobalName()),
- mStack.top(0));
+ _stack.top(0));
as_object* object = pop_stack().to_object().get();
@@ -1673,6 +1665,7 @@
log_abc("Creating new class id=%u name=%s", c->getName(),
mST.value(c->getName()));
+ // This may be 0, and that's fine.
as_object* base_class = pop_stack().to_object().get();
as_object* new_class = c->getPrototype();
@@ -1688,10 +1681,8 @@
new_class->init_member(NSV::PROP_uuCONSTRUCTORuu,
as_value(static_constructor), 0);
- as_function* constructor =
- c->getConstructor()->getPrototype();
- new_class->init_member(NSV::PROP_CONSTRUCTOR, as_value(
- constructor), 0);
+ as_function* ctor = c->getConstructor()->getPrototype();
+ new_class->init_member(NSV::PROP_CONSTRUCTOR, ctor, 0);
push_stack(new_class);
@@ -1722,10 +1713,10 @@
case SWF::ABC_ACTION_GETDESCENDANTS:
{
asName a = pool_name(mStream->read_V32(), mPoolObject);
- //as_value &v = mStack.top(0);
+ //as_value &v = _stack.top(0);
ENSURE_OBJECT(v);
- mStack.drop(1);
- mStack.drop(completeName(a));
+ _stack.drop(1);
+ _stack.drop(completeName(a));
// TODO: Decide or discover what to do with this.
LOG_ONCE( log_unimpl("ABC_ACTION_GETDESCENDANTS") );
break;
@@ -1757,13 +1748,13 @@
{
asName a = pool_name(mStream->read_V32(), mPoolObject);
if (a.isRuntime()) {
- mStack.drop(completeName(a));
+ _stack.drop(completeName(a));
}
as_value ret = find_prop_strict(a);
- /* mStack.drop(completeName(a));
+ /* _stack.drop(completeName(a));
as_object *owner;
Property *b = mCurrentScope->findProperty(a.getABCName(),
a.getNamespace()->getURI(), &owner);
@@ -1772,11 +1763,11 @@
if (opcode == SWF::ABC_ACTION_FINDPROPSTRICT)
throw ASReferenceError();
else
- mStack.push(as_value());
+ _stack.push(as_value());
}
else
{
- mStack.push(owner);
+ _stack.push(owner);
}*/
break;
}
@@ -1804,7 +1795,7 @@
as_value val = find_prop_strict(a);
log_abc("GETLEX: found value %s", val);
- mStack.top(0) = val;
+ _stack.top(0) = val;
break;
}
@@ -1889,7 +1880,7 @@
case SWF::ABC_ACTION_GETGLOBALSCOPE:
{
// TODO: Use get_scope_stack here.
- push_stack(as_value(mScopeStack.value(0).get()));
+ push_stack(as_value(_scopeStack.value(0).get()));
//print_stack();
break;
}
@@ -2002,13 +1993,13 @@
case SWF::ABC_ACTION_DELETEPROPERTY:
{
asName a = pool_name(mStream->read_V32(), mPoolObject);
- mStack.drop(completeName(a));
- as_object* obj = mStack.top(0).to_object().get();
+ _stack.drop(completeName(a));
+ as_object* obj = _stack.top(0).to_object().get();
if (!obj) {
// TODO: what here?
log_abc("DELETEPROPERTY: expecting object on stack, "
- "got %s", mStack.top(0));
+ "got %s", _stack.top(0));
break;
}
@@ -2018,7 +2009,7 @@
const string_table::key prop = a.getGlobalName();
const bool deleted = obj->delProperty(prop, ns).second;
- mStack.top(0) = deleted;
+ _stack.top(0) = deleted;
break;
}
@@ -2104,8 +2095,8 @@
if (!sindex)
throw ASException();
--sindex;
- mStack.grow(1);
- //TODO: mStack.top(0) = mGlobal.getSlot(sindex);
+ _stack.grow(1);
+ //TODO: _stack.top(0) = mGlobal.getSlot(sindex);
break;
}
@@ -2123,7 +2114,7 @@
if (!sindex)
throw ASException();
--sindex;
- //TODO: mGlobal.setSlot(sindex, mStack.pop());
+ //TODO: mGlobal.setSlot(sindex, _stack.pop());
break;
}
@@ -2133,7 +2124,7 @@
/// Stack Out:
/// str_value -- value as a string
case SWF::ABC_ACTION_CONVERT_S:
- mStack.top(0) = mStack.top(0).to_string();
+ _stack.top(0) = _stack.top(0).to_string();
break;
/// 0x71 ABC_ACTION_ESC_XELEM
@@ -2144,7 +2135,7 @@
/// an XML element.
case SWF::ABC_ACTION_ESC_XELEM:
log_unimpl("ABC_ACTION_ESC_XELEM");
- //TODO: set mStack.top(0) to an escaped string.
+ //TODO: set _stack.top(0) to an escaped string.
break;
/// 0x72 ABC_ACTION_ESC_XATTR
@@ -2155,7 +2146,7 @@
/// XML attribute.
case SWF::ABC_ACTION_ESC_XATTR:
log_unimpl("ABC_ACTION_ESC_XATTR");
- //TODO: set mStack.top(0) to an escaped string.
+ //TODO: set _stack.top(0) to an escaped string.
break;
/// 0x73 ABC_ACTION_CONVERT_I
@@ -2166,7 +2157,7 @@
/// int_value -- value as an integer object
case SWF::ABC_ACTION_CONVERT_I:
case SWF::ABC_ACTION_COERCE_I:
- mStack.top(0) = mStack.top(0).to_int();
+ _stack.top(0) = _stack.top(0).to_int();
break;
/// 0x74 ABC_ACTION_CONVERT_U
@@ -2177,7 +2168,7 @@
/// int_value -- value as an unsigned integer object
case SWF::ABC_ACTION_CONVERT_U:
case SWF::ABC_ACTION_COERCE_U:
- mStack.top(0) = mStack.top(0).to_number<unsigned int>();
+ _stack.top(0) = _stack.top(0).to_number<unsigned int>();
break;
/// 0x75 ABC_ACTION_CONVERT_D
@@ -2188,7 +2179,7 @@
/// double_value -- value as a double object
case SWF::ABC_ACTION_CONVERT_D:
case SWF::ABC_ACTION_COERCE_D:
- mStack.top(0) = mStack.top(0).to_number();
+ _stack.top(0) = _stack.top(0).to_number();
break;
/// 0x76 ABC_ACTION_CONVERT_B
@@ -2199,7 +2190,7 @@
/// bool_value -- value as a boolean object
case SWF::ABC_ACTION_CONVERT_B:
case SWF::ABC_ACTION_COERCE_B:
- mStack.top(0) = mStack.top(0).to_bool();
+ _stack.top(0) = _stack.top(0).to_bool();
break;
/// 0x77 ABC_ACTION_CONVERT_O
@@ -2210,8 +2201,8 @@
/// Do: If obj is Undefined or Null, throw TypeError
case SWF::ABC_ACTION_CONVERT_O:
{
- mStack.top(0) = mStack.top(0).to_object().get();
- if (mStack.top(0).is_undefined() ||
mStack.top(0).is_null())
+ _stack.top(0) = _stack.top(0).to_object().get();
+ if (_stack.top(0).is_undefined() ||
_stack.top(0).is_null())
throw ASTypeError();
break;
}
@@ -2224,8 +2215,8 @@
/// Do: If obj is not XML based, throw TypeError
case SWF::ABC_ACTION_CHECKFILTER:
{
- if (!mStack.top(0).is_object() ||
- !mStack.top(0).to_object()->isXML())
+ if (!_stack.top(0).is_object() ||
+ !_stack.top(0).to_object()->isXML())
throw ASTypeError();
break;
}
@@ -2243,7 +2234,7 @@
// TODO: handle runtime names?
asName a = pool_name(mStream->read_V32(), mPoolObject);
- as_value value = mStack.top(0);
+ as_value value = _stack.top(0);
log_abc("COERCE: object for conversion is %s, "
"desired type %s", value,
mST.value(a.getGlobalName()));
@@ -2279,11 +2270,11 @@
/// Null or Undefined
case SWF::ABC_ACTION_COERCE_S:
{
- if (mStack.top(0).is_undefined() ||
- mStack.top(0).is_null()) {
- mStack.top(0) = "";
+ if (_stack.top(0).is_undefined() ||
+ _stack.top(0).is_null()) {
+ _stack.top(0) = "";
}
- else mStack.top(0) = mStack.top(0).to_string();
+ else _stack.top(0) = _stack.top(0).to_string();
break;
}
@@ -2326,10 +2317,10 @@
/// cobj -- obj if obj is not Undefined, otherwise Null
case SWF::ABC_ACTION_COERCE_O:
{
- if (mStack.top(0).is_undefined())
- mStack.top(0) = mStack.top(0).to_object().get();
+ if (_stack.top(0).is_undefined())
+ _stack.top(0) = _stack.top(0).to_object().get();
else
- mStack.top(0).set_undefined();
+ _stack.top(0).set_undefined();
break;
}
/// 0x90 ABC_ACTION_NEGATE
@@ -2339,7 +2330,7 @@
/// negdouble -- -1.0 * (double) obj
case SWF::ABC_ACTION_NEGATE:
{
- mStack.top(0) = -mStack.top(0).to_number();
+ _stack.top(0) = -_stack.top(0).to_number();
break;
}
/// 0x91 ABC_ACTION_INCREMENT
@@ -2371,7 +2362,7 @@
/// num - 1
case SWF::ABC_ACTION_DECREMENT:
{
- mStack.top(0) = mStack.top(0).to_number() - 1;
+ _stack.top(0) = _stack.top(0).to_number() - 1;
break;
}
@@ -2391,7 +2382,7 @@
/// Stack Out:
/// type -- typeof(obj) as a string
case SWF::ABC_ACTION_ABC_TYPEOF:
- mStack.top(0) = mStack.top(0).typeOf();
+ _stack.top(0) = _stack.top(0).typeOf();
break;
/// 0x96 ABC_ACTION_NOT
@@ -2400,7 +2391,7 @@
/// Stack Out:
/// nobj -- A truth object with value !((Boolean) obj)
case SWF::ABC_ACTION_NOT:
- mStack.top(0).set_bool(!mStack.top(0).to_bool());
+ _stack.top(0).set_bool(!_stack.top(0).to_bool());
break;
/// 0x97 ABC_ACTION_BITNOT
@@ -2409,7 +2400,7 @@
/// Stack Out:
/// nint -- ~((Int) obj)
case SWF::ABC_ACTION_BITNOT:
- mStack.top(0) = ~mStack.top(0).to_int();
+ _stack.top(0) = ~_stack.top(0).to_int();
break;
/// 0xA0 ABC_ACTION_ADD
@@ -2419,8 +2410,8 @@
/// Stack Out:
/// a + b (double if numeric)
case SWF::ABC_ACTION_ADD:
- mStack.top(1) = mStack.top(1).newAdd(mStack.top(0));
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).newAdd(_stack.top(0));
+ _stack.drop(1);
break;
/// 0xA1 ABC_ACTION_SUBTRACT
@@ -2430,8 +2421,8 @@
/// Stack Out:
/// a - b (double)
case SWF::ABC_ACTION_SUBTRACT:
- mStack.top(1) = mStack.top(1).subtract(mStack.top(0));
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).subtract(_stack.top(0));
+ _stack.drop(1);
break;
/// 0xA2 ABC_ACTION_MULTIPLY
@@ -2441,8 +2432,8 @@
/// Stack Out:
/// a * b (double)
case SWF::ABC_ACTION_MULTIPLY:
- mStack.top(1) = mStack.top(1).to_number() *
mStack.top(0).to_number();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_number() *
_stack.top(0).to_number();
+ _stack.drop(1);
break;
/// 0xA3 ABC_ACTION_DIVIDE
@@ -2452,8 +2443,8 @@
/// Stack Out:
/// a / b (double)
case SWF::ABC_ACTION_DIVIDE:
- mStack.top(1) = mStack.top(1).to_number() /
mStack.top(0).to_number();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_number() /
_stack.top(0).to_number();
+ _stack.drop(1);
break;
/// 0xA4 ABC_ACTION_MODULO
@@ -2465,11 +2456,11 @@
case SWF::ABC_ACTION_MODULO:
{
// TODO: test this properly and fix the UB (overflow).
- double result = mStack.top(1).to_number() /
mStack.top(0).to_number();
+ double result = _stack.top(1).to_number() /
_stack.top(0).to_number();
int trunc_result = static_cast<int> (result);
- mStack.top(1) = mStack.top(1).to_number() -
- (trunc_result * mStack.top(0).to_number());
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_number() -
+ (trunc_result * _stack.top(0).to_number());
+ _stack.drop(1);
break;
}
@@ -2481,8 +2472,8 @@
/// a << b
case SWF::ABC_ACTION_LSHIFT:
{
- mStack.top(1) = mStack.top(1).to_int() <<
mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() <<
_stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2494,8 +2485,8 @@
/// a >> b
case SWF::ABC_ACTION_RSHIFT:
{
- mStack.top(1) = mStack.top(1).to_int() >>
mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() >>
_stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2507,9 +2498,9 @@
/// ((unsigned) a) >> b
case SWF::ABC_ACTION_URSHIFT:
{
- mStack.top(1) = mStack.top(1).to_number<unsigned int>()
- >> mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_number<unsigned int>()
+ >> _stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2519,8 +2510,8 @@
/// Stack Out:
/// a & b
case SWF::ABC_ACTION_BITAND:
- mStack.top(1) = mStack.top(1).to_int() &
mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() &
_stack.top(0).to_int();
+ _stack.drop(1);
break;
/// 0xA9 ABC_ACTION_BITOR
@@ -2530,8 +2521,8 @@
/// Stack Out:
/// a | b
case SWF::ABC_ACTION_BITOR:
- mStack.top(1) = mStack.top(1).to_int() |
mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() |
_stack.top(0).to_int();
+ _stack.drop(1);
break;
/// 0xAA ABC_ACTION_BITXOR
@@ -2542,8 +2533,8 @@
/// a ^ b
case SWF::ABC_ACTION_BITXOR:
{
- mStack.top(1) = mStack.top(1).to_int() ^
mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() ^
_stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2555,9 +2546,9 @@
/// truth -- Truth of (a == b) (weakly)
case SWF::ABC_ACTION_EQUALS:
{
- bool truth = abstractEquality(mStack.top(1),
mStack.top(0), false);
- mStack.drop(1);
- mStack.top(0).set_bool(truth);
+ bool truth = abstractEquality(_stack.top(1),
_stack.top(0), false);
+ _stack.drop(1);
+ _stack.top(0).set_bool(truth);
break;
}
@@ -2570,9 +2561,9 @@
/// 0x19 (ABC_ACTION_IFSTRICTEQ))
case SWF::ABC_ACTION_STRICTEQUALS:
{
- bool truth = abstractEquality(mStack.top(1),
mStack.top(0), true);
- mStack.drop(1);
- mStack.top(0).set_bool(truth);
+ bool truth = abstractEquality(_stack.top(1),
_stack.top(0), true);
+ _stack.drop(1);
+ _stack.top(0).set_bool(truth);
break;
}
@@ -2585,9 +2576,9 @@
case SWF::ABC_ACTION_LESSTHAN:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(1), mStack.top(0),
false);
- mStack.drop(1);
- mStack.top(0).set_bool(truth); // truth is a < b
+ ABSTRACT_COMPARE(truth, _stack.top(1), _stack.top(0),
false);
+ _stack.drop(1);
+ _stack.top(0).set_bool(truth); // truth is a < b
break;
}
@@ -2600,9 +2591,9 @@
case SWF::ABC_ACTION_LESSEQUALS:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
true);
- mStack.drop(1);
- mStack.top(0).set_bool(!truth); // truth is b < a
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
true);
+ _stack.drop(1);
+ _stack.top(0).set_bool(!truth); // truth is b < a
break;
}
@@ -2615,9 +2606,9 @@
case SWF::ABC_ACTION_GREATERTHAN:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(0), mStack.top(1),
false);
- mStack.drop(1);
- mStack.top(0).set_bool(truth); // truth is b < a
+ ABSTRACT_COMPARE(truth, _stack.top(0), _stack.top(1),
false);
+ _stack.drop(1);
+ _stack.top(0).set_bool(truth); // truth is b < a
break;
}
@@ -2630,9 +2621,9 @@
case SWF::ABC_ACTION_GREATEREQUALS:
{
bool truth;
- ABSTRACT_COMPARE(truth, mStack.top(1), mStack.top(0),
true);
- mStack.drop(1);
- mStack.top(0).set_bool(!truth); // truth is a < b
+ ABSTRACT_COMPARE(truth, _stack.top(1), _stack.top(0),
true);
+ _stack.drop(1);
+ _stack.top(0).set_bool(!truth); // truth is a < b
break;
}
@@ -2645,9 +2636,9 @@
case SWF::ABC_ACTION_INSTANCEOF:
{
bool truth;
- ABSTRACT_TYPELATE(truth, mStack.top(1), mStack.top(0));
- mStack.top(1).set_bool(truth);
- mStack.drop(1);
+ ABSTRACT_TYPELATE(truth, _stack.top(1), _stack.top(0));
+ _stack.top(1).set_bool(truth);
+ _stack.drop(1);
break;
}
@@ -2661,9 +2652,9 @@
case SWF::ABC_ACTION_ISTYPE:
{
asName a = pool_name(mStream->read_V32(), mPoolObject);
- mStack.drop(completeName(a));
+ _stack.drop(completeName(a));
// TODO: Namespace stuff?
-
mStack.top(0).set_bool(mStack.top(0).conforms_to(a.getABCName()));
+
_stack.top(0).set_bool(_stack.top(0).conforms_to(a.getABCName()));
}
/// 0xB3 ABC_ACTION_ISTYPELATE
@@ -2704,8 +2695,8 @@
case SWF::ABC_ACTION_IN:
{
log_unimpl("ABC_ACTION_IN");
- //TODO:
mStack.top(1).set_bool(mStack.top(1).to_object().contains(mStack.top(0)));
- mStack.drop(1);
+ //TODO:
_stack.top(1).set_bool(_stack.top(1).to_object().contains(_stack.top(0)));
+ _stack.drop(1);
break;
}
@@ -2713,7 +2704,7 @@
/// See: 0x91 (ABC_ACTION_INCREMENT), but forces types to int,
not double
case SWF::ABC_ACTION_INCREMENT_I:
{
- mStack.top(0) = mStack.top(0).to_int() + 1;
+ _stack.top(0) = _stack.top(0).to_int() + 1;
break;
}
@@ -2721,7 +2712,7 @@
/// See: 0x93 (ABC_ACTION_DECREMENT), but forces types to int,
not double
case SWF::ABC_ACTION_DECREMENT_I:
{
- mStack.top(0) = mStack.top(0).to_int() - 1;
+ _stack.top(0) = _stack.top(0).to_int() - 1;
break;
}
@@ -2750,7 +2741,7 @@
/// not double
case SWF::ABC_ACTION_NEGATE_I:
{
- mStack.top(0) = - mStack.top(0).to_int();
+ _stack.top(0) = - _stack.top(0).to_int();
break;
}
@@ -2758,9 +2749,9 @@
/// See: 0xA0 (ABC_ACTION_ADD), but forces type to int
case SWF::ABC_ACTION_ADD_I:
{
- mStack.top(1) = mStack.top(1).to_int() +
- mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() +
+ _stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2768,9 +2759,9 @@
/// See: 0xA1 (ABC_ACTION_SUBTRACT), but forces type to int
case SWF::ABC_ACTION_SUBTRACT_I:
{
- mStack.top(1) = mStack.top(1).to_int() -
- mStack.top(0).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(1).to_int() -
+ _stack.top(0).to_int();
+ _stack.drop(1);
break;
}
@@ -2778,8 +2769,8 @@
/// See: 0xA2 (ABC_ACTION_MULTIPLY), but forces type to int
case SWF::ABC_ACTION_MULTIPLY_I:
{
- mStack.top(1) = mStack.top(0).to_int() *
mStack.top(1).to_int();
- mStack.drop(1);
+ _stack.top(1) = _stack.top(0).to_int() *
_stack.top(1).to_int();
+ _stack.drop(1);
break;
}
@@ -2797,11 +2788,11 @@
{
//We shouldn't need to a call grow stack, because each
function should now how big the stack will need to be and should allocate all
the space, when it is loaded into the vm.
// GROW_STACK();
- // mStack.grow(1);
- // mStack.push() instead?
+ // _stack.grow(1);
+ // _stack.push() instead?
push_stack(getRegister(opcode- SWF::ABC_ACTION_GETLOCAL0));
- // mStack.top(0) = _registers.value(opcode -
SWF::ABC_ACTION_GETLOCAL0);
+ // _stack.top(0) = _registers.value(opcode -
SWF::ABC_ACTION_GETLOCAL0);
break;
}
/// 0xD4 ABC_ACTION_SETLOCAL0
@@ -2881,15 +2872,15 @@
#if 0
if (!pBinding->isGetSet())
{
- //TODO: mStack.push(pBinding->getFromInstance(instance));
+ //TODO: _stack.push(pBinding->getFromInstance(instance));
return;
}
// This is a getter, so we need to execute it. Even those
// written in C++ get called like this, with pushCall handling.
// And push the instance ('this')
- mStack.push(instance);
- pushCall(1, &mStack.top(0), pBinding); //TODO: pBinding->getGetter());
+ _stack.push(instance);
+ pushCall(1, &_stack.top(0), pBinding); //TODO: pBinding->getGetter());
#else
UNUSED(pDefinition);
UNUSED(name);
@@ -2918,9 +2909,9 @@
}
// Two parameters -- the target object, the value to set.
- mStack.push(instance);
- mStack.push(newvalue);
- pushCall(2, &mStack.top(1), pBinding); //TODO: pBinding->getSetter());
+ _stack.push(instance);
+ _stack.push(newvalue);
+ pushCall(2, &_stack.top(1), pBinding); //TODO: pBinding->getSetter());
#else
UNUSED(pDefinition);
UNUSED(name);
@@ -2934,13 +2925,13 @@
// TODO: implement this properly.
// Should this really be called when there's nothing on the stack?
- if (mStack.empty()) return 0;
+ if (_stack.empty()) return 0;
int size = 0;
if (name.isRuntime())
{
- as_value obj = mStack.top(offset);
+ as_value obj = _stack.top(offset);
if (obj.is_object() && obj.to_object()->isQName()) {
name.fill(obj.to_object().get());
++size;
@@ -2952,7 +2943,7 @@
}
else if (name.isRtns())
{
- //TODO: This should be a namespace
//name.setNamespace(mStack.top(offset));
+ //TODO: This should be a namespace
//name.setNamespace(_stack.top(offset));
++size;
}
return size;
@@ -2983,23 +2974,21 @@
Machine::immediateFunction(const as_function* func, as_object* thisptr,
as_value& storage, unsigned char stack_in, short stack_out)
{
-
- GNASH_REPORT_FUNCTION;
assert(func);
// TODO: Set up the fn to use the stack
std::auto_ptr<std::vector<as_value> > args(new std::vector<as_value>);
size_t st = 0;
while (st < stack_in) {
- args->push_back(mStack.top(st));
+ args->push_back(_stack.top(st));
++st;
}
fn_call fn(thisptr, as_environment(_vm), args);
- mStack.drop(stack_in - stack_out);
+ _stack.drop(stack_in - stack_out);
saveState();
- mStack.grow(stack_in - stack_out);
- mStack.setDownstop(stack_in);
+ _stack.grow(stack_in - stack_out);
+ _stack.setDownstop(stack_in);
mThis = thisptr;
storage = const_cast<as_function*>(func)->call(fn);
restoreState();
@@ -3024,7 +3013,7 @@
if (!prop) return;
if (prop->isGetterSetter()) {
- mStack.push(value);
+ _stack.push(value);
//TODO pushCall(prop->getSetter(), this_obj, mIgnoreReturn, 1);
return;
}
@@ -3048,15 +3037,15 @@
// Here is where the SafeStack shines:
// We set the stack the way it should be on return.
- mStack.drop(stack_in - stack_out);
+ _stack.drop(stack_in - stack_out);
// We save that state.
saveState();
// Set the 'this' for the new call
mThis = pthis;
// Retrieve the stack. (It wasn't lost)
- mStack.grow(stack_in - stack_out);
+ _stack.grow(stack_in - stack_out);
// And then we set the downstop
- mStack.setDownstop(stack_in);
+ _stack.setDownstop(stack_in);
// When control goes to the main loop of the interpreter, it will
// automatically start executing the method.
@@ -3068,8 +3057,8 @@
log_abc("Restoring state.");
State &s = mStateStack.top(0);
s.to_debug_string();
-// mStack.setAllSizes(s.mStackTotalSize, s.mStackDepth);
- mScopeStack.setAllSizes(s.mScopeTotalSize, s.mScopeStackDepth);
+// _stack.setAllSizes(s._stackTotalSize, s._stackDepth);
+ _scopeStack.setAllSizes(s.mScopeTotalSize, s._scopeStackDepth);
mStream = s.mStream;
_registers = s._registers;
mCurrentFunction = s.mFunction;
@@ -3087,10 +3076,10 @@
log_abc("Saving state.");
mStateStack.grow(1);
State &s = mStateStack.top(0);
- s.mStackDepth = mStack.getDownstop();
- s.mStackTotalSize = mStack.totalSize();
- s.mScopeStackDepth = mScopeStack.getDownstop();
- s.mScopeTotalSize = mScopeStack.totalSize();
+ s._stackDepth = _stack.getDownstop();
+ s._stackTotalSize = _stack.totalSize();
+ s._scopeStackDepth = _scopeStack.getDownstop();
+ s.mScopeTotalSize = _scopeStack.totalSize();
s.mStream = mStream;
s.to_debug_string();
s._registers = _registers;
@@ -3132,10 +3121,10 @@
// Protect the current stack from alteration
// TODO: use saveState only, but not before checking other effects.
- size_t stackdepth = mStack.fixDownstop();
- size_t stacksize = mStack.totalSize();
- size_t scopedepth = mScopeStack.fixDownstop();
- size_t scopesize = mScopeStack.totalSize();
+ size_t stackdepth = _stack.fixDownstop();
+ size_t stacksize = _stack.totalSize();
+ size_t scopedepth = _scopeStack.fixDownstop();
+ size_t scopesize = _scopeStack.totalSize();
saveState();
mStream = stream;
@@ -3153,8 +3142,8 @@
execute();
mExitWithReturn = prev_ext;
- mStack.setAllSizes(stacksize, stackdepth);
- mScopeStack.setAllSizes(scopesize, scopedepth);
+ _stack.setAllSizes(stacksize, stackdepth);
+ _scopeStack.setAllSizes(scopesize, scopedepth);
return mGlobalReturn;
}
@@ -3204,10 +3193,10 @@
// Protect the current stack from alteration
// TODO: use saveState
- size_t stackdepth = mStack.fixDownstop();
- size_t stacksize = mStack.totalSize();
- size_t scopedepth = mScopeStack.fixDownstop();
- size_t scopesize = mScopeStack.totalSize();
+ size_t stackdepth = _stack.fixDownstop();
+ size_t stacksize = _stack.totalSize();
+ size_t scopedepth = _scopeStack.fixDownstop();
+ size_t scopesize = _scopeStack.totalSize();
// The value at _registers[0] is generally pushed to the stack for
// CONSTRUCTSUPER, which apparently expects the object whose super
@@ -3218,8 +3207,8 @@
executeCodeblock(ctor->getBody());
log_debug("Finished instantiating class %s", className);
- mStack.setAllSizes(stacksize, stackdepth);
- mScopeStack.setAllSizes(scopesize, scopedepth);
+ _stack.setAllSizes(stacksize, stackdepth);
+ _scopeStack.setAllSizes(scopesize, scopedepth);
}
@@ -3242,16 +3231,16 @@
const string_table::key var = multiname.getGlobalName();
const string_table::key ns = multiname.getNamespace()->getURI();
- for (size_t i = 0; i < mScopeStack.totalSize(); ++i)
+ for (size_t i = 0; i < _scopeStack.totalSize(); ++i)
{
- as_object* scope_object = mScopeStack.at(i).get();
+ as_object* scope_object = _scopeStack.at(i).get();
if (!scope_object) {
log_abc("Scope object is NULL.");
continue;
}
if (scope_object->get_member(var, &val, ns)) {
- push_stack(mScopeStack.at(i));
+ push_stack(_scopeStack.at(i));
return val;
}
}
@@ -3263,51 +3252,15 @@
return val;
}
-as_value
-Machine::get_property_value(asName multiname)
-{
- return get_property_value(0, multiname);
-}
-
-as_value
-Machine::get_property_value(boost::intrusive_ptr<as_object> obj,
- asName multiname)
-{
-
- std::string ns = pool_string(multiname.getNamespace()->getAbcURI(),
- mPoolObject);
- std::string name = pool_string(multiname.getABCName(), mPoolObject);
- return get_property_value(obj, name, ns);
-}
-
-as_value
-Machine::get_property_value(boost::intrusive_ptr<as_object> obj,
- std::string name, std::string ns)
-{
-
- as_environment::ScopeStack stack;
- as_environment env = as_environment(_vm);
-
- if (!obj) stack = *getScopeStack();
- else stack.push_back(obj);
-
- std::string path;
-
- if (ns.empty()) path = name;
- else path = ns + "." + name;
-
- return env.get_variable(path, stack, 0);
-}
-
void
Machine::print_stack()
{
std::stringstream ss;
ss << "Stack: ";
- for (unsigned int i = 0; i < mStack.totalSize(); ++i) {
+ for (unsigned int i = 0; i < _stack.totalSize(); ++i) {
if (i!=0) ss << " | ";
- ss << mStack.at(i);
+ ss << _stack.at(i);
}
log_abc("%s", ss.str());
}
@@ -3319,10 +3272,10 @@
std::stringstream ss;
ss << "ScopeStack: ";
- size_t totalSize = mScopeStack.totalSize();
+ size_t totalSize = _scopeStack.totalSize();
for (unsigned int i = 0; i < totalSize; ++i) {
- ss << as_value(mScopeStack.at(i).get()).toDebugString();
+ ss << as_value(_scopeStack.at(i).get()).toDebugString();
}
log_abc("%s", ss.str());
}
@@ -3339,16 +3292,6 @@
return args;
}
-as_environment::ScopeStack*
-Machine::getScopeStack()
-{
- as_environment::ScopeStack *stack = new as_environment::ScopeStack();
- for (size_t i = 0; i < mScopeStack.size(); ++i) {
- stack->push_back(mScopeStack.top(i));
- }
- return stack;
-}
-
void
Machine::clearRegisters(boost::uint32_t maxRegisters)
{
=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h 2009-07-03 08:19:37 +0000
+++ b/libcore/vm/Machine.h 2009-07-06 06:32:36 +0000
@@ -245,9 +245,9 @@
class State
{
public:
- unsigned int mStackDepth;
- unsigned int mStackTotalSize;
- unsigned int mScopeStackDepth;
+ unsigned int _stackDepth;
+ unsigned int _stackTotalSize;
+ unsigned int _scopeStackDepth;
unsigned int mScopeTotalSize;
bool mReturn;
CodeStream *mStream;
@@ -258,7 +258,7 @@
std::vector<as_value> _registers;
abc_function* mFunction;
void to_debug_string(){
- log_abc("StackDepth=%u StackTotalSize=%u ScopeStackDepth=%u
ScopeTotalSize=%u",mStackDepth,mStackTotalSize,mScopeStackDepth,mScopeTotalSize);
+ log_abc("StackDepth=%u StackTotalSize=%u ScopeStackDepth=%u
ScopeTotalSize=%u",_stackDepth,_stackTotalSize,_scopeStackDepth,mScopeTotalSize);
}
};
@@ -280,12 +280,6 @@
as_value find_prop_strict(asName multiname);
- as_value get_property_value(asName multiname);
-
- as_value get_property_value(boost::intrusive_ptr<as_object> obj, asName
multiname);
-
- as_value get_property_value(boost::intrusive_ptr<as_object> obj,
std::string name, std::string ns);
-
void print_stack();
void print_scope_stack();
@@ -294,8 +288,6 @@
void load_function(CodeStream* stream, boost::uint32_t maxRegisters);
- as_environment::ScopeStack* getScopeStack();
-
void executeCodeblock(CodeStream* stream);
void clearRegisters(boost::uint32_t maxRegsiters);
@@ -316,11 +308,11 @@
void push_stack(as_value object){
log_abc("Pushing value %s onto stack.", object);
- mStack.push(object);
+ _stack.push(object);
}
as_value pop_stack(){
- as_value value = mStack.pop();
+ as_value value = _stack.pop();
log_abc("Popping value %s off the stack.", value);
return value;
}
@@ -329,25 +321,25 @@
boost::intrusive_ptr<as_object> scopeObj = object.to_object();
assert(scopeObj.get());
log_abc("Pushing value %s onto scope stack.", object);
- mScopeStack.push(scopeObj);
+ _scopeStack.push(scopeObj);
print_scope_stack();
}
boost::intrusive_ptr<as_object> pop_scope_stack() {
log_abc("Popping value %s off the scope stack. There will be "
- "%u items left.", as_value(mScopeStack.top(0)),
- mScopeStack.size()-1);
- return mScopeStack.pop();
+ "%u items left.", as_value(_scopeStack.top(0)),
+ _scopeStack.size()-1);
+ return _scopeStack.pop();
}
boost::intrusive_ptr<as_object> get_scope_stack(boost::uint8_t depth)
const {
log_abc("Getting value from scope stack %u from the bottom.",
depth | 0x0);
- return mScopeStack.value(depth);
+ return _scopeStack.value(depth);
}
- SafeStack<as_value> mStack;
+ SafeStack<as_value> _stack;
SafeStack<State> mStateStack;
std::vector<as_value> _registers;
@@ -359,7 +351,7 @@
/// before.
/// Most importantly, the complete stack is used for lookups, including
/// the section that is not changeable.
- SafeStack<boost::intrusive_ptr<as_object> > mScopeStack;
+ SafeStack<boost::intrusive_ptr<as_object> > _scopeStack;
CodeStream *mStream;
=== modified file 'testsuite/as3compile.all/MovieClip.as'
--- a/testsuite/as3compile.all/MovieClip.as 2009-07-03 10:25:04 +0000
+++ b/testsuite/as3compile.all/MovieClip.as 2009-07-06 09:28:29 +0000
@@ -29,10 +29,20 @@
xcheck_equals(MovieClip.prototype, "[object Object]");
xcheck_equals(MovieClip.constructor, "[class Class]");
+ check(!MovieClip.hasOwnProperty("constructor"));
+
+ // Check that this object is a MovieClip and has MovieClip
+ // functions (no need to check them all).
+ xcheck(this instanceof MovieClip);
+ check_equals(typeof(this.nextFrame), "function");
+ check_equals(typeof(this.play), "function");
+
+ xcheck(MovieClip.prototype.hasOwnProperty("constructor"));
// The prototype seems really to be just an object. Just
// test the MovieClip properties until there's a reason
// to check others.
+
check(!MovieClip.prototype.hasOwnProperty("nextFrame"));
check(!MovieClip.prototype.hasOwnProperty("prevFrame"));
check(!MovieClip.prototype.hasOwnProperty("gotoAndStop"));
@@ -47,6 +57,7 @@
var m = new MovieClip();
xcheck_equals(m.constructor, "[class MovieClip]");
+ check(!m.hasOwnProperty("constructor"));
// MovieClip properties
xcheck(m.hasOwnProperty("nextFrame"));
@@ -139,7 +150,7 @@
xcheck_equals(typeof(m.totalFrames), "number");
xcheck_equals(typeof(m.currentFrame), "number");
- totals(92);
+ totals(98);
done();
}
=== modified file 'testsuite/as3compile.all/class.as'
--- a/testsuite/as3compile.all/class.as 2009-06-16 15:22:28 +0000
+++ b/testsuite/as3compile.all/class.as 2009-07-06 09:28:29 +0000
@@ -27,15 +27,18 @@
public class Base {
public function Base() {
- trace("Base ctor");
S.s += "Base ";
+ a = 7;
}
+ var a : int;
}
public class Derived extends Base {
public function Derived() {
S.s += "Derived ";
+ b = "string";
}
+ var b : String;
}
public class Hello extends MovieClip {
@@ -74,10 +77,16 @@
xcheck_equals(Derived.__constructor__, undefined);
xcheck_equals(Base.__constructor__, undefined);
+ // Objects are objects in AS3, not functions.
+ check_equals(typeof(Base), "object");
+ check_equals(typeof(Derived), "object");
+ check_equals(typeof(MovieClip), "object");
+
var b1 : Base = new Base();
xcheck(b1 instanceof Base);
check(!(b1 instanceof Derived));
check_equals(S.s, "Hello Base ");
+ check_equals(b1.a, 7);
xcheck_equals(b1.constructor, "[class Base]");
@@ -85,15 +94,19 @@
var b2 : Base = new Derived();
xcheck(b2 instanceof Base);
xcheck(b2 instanceof Derived);
- xcheck_equals(S.s, "Base Derived ");
+ check_equals(S.s, "Base Derived ");
+ check_equals(b2.a, 7);
+ check_equals(b2.b, "string");
S.s = "";
var d1 : Derived = new Derived();
xcheck(d1 instanceof Base);
xcheck(d1 instanceof Derived);
- xcheck_equals(S.s, "Base Derived ");
+ check_equals(S.s, "Base Derived ");
+ check_equals(d1.a, 7);
+ check_equals(d1.b, "string");
- totals(30);
+ totals(38);
done();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11203: AS3 classes are not functions, but become global objects with a constructor,
Benjamin Wolsey <=