[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve... |
Date: |
Thu, 26 Apr 2007 13:34:01 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/26 13:34:00
Modified files:
. : ChangeLog
server : as_environment.cpp as_environment.h
Log message:
* server/as_environment.{cpp,h}: refactor local variables
so they are stored into a proper object. Will help introducing
a VariableRef class that associates a Property to an
as_object.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3007&r2=1.3008
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.46&r2=1.47
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3007
retrieving revision 1.3008
diff -u -b -r1.3007 -r1.3008
--- ChangeLog 26 Apr 2007 12:31:44 -0000 1.3007
+++ ChangeLog 26 Apr 2007 13:34:00 -0000 1.3008
@@ -1,5 +1,11 @@
2007-04-26 Sandro Santilli <address@hidden>
+ * server/as_environment.{cpp,h}: refactor local variables
+ so they are stored into a proper object. Will help introducing
+ a VariableRef class that associates a Property to an as_object.
+
+2007-04-26 Sandro Santilli <address@hidden>
+
* server/as_environment.h, server/movie_root.h,
server/sprite_instance.h, server/vm/action.cpp:
Remove some unused code, remove Id tags from headers.
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- server/as_environment.cpp 26 Apr 2007 07:00:29 -0000 1.71
+++ server/as_environment.cpp 26 Apr 2007 13:34:00 -0000 1.72
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: as_environment.cpp,v 1.71 2007/04/26 07:00:29 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.72 2007/04/26 13:34:00 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -31,6 +31,8 @@
#include "with_stack_entry.h"
#include "VM.h"
#include "log.h"
+#include "Property.h"
+#include "as_object.h"
#include <string>
#include <utility> // for std::pair
@@ -102,15 +104,15 @@
{
assert(strchr(varname.c_str(), ':') == NULL);
+ as_value val;
+
// Check locals for getting them
- as_environment::frame_slot slot;
- if ( findLocal(varname, slot, true) ) // do we really want to descend here
??
+ //as_environment::frame_slot slot;
+ if ( findLocal(varname, val, true) ) // do we really want to descend here
??
{
- return slot.m_value;
+ return val;
}
- as_value val;
-
// Check the with-stack.
for (size_t i = with_stack.size(); i > 0; --i) {
// const_cast needed due to non-const as_object::get_member
@@ -271,7 +273,6 @@
{
// Check locals for setting them
- as_environment::frame_slot slot;
if ( setLocal(varname, val, true) )
{
return;
@@ -314,7 +315,7 @@
// Is it in the current frame already?
// TODO: should we descend to upper frames ?
// (probably not as we want to update it)
- as_environment::frame_slot slot;
+ //as_environment::frame_slot slot;
if ( setLocal(varname, val, false) )
{
return;
@@ -325,7 +326,8 @@
assert(_localFrames.size());
assert(varname.length() > 0); // null varnames are invalid!
LocalVars& locals = _localFrames.back().locals;
- locals.push_back(as_environment::frame_slot(varname, val));
+ //locals.push_back(as_environment::frame_slot(varname, val));
+ locals->set_member(varname, val);
}
}
@@ -335,14 +337,17 @@
{
// TODO: should we descend to upper frames ?
// (probably not as we want to declare it)
- as_environment::frame_slot slot;
- if ( ! findLocal(varname, slot, false) )
+ //as_environment::frame_slot slot;
+
+ as_value tmp;
+ if ( ! findLocal(varname, tmp, false) )
{
// Not in frame; create a new local var.
assert(_localFrames.size());
assert(varname.length() > 0); // null varnames are invalid!
LocalVars& locals = _localFrames.back().locals;
- locals.push_back(as_environment::frame_slot(varname,
as_value()));
+ //locals.push_back(as_environment::frame_slot(varname,
as_value()));
+ locals->set_member(varname, as_value());
}
}
@@ -870,6 +875,8 @@
static void
dump(const as_environment::LocalVars& locals, std::ostream& out)
{
+ log_msg("FIXME: implement dumper for local variables now that they are
simple objects");
+#if 0
for (size_t i=0; i<locals.size(); ++i)
{
const as_environment::frame_slot& slot = locals[i];
@@ -878,6 +885,7 @@
out << slot.m_name << "==" << slot.m_value;
}
out << std::endl;
+#endif
}
void
@@ -913,7 +921,7 @@
/*private*/
bool
-as_environment::findLocal(const std::string& varname,
as_environment::frame_slot& ret, bool descend)
+as_environment::findLocal(const std::string& varname, as_value& ret, bool
descend)
{
if ( _localFrames.empty() ) return false;
if ( ! descend ) return findLocal(_localFrames.back().locals, varname,
ret);
@@ -934,8 +942,10 @@
/* static private */
bool
-as_environment::findLocal(LocalVars& locals, const std::string& name,
as_environment::frame_slot& ret)
+as_environment::findLocal(LocalVars& locals, const std::string& name,
as_value& ret)
{
+ return locals->get_member(name, &ret);
+#if 0
for (size_t i=0; i<locals.size(); ++i)
{
const as_environment::frame_slot& slot = locals[i];
@@ -946,12 +956,15 @@
}
}
return false;
+#endif
}
/* static private */
bool
as_environment::delLocal(LocalVars& locals, const std::string& varname)
{
+ return locals->delProperty(varname).second;
+#if 0
for (size_t i=0; i<locals.size(); ++i)
{
const as_environment::frame_slot& slot = locals[i];
@@ -962,6 +975,7 @@
}
}
return false;
+#endif
}
/* private */
@@ -1011,6 +1025,11 @@
as_environment::setLocal(LocalVars& locals,
const std::string& varname, const as_value& val)
{
+ Property* prop = locals->getOwnProperty(varname);
+ if ( ! prop ) return false;
+ prop->setValue(*locals, val);
+ return true;
+#if 0
for (size_t i=0; i<locals.size(); ++i)
{
as_environment::frame_slot& slot = locals[i];
@@ -1021,6 +1040,7 @@
}
}
return false;
+#endif
}
@@ -1054,6 +1074,23 @@
m_target = target;
}
+void
+as_environment::add_local(const std::string& varname, const as_value& val)
+{
+ assert(varname.length() > 0); // null varnames are invalid!
+ assert(_localFrames.size());
+ LocalVars& locals = _localFrames.back().locals;
+ //locals.push_back(frame_slot(varname, val));
+ locals->set_member(varname, val);
+}
+
+as_environment::CallFrame::CallFrame(as_function* funcPtr)
+ :
+ locals(new as_object()),
+ func(funcPtr)
+{
+}
+
} // end of gnash namespace
Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- server/as_environment.h 26 Apr 2007 12:31:44 -0000 1.46
+++ server/as_environment.h 26 Apr 2007 13:34:00 -0000 1.47
@@ -23,6 +23,7 @@
#include "as_value.h" // for composition (vector + frame_slot)
#include "StringPredicates.h" // for Variables
+#include "as_object.h"
#include <map> // for composition (Variables)
#include <string> // for frame_slot name
@@ -46,6 +47,7 @@
/// Stack of as_values in this environment
std::vector<as_value> m_stack;
+#if 0
/// For local vars. Use empty names to separate frames.
class frame_slot
{
@@ -64,6 +66,7 @@
{
}
};
+#endif
as_environment()
:
@@ -248,13 +251,7 @@
/// doesn't exist yet, since it's faster than set_local();
/// e.g. when setting up args for a function.
///
- void add_local(const std::string& varname, const as_value& val)
- {
- assert(varname.length() > 0); // null varnames are invalid!
- assert(_localFrames.size());
- LocalVars& locals = _localFrames.back().locals;
- locals.push_back(frame_slot(varname, val));
- }
+ void add_local(const std::string& varname, const as_value& val);
/// Create the specified local var if it doesn't exist already.
void declare_local(const std::string& varname);
@@ -432,16 +429,14 @@
typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;
/// The locals container
- typedef std::vector<frame_slot> LocalVars;
+ //typedef std::vector<frame_slot> LocalVars;
+ typedef boost::intrusive_ptr<as_object> LocalVars;
typedef std::vector<as_value> Registers;
struct CallFrame
{
- CallFrame(as_function* funcPtr)
- :
- func(funcPtr)
- {}
+ CallFrame(as_function* funcPtr);
/// function use this
LocalVars locals;
@@ -537,9 +532,9 @@
///
/// @return true if the variable was found, false otherwise
///
- bool findLocal(const std::string& varname, frame_slot& ret, bool
descend=false);
+ bool findLocal(const std::string& varname, as_value& ret, bool
descend=false);
- bool findLocal(const std::string& varname, frame_slot& ret, bool
descend=false) const
+ bool findLocal(const std::string& varname, as_value& ret, bool
descend=false) const
{
return const_cast<as_environment*>(this)->findLocal(varname,
ret, descend);
}
@@ -555,7 +550,7 @@
///
/// @return true if the variable was found, false otherwise
///
- static bool findLocal(LocalVars& locals, const std::string& name,
frame_slot& ret);
+ static bool findLocal(LocalVars& locals, const std::string& name,
as_value& ret);
/// Delete a local variable
//
@@ -566,7 +561,7 @@
/// If true the seek don't stop at current call frame, but
/// descends in upper frames. By default it is false.
///
- /// @return true if the variable was found, false otherwise
+ /// @return true if the variable was found and deleted, false otherwise
///
bool delLocal(const std::string& varname, bool descend=false);
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/10
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/16
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/16
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/26
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/27
- [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve..., Sandro Santilli, 2007/04/28