[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9758: - Drop another static member
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9758: - Drop another static member (CallStack) |
Date: |
Tue, 16 Sep 2008 19:31:20 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9758
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Tue 2008-09-16 19:31:20 +0200
message:
- Drop another static member (CallStack)
- Implement arguments.caller
added:
libcore/vm/CallStack.cpp
libcore/vm/CallStack.h
modified:
libcore/as_environment.cpp
libcore/as_environment.h
libcore/builtin_function.h
libcore/namedStrings.cpp
libcore/namedStrings.h
libcore/swf_function.cpp
libcore/swf_function.h
libcore/vm/ActionExec.cpp
libcore/vm/ActionExec.h
libcore/vm/Makefile.am
libcore/vm/VM.h
libcore/vm/action.h
libcore/vm/fn_call.h
testsuite/actionscript.all/Function.as
testsuite/actionscript.all/MovieClip.as
testsuite/swfdec/PASSING
------------------------------------------------------------
revno: 9753.1.1
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 09:53:27 +0200
message:
test arguments.caller when caller is a native function (or is it?)
modified:
testsuite/actionscript.all/MovieClip.as
------------------------------------------------------------
revno: 9753.1.2
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 09:57:22 +0200
message:
add 'caller' named property
modified:
libcore/namedStrings.cpp
libcore/namedStrings.h
------------------------------------------------------------
revno: 9753.1.3
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:15:51 +0200
message:
some more tests for arguments.caller
modified:
testsuite/actionscript.all/Function.as
------------------------------------------------------------
revno: 9753.1.4
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:57:45 +0200
message:
add 'caller' member to fn_call
modified:
libcore/vm/fn_call.h
------------------------------------------------------------
revno: 9753.1.5
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:58:02 +0200
message:
add optional 'caller' parameter to call_method
modified:
libcore/vm/action.cpp
libcore/vm/action.h
------------------------------------------------------------
revno: 9753.1.6
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:58:47 +0200
message:
add getThisFunction method to ActionExec
modified:
libcore/vm/ActionExec.h
------------------------------------------------------------
revno: 9753.1.7
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:59:01 +0200
message:
pass caller on ActionCallFunction and ActionCallMethod
modified:
libcore/vm/ASHandlers.cpp
------------------------------------------------------------
revno: 9753.1.8
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 10:59:18 +0200
message:
add arguments.caller on swf function invocation
modified:
libcore/swf_function.cpp
------------------------------------------------------------
revno: 9753.1.9
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 11:12:54 +0200
message:
array-sort-custom-call pass now (arguments.caller)
modified:
testsuite/swfdec/PASSING
------------------------------------------------------------
revno: 9753.1.10
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 11:20:45 +0200
message:
xcheck to check (arguments.caller)
modified:
testsuite/actionscript.all/Function.as
------------------------------------------------------------
revno: 9753.1.11
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 11:28:54 +0200
message:
fix expected gnash results
modified:
testsuite/actionscript.all/MovieClip.as
------------------------------------------------------------
revno: 9753.1.12
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 14:03:31 +0200
message:
Move ActionScript call stack from as_environment to VM, dropping
another static and giving opportunity to inspect it from any
as_object w/out the need of an as_environment (thinking callMethod for
arguments.caller)
added:
libcore/vm/CallStack.cpp
libcore/vm/CallStack.h
modified:
libcore/as_environment.cpp
libcore/as_environment.h
libcore/builtin_function.h
libcore/swf_function.cpp
libcore/vm/ActionExec.cpp
libcore/vm/Makefile.am
libcore/vm/VM.h
------------------------------------------------------------
revno: 9753.1.13
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 18:44:38 +0200
message:
don't push a CallFrame on stack for builtin functions
modified:
libcore/builtin_function.h
------------------------------------------------------------
revno: 9753.1.14
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 18:48:01 +0200
message:
add comments about why we don't push builtins on the call stack
modified:
libcore/builtin_function.h
------------------------------------------------------------
revno: 9753.1.15
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-16 19:28:57 +0200
message:
- Revert the fn_call extension of 'caller': do everything locally in
swf_function call operator.
- Don't push builtin functions on the call stack
modified:
libcore/swf_function.cpp
libcore/swf_function.h
libcore/vm/ASHandlers.cpp
libcore/vm/action.cpp
libcore/vm/action.h
libcore/vm/fn_call.h
=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp 2008-09-09 00:30:54 +0000
+++ b/libcore/as_environment.cpp 2008-09-16 12:03:31 +0000
@@ -28,7 +28,8 @@
#include "Property.h"
#include "as_object.h"
#include "namedStrings.h"
-#include "as_function.h" // for
as_environment::CallFrame::markReachableResources
+#include "as_function.h"
+#include "CallStack.h"
#include <cstring> // std::strpbrk
#include <string>
@@ -44,14 +45,13 @@
namespace gnash {
-as_environment::CallStack as_environment::_localFrames =
as_environment::CallStack();
-
as_value as_environment::undefVal;
as_environment::as_environment(VM& vm)
:
_vm(vm),
_stack(_vm.getStack()),
+ _localFrames(_vm.getCallStack()),
m_target(0),
_original_target(0)
{
@@ -424,7 +424,7 @@
{
// Not in frame; create a new local var.
assert( ! varname.empty() ); // null varnames are invalid!
- LocalVars& locals = _localFrames.back().locals;
+ as_object* locals = _localFrames.back().locals;
//locals.push_back(as_environment::frame_slot(varname, val));
locals->set_member(varkey, val);
}
@@ -440,7 +440,7 @@
// Not in frame; create a new local var.
assert( ! _localFrames.empty() );
assert( ! varname.empty() ); // null varnames are invalid!
- LocalVars& locals = _localFrames.back().locals;
+ as_object* locals = _localFrames.back().locals;
//locals.push_back(as_environment::frame_slot(varname,
as_value()));
locals->set_member(_vm.getStringTable().find(varname),
as_value());
}
@@ -790,11 +790,11 @@
}
static void
-dump(const as_environment::LocalVars& locals, std::ostream& out)
+dump(const as_object* locals, std::ostream& out)
{
typedef std::map<std::string, as_value> PropMap;
PropMap props;
- const_cast<as_object*>(locals.get())->dump_members(props);
+ const_cast<as_object*>(locals)->dump_members(props);
//log_debug("FIXME: implement dumper for local variables now that they
are simple objects");
int count = 0;
@@ -854,26 +854,26 @@
if ( _localFrames.empty() ) return false;
if ( findLocal(_localFrames.back().locals, varname, ret) )
{
- if ( retTarget ) *retTarget = _localFrames.back().locals.get();
+ if ( retTarget ) *retTarget = _localFrames.back().locals;
return true;
}
return false;
}
-/* static private */
+/* private */
bool
-as_environment::findLocal(LocalVars& locals, const std::string& name,
as_value& ret)
+as_environment::findLocal(as_object* locals, const std::string& name,
as_value& ret)
{
// TODO: get VM passed as arg
- return locals->get_member(VM::get().getStringTable().find(name), &ret);
+ return locals->get_member(_vm.getStringTable().find(name), &ret);
}
-/* static private */
+/* private */
bool
-as_environment::delLocal(LocalVars& locals, const std::string& varname)
+as_environment::delLocal(as_object* locals, const std::string& varname)
{
// TODO: get VM passed as arg
- return
locals->delProperty(VM::get().getStringTable().find(varname)).second;
+ return locals->delProperty(_vm.getStringTable().find(varname)).second;
}
/* private */
@@ -892,13 +892,12 @@
return setLocal(_localFrames.back().locals, varname, val);
}
-/* static private */
+/* private */
bool
-as_environment::setLocal(LocalVars& locals,
+as_environment::setLocal(as_object* locals,
const std::string& varname, const as_value& val)
{
- // TODO: get VM passed as arg
- Property* prop =
locals->getOwnProperty(VM::get().getStringTable().find(varname));
+ Property* prop =
locals->getOwnProperty(_vm.getStringTable().find(varname));
if ( ! prop ) return false;
prop->setValue(*locals, val);
return true;
@@ -967,18 +966,11 @@
{
assert( ! varname.empty() ); // null varnames are invalid!
assert( ! _localFrames.empty() );
- LocalVars& locals = _localFrames.back().locals;
+ as_object* locals = _localFrames.back().locals;
//locals.push_back(frame_slot(varname, val));
locals->set_member(_vm.getStringTable().find(varname), val);
}
-as_environment::CallFrame::CallFrame(as_function* funcPtr)
- :
- locals(new as_object()),
- func(funcPtr)
-{
-}
-
void
as_environment::dump_stack(std::ostream& out, unsigned int limit) const
{
@@ -1002,21 +994,6 @@
}
#ifdef GNASH_USE_GC
-/// Mark all reachable resources
-//
-/// Reachable resources would be registers and
-/// locals (expected to be empty?) and function.
-void
-as_environment::CallFrame::markReachableResources() const
-{
- if ( func ) func->setReachable();
- for (Registers::const_iterator i=registers.begin(), e=registers.end();
i!=e; ++i)
- {
- i->setReachable();
- }
- if (locals)
- locals->setReachable();
-}
unsigned int
as_environment::setRegister(unsigned int regnum, const as_value& v)
=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h 2008-09-12 13:10:58 +0000
+++ b/libcore/as_environment.h 2008-09-16 12:03:31 +0000
@@ -24,6 +24,7 @@
#include "StringPredicates.h" // for Variables
#include "as_object.h"
#include "SafeStack.h"
+#include "CallStack.h" // for composition
#include <map> // for composition (Variables)
#include <string> // for frame_slot name
@@ -49,10 +50,6 @@
/// The variables container (case-insensitive)
typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;
- /// The locals container
- //typedef std::vector<frame_slot> LocalVars;
- typedef boost::intrusive_ptr<as_object> LocalVars;
-
typedef std::vector<as_value> Registers;
as_environment(VM& vm);
@@ -496,40 +493,24 @@
///
bool parse_path(const std::string& var_path, as_object** target,
as_value& val);
- struct CallFrame
- {
- CallFrame(as_function* funcPtr);
-
- CallFrame(const CallFrame& other) : locals(other.locals),
- registers(other.registers), func(other.func)
- {/**/}
-
- /// function use this
- LocalVars locals;
-
- /// function2 also use this
- Registers registers;
-
- as_function* func;
-
-#ifdef GNASH_USE_GC
- /// Mark all reachable resources
- //
- /// Reachable resources would be registers and
- /// locals (expected to be empty?) and function.
- void markReachableResources() const;
-#endif // GNASH_USE_GC
- };
-
/// A class to wrap frame access. Stack allocating a frame guard
/// will ensure that all CallFrame pushes have a corresponding
/// CallFrame pop, even in the presence of extraordinary returns.
class FrameGuard
{
+ as_environment& _env;
public:
- FrameGuard(as_function* func)
- { as_environment::pushCallFrame(func); }
- ~FrameGuard() { as_environment::popCallFrame(); }
+ FrameGuard(as_environment& env, as_function* func)
+ :
+ _env(env)
+ {
+ _env.pushCallFrame(func);
+ }
+
+ ~FrameGuard()
+ {
+ _env.popCallFrame();
+ }
};
/// Get top element of the call stack
@@ -541,7 +522,7 @@
}
/// Return the depth of call stack
- static size_t callStackDepth()
+ size_t callStackDepth()
{
return _localFrames.size();
}
@@ -556,9 +537,7 @@
static const short unsigned int numGlobalRegisters = 4;
- typedef std::vector<CallFrame> CallStack;
-
- static CallStack _localFrames;
+ CallStack& _localFrames;
as_value m_global_register[numGlobalRegisters];
@@ -579,13 +558,13 @@
/// @param func
/// The function being called
///
- static DSOEXPORT void pushCallFrame(as_function* func);
+ DSOEXPORT void pushCallFrame(as_function* func);
/// Remove current call frame from the stack
//
/// This should happen when an ActionScript function returns.
///
- static DSOEXPORT void popCallFrame();
+ DSOEXPORT void popCallFrame();
/// Return the (possibly UNDEFINED) value of the named variable.
//
@@ -633,7 +612,7 @@
return const_cast<as_environment*>(this)->findLocal(varname,
ret, retTarget);
}
- /// Find a variable in the given LocalVars
+ /// Find a variable in the given as_object
//
/// @param varname
/// Name of the local variable
@@ -644,7 +623,7 @@
///
/// @return true if the variable was found, false otherwise
///
- static bool findLocal(LocalVars& locals, const std::string& name,
as_value& ret);
+ bool findLocal(as_object* locals, const std::string& name, as_value&
ret);
/// Delete a local variable
//
@@ -655,14 +634,14 @@
///
bool delLocal(const std::string& varname);
- /// Delete a variable from the given LocalVars
+ /// Delete a variable from the given as_object
//
/// @param varname
/// Name of the local variable
///
/// @return true if the variable was found, false otherwise
///
- static bool delLocal(LocalVars& locals, const std::string& varname);
+ bool delLocal(as_object* locals, const std::string& varname);
/// Set a local variable, if it exists.
//
@@ -676,7 +655,7 @@
///
bool setLocal(const std::string& varname, const as_value& val);
- /// Set a variable from the given LocalVars, if it exists.
+ /// Set a variable of the given object, if it exists.
//
/// @param varname
/// Name of the local variable
@@ -686,7 +665,7 @@
///
/// @return true if the variable was found, false otherwise
///
- static bool setLocal(LocalVars& locals, const std::string& varname,
const as_value& val);
+ bool setLocal(as_object* locals, const std::string& varname, const
as_value& val);
static as_value undefVal;
=== modified file 'libcore/builtin_function.h'
--- a/libcore/builtin_function.h 2008-03-31 16:17:14 +0000
+++ b/libcore/builtin_function.h 2008-09-16 16:48:01 +0000
@@ -19,7 +19,8 @@
#define __GNASH_BUILTIN_FUNCTION_H__
#include "as_function.h" // for inheritance
-#include "as_environment.h" // for FrameGuard
+#include "fn_call.h" // for call operator
+// #include "as_environment.h" // for FrameGuard
#include "namedStrings.h"
#include <cassert>
@@ -82,7 +83,21 @@
/// Invoke this function or this Class constructor
virtual as_value operator()(const fn_call& fn)
{
- as_environment::FrameGuard guard(this);
+ // Real native functions don't put self on the CallStack
+ // (they never end up in an arguments.caller).
+ // This is, for example, the case for Array.sort when
+ // calling a custom comparator.
+ // Unfortunately gnash implements all builtin as natives
+ // while the proprietary player doesn't (for example
+ // MovieClip.meth does end up in arguments.caller).
+ //
+ // A possible short-term solution to this could be
+ // specifying for a builtin_function whether or not
+ // it should be considered 'native'.
+ // If not 'native', we'd push a CallFrame on stack...
+ //
+ //as_environment::FrameGuard guard(fn.env(), this);
+
assert(_func);
return _func(fn);
}
=== modified file 'libcore/namedStrings.cpp'
--- a/libcore/namedStrings.cpp 2008-08-19 20:37:40 +0000
+++ b/libcore/namedStrings.cpp 2008-09-16 07:57:22 +0000
@@ -42,6 +42,7 @@
string_table::svt( "bullet", NSV::PROP_BULLET ),
string_table::svt( "c", NSV::PROP_C ),
string_table::svt( "callee", NSV::PROP_CALLEE ),
+ string_table::svt( "caller", NSV::PROP_CALLER ),
//string_table::svt( "color", NSV::PROP_COLOR ), // clashes with
CLASS_COLOR in case-insensitive mode
string_table::svt( "constructor", NSV::PROP_CONSTRUCTOR ),
string_table::svt( "__constructor__", NSV::PROP_uuCONSTRUCTORuu ),
=== modified file 'libcore/namedStrings.h'
--- a/libcore/namedStrings.h 2008-08-19 20:37:40 +0000
+++ b/libcore/namedStrings.h 2008-09-16 07:57:22 +0000
@@ -60,6 +60,7 @@
PROP_BULLET,
PROP_C,
PROP_CALLEE,
+ PROP_CALLER,
//PROP_COLOR, // clashes with CLASS_COLOR in case-insensitive
mode
PROP_CONSTRUCTOR,
PROP_uuCONSTRUCTORuu,
=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp 2008-07-08 00:23:27 +0000
+++ b/libcore/swf_function.cpp 2008-09-16 17:28:57 +0000
@@ -63,7 +63,7 @@
/*private static*/
as_array_object*
-swf_function::getArguments(swf_function& callee, const fn_call& fn)
+swf_function::getArguments(swf_function& callee, const fn_call& fn, as_object*
caller)
{
#ifndef GNASH_USE_GC
// We'll be storing the callee as_object into an as_value
@@ -80,6 +80,8 @@
}
arguments->init_member(NSV::PROP_CALLEE, &callee);
+ arguments->init_member(NSV::PROP_CALLER, as_value(caller));
+
return arguments;
}
@@ -120,8 +122,14 @@
as_value
swf_function::operator()(const fn_call& fn)
{
+ // Extract caller before pushing ourself on the call stack
+ as_object* caller = 0;
+ VM& vm = getVM();
+ CallStack& cs = vm.getCallStack();
+ if ( ! cs.empty() ) caller = cs.back().func;
+
// Set up local stack frame, for parameters and locals.
- as_environment::FrameGuard guard(this);
+ as_environment::FrameGuard guard(fn.env(), this);
as_environment* our_env = m_env;
assert(our_env);
@@ -208,7 +216,7 @@
}
// Add 'arguments'
- our_env->set_local("arguments", getArguments(*this, fn));
+ our_env->set_local("arguments", getArguments(*this, fn,
caller));
}
else
{
@@ -242,7 +250,7 @@
boost::intrusive_ptr<as_array_object> arg_array;
if ((m_function2_flags & PRELOAD_ARGUMENTS) || !
(m_function2_flags & SUPPRESS_ARGUMENTS))
{
- arg_array = getArguments(*this, fn);
+ arg_array = getArguments(*this, fn, caller);
}
if (m_function2_flags & PRELOAD_ARGUMENTS)
=== modified file 'libcore/swf_function.h'
--- a/libcore/swf_function.h 2008-03-27 10:50:12 +0000
+++ b/libcore/swf_function.h 2008-09-16 17:28:57 +0000
@@ -94,7 +94,7 @@
/// a reference on it!
///
///
- static as_array_object* getArguments(swf_function& callee, const
fn_call& fn);
+ static as_array_object* getArguments(swf_function& callee, const
fn_call& fn, as_object* caller);
public:
=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2008-09-14 10:58:19 +0000
+++ b/libcore/vm/ActionExec.cpp 2008-09-16 12:03:31 +0000
@@ -98,7 +98,7 @@
// We assume that the swf_function () operator already initialized its
environment
// so that it's activation object is now in the top element of the
CallFrame stack
//
- as_environment::CallFrame& topFrame = newEnv.topCallFrame();
+ CallFrame& topFrame = newEnv.topCallFrame();
assert(topFrame.func == &func);
_scopeStack.push_back(topFrame.locals);
}
@@ -575,7 +575,7 @@
/*private*/
void
-ActionExec::cleanupAfterRun(bool expectInconsistencies)
+ActionExec::cleanupAfterRun(bool /*expectInconsistencies*/) // TODO: drop
argument...
{
//assert(_originalTarget); // this execution context might have been
started while target had a null target
env.set_target(_originalTarget);
=== modified file 'libcore/vm/ActionExec.h'
--- a/libcore/vm/ActionExec.h 2008-08-31 17:34:39 +0000
+++ b/libcore/vm/ActionExec.h 2008-09-16 08:58:47 +0000
@@ -272,6 +272,9 @@
/// Is this execution thread a function call ?
bool isFunction() const { return _func != 0; }
+ /// Get a pointer of the function being executed (if any)
+ const swf_function* getThisFunction() const { return _func; }
+
/// Get the current 'this' pointer, for use in function calls
as_object* getThisPointer();
=== added file 'libcore/vm/CallStack.cpp'
--- a/libcore/vm/CallStack.cpp 1970-01-01 00:00:00 +0000
+++ b/libcore/vm/CallStack.cpp 2008-09-16 12:03:31 +0000
@@ -0,0 +1,47 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#include "CallStack.h"
+#include "as_object.h"
+#include "as_function.h" // for
as_environment::CallFrame::markReachableResources
+
+namespace gnash {
+
+CallFrame::CallFrame(as_function* funcPtr)
+ :
+ locals(new as_object()),
+ func(funcPtr)
+{
+}
+
+/// Mark all reachable resources
+//
+/// Reachable resources would be registers and
+/// locals (expected to be empty?) and function.
+void
+CallFrame::markReachableResources() const
+{
+ if ( func ) func->setReachable();
+ for (Registers::const_iterator i=registers.begin(), e=registers.end();
i!=e; ++i)
+ {
+ i->setReachable();
+ }
+ if (locals)
+ locals->setReachable();
+}
+
+} // namespace gnash
=== added file 'libcore/vm/CallStack.h'
--- a/libcore/vm/CallStack.h 1970-01-01 00:00:00 +0000
+++ b/libcore/vm/CallStack.h 2008-09-16 12:03:31 +0000
@@ -0,0 +1,67 @@
+//
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef GNASH_VM_CALL_STACK_H
+#define GNASH_VM_CALL_STACK_H
+
+#include <vector>
+
+// Forward declarations
+namespace gnash {
+ class as_object;
+ class as_function;
+ class as_value;
+}
+
+namespace gnash {
+
+/// An element of a CallStack
+struct CallFrame
+{
+ typedef std::vector<as_value> Registers;
+
+
+ CallFrame(as_function* funcPtr);
+
+ CallFrame(const CallFrame& other)
+ :
+ locals(other.locals),
+ registers(other.registers),
+ func(other.func)
+ {/**/}
+
+ /// function use this
+ as_object* locals;
+
+ /// function2 also use this
+ Registers registers;
+
+ as_function* func;
+
+ /// Mark all reachable resources
+ //
+ /// Reachable resources would be registers and
+ /// locals (expected to be empty?) and function.
+ void markReachableResources() const;
+};
+
+typedef std::vector<CallFrame> CallStack;
+
+
+} // namespace gnash
+
+#endif // GNASH_VM_CALL_STACK_H
=== modified file 'libcore/vm/Makefile.am'
--- a/libcore/vm/Makefile.am 2008-07-22 21:24:49 +0000
+++ b/libcore/vm/Makefile.am 2008-09-16 12:03:31 +0000
@@ -44,7 +44,8 @@
Machine.cpp \
ActionExec.cpp \
VM.cpp \
- action.cpp \
+ action.cpp \
+ CallStack.cpp \
$(NULL)
noinst_HEADERS = \
@@ -58,6 +59,7 @@
VM.h \
action.h \
fn_call.h \
+ CallStack.h \
with_stack_entry.h \
$(NULL)
=== modified file 'libcore/vm/VM.h'
--- a/libcore/vm/VM.h 2008-09-10 13:32:57 +0000
+++ b/libcore/vm/VM.h 2008-09-16 12:03:31 +0000
@@ -159,6 +159,8 @@
SafeStack<as_value> _stack;
+ CallStack _callStack;
+
/// Library of SharedObjects. Owned by the VM.
SharedObjectLibrary* _shLib;
@@ -169,6 +171,11 @@
return _stack;
}
+ CallStack& getCallStack()
+ {
+ return _callStack;
+ }
+
/// \brief
/// Initialize the virtual machine singleton with the given
/// movie definition and return a reference to it.
=== modified file 'libcore/vm/action.h'
--- a/libcore/vm/action.h 2008-08-29 21:41:06 +0000
+++ b/libcore/vm/action.h 2008-09-16 17:28:57 +0000
@@ -49,7 +49,8 @@
///
DSOEXPORT as_value call_method(const as_value& method, as_environment*
env,
as_object* this_ptr, // this is ourself
- std::auto_ptr<std::vector<as_value> > args, as_object*
super=NULL);
+ std::auto_ptr<std::vector<as_value> > args,
+ as_object* super=0); // the super object
} // end namespace gnash
=== modified file 'libcore/vm/fn_call.h'
--- a/libcore/vm/fn_call.h 2008-09-01 09:44:23 +0000
+++ b/libcore/vm/fn_call.h 2008-09-16 17:28:57 +0000
@@ -30,12 +30,16 @@
#include <ostream> // for inlines (dump_args)
#include <sstream> // for inlines (dump_args)
-namespace gnash {
-
// Forward declarations
-class as_environment;
-class as_object;
-class as_value;
+namespace gnash {
+ class as_environment;
+ class as_function;
+ class as_object;
+ class as_value;
+}
+
+namespace gnash {
+
/// \brief
/// Parameters/environment for builtin or user-defined functions
=== modified file 'testsuite/actionscript.all/Function.as'
--- a/testsuite/actionscript.all/Function.as 2008-08-29 21:28:38 +0000
+++ b/testsuite/actionscript.all/Function.as 2008-09-16 09:20:45 +0000
@@ -147,10 +147,12 @@
check_equals ( nullcall, 6 );
#endif
-function getThis () { ++c; return this; }
+function getThis () { retCaller=arguments.caller; ++c; return this; }
o={};
c=0;
+retCaller = 'custom';
ret = getThis.call(o);
+check_equals(typeof(retCaller), 'null');
check_equals(ret, o);
check_equals(c, 1);
ret = getThis.call(null);
@@ -160,6 +162,15 @@
check( ! (ret === undefined) ); // an object type which returns 'undefined' as
primitive value ?
check( ! (ret === null) ); // an object type which returns 'undefined' as
primitive value ?
+retCaller = 'custom';
+myCaller = function()
+{
+ getThis.call(o);
+};
+myCaller();
+check_equals(typeof(retCaller), 'function');
+check_equals(retCaller, myCaller); // note: it is not Function.prototype.call!
+
#else // OUTPUT_VERSION < 6
check_equals ( typeOf(getThisName.call), 'undefined' );
@@ -412,7 +423,7 @@
// callee: the function being called
check_equals(arguments.callee, _root.f);
// caller: the caller function
- xcheck_equals(typeof(arguments.caller), 'null'); //? typeof return 'null',
seems new!
+ check_equals(typeof(arguments.caller), 'null');
check_equals(arguments.caller, null);
var a = arguments;
@@ -433,7 +444,7 @@
xcheck_equals(propRecorder.length, 5);
check_equals(propRecorder[0], '__proto__');
check_equals(propRecorder[1], 'callee');
- xcheck_equals(propRecorder[2], 'caller');
+ check_equals(propRecorder[2], 'caller');
xcheck_equals(propRecorder[3], 'constructor');
xcheck_equals(propRecorder[4], 'length');
}
@@ -442,12 +453,7 @@
// test argument.caller
function child_func()
{
-#if OUTPUT_VERSION == 5
check_equals(arguments.caller, parent_func);
-#else
- //? passed on swf5, but failed on swf6,7,8
- xcheck_equals(arguments.caller, parent_func);
-#endif
}
function parent_func()
{
@@ -979,8 +985,8 @@
check_totals(150); // SWF5
#endif
#if OUTPUT_VERSION == 6
- check_totals(213); // SWF6
+ check_totals(216); // SWF6
#endif
#if OUTPUT_VERSION >= 7
- check_totals(214); // SWF7,SWF8
+ check_totals(217); // SWF7,SWF8
#endif
=== modified file 'testsuite/actionscript.all/MovieClip.as'
--- a/testsuite/actionscript.all/MovieClip.as 2008-08-26 14:07:38 +0000
+++ b/testsuite/actionscript.all/MovieClip.as 2008-09-16 09:28:54 +0000
@@ -27,19 +27,19 @@
endOfTest = function()
{
#if OUTPUT_VERSION <= 5
- check_totals(233); // SWF5
+ check_totals(234); // SWF5
#endif
#if OUTPUT_VERSION == 6
- check_totals(663); // SWF6
+ check_totals(664); // SWF6
#endif
#if OUTPUT_VERSION == 7
- check_totals(680); // SWF7
+ check_totals(681); // SWF7
#endif
#if OUTPUT_VERSION >= 8
- check_totals(681); // SWF8+
+ check_totals(682); // SWF8+
#endif
play();
@@ -1462,8 +1462,13 @@
check_equals(typeof(ret), 'number');
check_equals(ret, 0);
-Number.prototype.toLowerCase = function() { return "post"; };
+Number.prototype.toLowerCase = function() { retCaller=arguments.caller; return
"post"; };
ret = _root.meth(1);
+#if OUTPUT_VERSION < 6
+ check_equals(retCaller, _root.meth); // in gnash works because functions
resolve equal to undefined
+#else
+ xcheck_equals(retCaller, _root.meth); // check that arguments.caller is also
set for builtin functions
+#endif
check_equals(typeof(ret), 'number');
check_equals(ret, 2);
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2008-09-15 09:22:13 +0000
+++ b/testsuite/swfdec/PASSING 2008-09-16 09:12:54 +0000
@@ -40,6 +40,10 @@
array-new-7.swf:77c4510eed0fd37d8654f761800edcce
array-new-8.swf:8b26fcd892b0cd7a1cd2832d3844d00d
array-new-override-5.swf:5016b51c60e30ee262b3cb022ba4c58f
+array-sort-custom-call-5.swf:3bfe136dfda4403b1984aae59fde2144
+array-sort-custom-call-6.swf:d2517fbff896c1586947664ea20befa7
+array-sort-custom-call-7.swf:6293fd0f9a5cc6498ebcbe3d90aeca69
+array-sort-custom-call-8.swf:55f6ed659bdfb624198f5f1b6ccf365e
array-sort-on-5.swf:3c7eaa57454c8a65971d7765bbf3f495
array-sort-on-6.swf:158e931ebd968351b6a4d3d8ca30b516
array-sort-on-7.swf:d2ad844a1b5ebe6c65aae075a8273370
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9758: - Drop another static member (CallStack),
Sandro Santilli <=