[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12329: Code cleanups, drop unused v
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12329: Code cleanups, drop unused variables and functions. |
Date: |
Fri, 23 Jul 2010 17:30:52 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12329 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2010-07-23 17:30:52 +0200
message:
Code cleanups, drop unused variables and functions.
Minor fix and additional test for delete behaviour.
renamed:
libcore/vm/CodeStream.cpp => libcore/abc/CodeStream.cpp
libcore/vm/CodeStream.h => libcore/abc/CodeStream.h
modified:
libbase/GnashImagePng.cpp
libcore/Makefile.am
libcore/swf_function.h
libcore/vm/ASHandlers.cpp
libcore/vm/ActionExec.cpp
libcore/vm/ActionExec.h
libcore/vm/Makefile.am
testsuite/actionscript.all/delete.as
=== modified file 'libbase/GnashImagePng.cpp'
--- a/libbase/GnashImagePng.cpp 2010-02-10 19:21:36 +0000
+++ b/libbase/GnashImagePng.cpp 2010-07-23 12:52:56 +0000
@@ -145,33 +145,25 @@
// Set our user-defined reader function
png_set_read_fn(_pngPtr, _inStream.get(), &readData);
-
png_read_info(_pngPtr, _infoPtr);
png_byte type = png_get_color_type(_pngPtr, _infoPtr);
png_byte bitDepth = png_get_bit_depth(_pngPtr, _infoPtr);
// Convert indexed images to RGB
- if (type == PNG_COLOR_TYPE_PALETTE)
- {
+ if (type == PNG_COLOR_TYPE_PALETTE) {
log_debug("Converting palette PNG to RGB(A)");
png_set_palette_to_rgb(_pngPtr);
}
// Convert less-than-8-bit greyscale to 8 bit.
- if (type == PNG_COLOR_TYPE_GRAY && bitDepth < 8)
- {
+ if (type == PNG_COLOR_TYPE_GRAY && bitDepth < 8) {
log_debug("Setting grey bit depth(%d) to 8", bitDepth);
-#if PNG_LIBPNG_VER_MINOR == 4
png_set_expand_gray_1_2_4_to_8(_pngPtr);
-#else
- png_set_gray_1_2_4_to_8(_pngPtr);
-#endif
}
// Apply the transparency block if it exists.
- if (png_get_valid(_pngPtr, _infoPtr, PNG_INFO_tRNS))
- {
+ if (png_get_valid(_pngPtr, _infoPtr, PNG_INFO_tRNS)) {
log_debug("Applying transparency block, image is RGBA");
png_set_tRNS_to_alpha(_pngPtr);
_type = GNASH_IMAGE_RGBA;
=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am 2010-07-22 11:56:51 +0000
+++ b/libcore/Makefile.am 2010-07-23 12:49:43 +0000
@@ -139,6 +139,7 @@
if ENABLE_AVM2
libgnashcore_la_SOURCES += \
+ abc/CodeStream.cpp \
abc/Class.cpp \
abc/Namespace.cpp \
abc/as_class.cpp \
@@ -220,6 +221,7 @@
if ENABLE_AVM2
noinst_HEADERS += \
+ abc/CodeStream.h \
abc/Class.h \
abc/Namespace.h \
swf/DoABCTag.h \
=== renamed file 'libcore/vm/CodeStream.cpp' => 'libcore/abc/CodeStream.cpp'
=== renamed file 'libcore/vm/CodeStream.h' => 'libcore/abc/CodeStream.h'
=== modified file 'libcore/swf_function.h'
--- a/libcore/swf_function.h 2010-07-23 07:47:23 +0000
+++ b/libcore/swf_function.h 2010-07-23 13:16:23 +0000
@@ -107,11 +107,6 @@
return _length;
}
- bool isFunction2() const
- {
- return _isFunction2;
- }
-
void set_is_function2() { _isFunction2 = true; }
size_t registers() const {
@@ -173,8 +168,8 @@
struct Argument
{
- Argument(int r, string_table::key n) : reg(r), name(n) {}
- int reg;
+ Argument(boost::uint8_t r, string_table::key n) : reg(r), name(n) {}
+ boost::uint8_t reg;
string_table::key name;
};
@@ -193,6 +188,5 @@
} // end of gnash namespace
-// __GNASH_SWF_FUNCTION_H__
#endif
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2010-07-23 08:56:49 +0000
+++ b/libcore/vm/ASHandlers.cpp 2010-07-23 14:12:47 +0000
@@ -1749,8 +1749,6 @@
void
ActionGetTimer(ActionExec& thread)
{
-
-
as_environment& env = thread.env;
const VM& vm = getVM(env);
@@ -1760,7 +1758,6 @@
void
ActionMbSubString(ActionExec& thread)
{
-
as_environment& env = thread.env;
const as_value& arg0 = env.top(0);
@@ -1912,7 +1909,6 @@
void
ActionWaitForFrameExpression(ActionExec& thread)
{
-
as_environment& env = thread.env;
const action_buffer& code = thread.code;
@@ -2140,8 +2136,6 @@
void
ActionBranchAlways(ActionExec& thread)
{
-
-
boost::int16_t offset = thread.code.read_int16(thread.getCurrentPC()+3);
thread.adjustNextPC(offset);
// @@ TODO range checks
@@ -2150,7 +2144,6 @@
void
ActionGetUrl2(ActionExec& thread)
{
-
as_environment& env = thread.env;
const action_buffer& code = thread.code;
@@ -2176,8 +2169,6 @@
void
ActionBranchIfTrue(ActionExec& thread)
{
-
- // Alias these
as_environment& env = thread.env;
const action_buffer& code = thread.code;
size_t pc = thread.getCurrentPC();
@@ -2209,7 +2200,6 @@
void
ActionCallFrame(ActionExec& thread)
{
- //GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
const std::string& target_frame = env.top(0).to_string();
@@ -2242,13 +2232,11 @@
void
ActionGotoExpression(ActionExec& thread)
{
-
as_environment& env = thread.env;
const action_buffer& code = thread.code;
size_t pc = thread.getCurrentPC();
-
// From Alexis SWF ref:
//
// Pop a value or a string and jump to the specified
@@ -2260,7 +2248,6 @@
// When f_play is ON, the action is to play as soon as
// that frame is reached. Otherwise, the
// frame is shown in stop mode.
-
unsigned char play_flag = code[pc + 3];
const MovieClip::PlayState state =
play_flag ? MovieClip::PLAYSTATE_PLAY : MovieClip::PLAYSTATE_STOP;
@@ -2310,7 +2297,6 @@
void
ActionDelete(ActionExec& thread)
{
- //GNASH_REPORT_FUNCTION;
as_environment& env = thread.env;
#if GNASH_PARANOIA_LEVEL > 1
@@ -2343,8 +2329,7 @@
//
// In both cases, if there are two or more items on the stack, they
// have to be property and object.
- if (stackSize < 2)
- {
+ if (stackSize < 2) {
if (version > 6) {
env.top(1).set_bool(false);
env.drop(1);
@@ -2352,34 +2337,33 @@
}
std::string path, var;
- if (!parsePath(propertyname, path, var))
- {
+ if (!parsePath(propertyname, path, var)) {
// It's not a path. For SWF 7 and above, don't delete. Otherwise
// assume it's a variable and try to delete.
env.top(1).set_bool(thread.delVariable(propertyname));
+ env.drop(1);
+ return;
}
- else
- {
+ else {
as_value target = thread.getVariable(path);
-
- if ( target.is_object() ) // Don't syntetize one otherwise !!
- {
+
+ // Don't create an object! Only get the value if it is an object
+ // already.
+ if (target.is_object()) {
obj = toObject(getGlobal(thread.env), target);
-
propertyname = var;
}
}
}
- else
- {
- if ( env.top(1).is_object() ) // Don't syntetize one otherwise !!
- {
+ else {
+ // Don't create an object! Only get the value if it is an object
+ // already.
+ if (env.top(1).is_object()) {
obj = toObject(getGlobal(thread.env), env.top(1));
}
}
- if (!obj)
- {
+ if (!obj) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("delete %s.%s: no object found to delete"),
env.top(1), env.top(0));
@@ -3575,19 +3559,17 @@
if (!doFinally) finallySize = 0;
if (!doCatch) catchSize = 0;
- if (!catchInRegister)
- {
+ if (!catchInRegister) {
catchName = code.read_string(i);
i += strlen(catchName) + 1;
- TryBlock t(i, trySize, catchSize, finallySize, catchName);
- thread.pushTryBlock(t);
+ thread.pushTryBlock(
+ TryBlock(i, trySize, catchSize, finallySize, catchName));
}
- else
- {
+ else {
catchRegister = code[i];
++i;
- TryBlock t(i, trySize, catchSize, finallySize, catchRegister);
- thread.pushTryBlock(t);
+ thread.pushTryBlock(
+ TryBlock(i, trySize, catchSize, finallySize, catchRegister));
}
thread.setNextPC(i); // Proceed into the try block.
=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2010-07-23 08:10:09 +0000
+++ b/libcore/vm/ActionExec.cpp 2010-07-23 14:22:11 +0000
@@ -70,6 +70,9 @@
ActionExec::ActionExec(const swf_function& func, as_environment& newEnv,
as_value* nRetVal, as_object* this_ptr)
:
+ code(func.getActionBuffer()),
+ env(newEnv),
+ retval(nRetVal),
_withStack(),
_scopeStack(func.getScopeStack()),
_withStackLimit(7),
@@ -83,10 +86,7 @@
_abortOnUnload(false),
pc(func.getStartPC()),
next_pc(pc),
- stop_pc(pc + func.getLength()),
- code(func.getActionBuffer()),
- env(newEnv),
- retval(nRetVal)
+ stop_pc(pc + func.getLength())
{
assert(stop_pc < code.size());
@@ -120,8 +120,11 @@
ActionExec::ActionExec(const action_buffer& abuf, as_environment& newEnv,
bool abortOnUnloaded)
:
+ code(abuf),
+ env(newEnv),
+ retval(0),
_withStack(),
- _scopeStack(), // TODO: initialize the scope stack somehow
+ _scopeStack(),
_withStackLimit(7),
_func(0),
_initialStackSize(0),
@@ -132,10 +135,7 @@
_abortOnUnload(abortOnUnloaded),
pc(0),
next_pc(0),
- stop_pc(abuf.size()),
- code(abuf),
- env(newEnv),
- retval(0)
+ stop_pc(abuf.size())
{
/// See comment in header
// TODO: stack limit dependent on function version or VM version ?
@@ -589,9 +589,6 @@
// Have movie_root flush any newly pushed actions in higher priority queues
getRoot(env).flushHigherPriorityActionQueues();
-// log_debug("After cleanup of ActionExec %p, env %p has "
-// "stack size of %d and callStackDepth of %d",
-// (void*)this, (void*)&env, env.stack_size(), env.callStackDepth());
}
void
@@ -714,7 +711,7 @@
}
void
-ActionExec::pushTryBlock(TryBlock& t)
+ActionExec::pushTryBlock(TryBlock t)
{
// The current block should end at the end of the try block.
t._savedEndOffset = stop_pc;
@@ -745,12 +742,6 @@
next_pc += offset;
}
-bool
-ActionExec::isFunction2() const
-{
- return _func ? _func->isFunction2() : false;
-}
-
void
ActionExec::dumpActions(size_t from, size_t to, std::ostream& os)
{
=== modified file 'libcore/vm/ActionExec.h'
--- a/libcore/vm/ActionExec.h 2010-07-22 12:02:11 +0000
+++ b/libcore/vm/ActionExec.h 2010-07-23 14:22:11 +0000
@@ -116,6 +116,171 @@
class ActionExec : boost::noncopyable
{
+ typedef as_environment::ScopeStack ScopeStack;
+
+public:
+
+ /// Create an execution thread
+ //
+ /// @param abuf
+ /// the action code
+ ///
+ /// @param newEnv
+ /// the execution environment (variables scope, stack etc.)
+ ///
+ /// @param abortOnUnloaded
+ /// If true (the default) execution aborts as soon as the target
+ /// sprite is unloaded.
+ /// NOTE: original target is fetched from the environment.
+ ///
+ ActionExec(const action_buffer& abuf, as_environment& newEnv,
+ bool abortOnUnloaded = true);
+
+ /// Create an execution thread for a function call.
+ //
+ /// @param func The function
+ /// @param newEnv The execution environment (variables scope, stack
etc.)
+ /// @param nRetval Where to return a value. If NULL any return will
+ /// be discarded.
+ ActionExec(const swf_function& func, as_environment& newEnv,
+ as_value* nRetVal, as_object* this_ptr);
+
+ /// \brief
+ /// Use this to push a try block.
+ /// t will be copied
+ void pushTryBlock(TryBlock t);
+
+ /// \brief
+ /// Set the return value.
+ void pushReturn(const as_value& t);
+
+ /// The actual action buffer
+ //
+ /// TODO: provide a getter and make private
+ ///
+ const action_buffer& code;
+
+ /// TODO: provide a getter and make private ?
+ as_environment& env;
+
+ /// TODO: provide a setter and make private ?
+ as_value* retval;
+
+ /// Is this execution thread a function call ?
+ bool isFunction() const { return _func != 0; }
+
+ /// Get the current 'this' pointer, for use in function calls
+ as_object* getThisPointer();
+
+ /// Returns the scope stack associated with this execution thread
+ const ScopeStack& getScopeStack() const
+ {
+ return _scopeStack;
+ }
+
+ /// Push an entry to the with stack
+ //
+ /// @return true if the entry was pushed, false otherwise. This
+ /// depends on the with stack limit.
+ bool pushWith(const With& entry);
+
+ /// Skip the specified number of action tags
+ //
+ /// The offset is relative to next_pc
+ ///
+ void skip_actions(size_t offset);
+
+ /// Delete named variable, seeking for it in the with stack if any
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ bool delVariable(const std::string& name);
+
+ /// Delete a named object member.
+ //
+ /// @param obj
+ /// The object to remove the member/property from.
+ ///
+ /// @param name
+ /// Name of the member.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ /// @return true if the member was successfully removed, false
otherwise.
+ ///
+ bool delObjectMember(as_object& obj, const std::string& name);
+
+ /// Set a named variable, seeking for it in the with stack if any.
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ void setVariable(const std::string& name, const as_value& val);
+
+ /// \brief
+ /// If in a function context set a local variable,
+ /// otherwise, set a normal variable.
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ void setLocalVariable(const std::string& name, const as_value& val);
+
+ /// Get a named variable, seeking for it in the with stack if any.
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ as_value getVariable(const std::string& name);
+
+ /// Get a named variable, seeking for it in the with stack if any.
+ //
+ /// @param name
+ /// Name of the variable. Supports slash and dot syntax.
+ /// Name is converted to lowercase if SWF version is < 7.
+ ///
+ /// @param target
+ /// An output parameter, will be set to point to the object
+ /// containing any found variable.
+ /// The pointer may be set to NULL if the variable was not
+ /// found or it belongs to no object (absolute references, for
instance).
+ ///
+ as_value getVariable(const std::string& name, as_object** target);
+
+ /// Get current target.
+ //
+ /// This function returns top 'with' stack entry, if any.
+ /// Main use for this function is for calling methods and
+ /// properly setting the "this" pointer.
+ ///
+ /// TODO:
+ /// A better, cleaner and less error-prone approach
+ /// would be providing a callFunction() method in
+ /// ActionExec. This will likely help debugger too
+ as_object* getTarget();
+
+ /// Execute.
+ void operator()();
+
+ // TODO: cut down these accessors.
+ bool atActionTag(SWF::ActionType t) { return code[pc] == t; }
+
+ size_t getCurrentPC() const { return pc; }
+
+ void skipRemainingBuffer() { next_pc = stop_pc; }
+
+ void adjustNextPC(int offset);
+
+ size_t getNextPC() const { return next_pc; }
+
+ void setNextPC(size_t pc) { next_pc = pc; }
+
+ size_t getStopPC() const { return stop_pc; }
+
private:
/// \brief
@@ -169,8 +334,6 @@
/// the 'with' stack associated with this execution thread
std::vector<With> _withStack;
- typedef as_environment::ScopeStack ScopeStack;
-
/// the scope stack associated with this execution thread
ScopeStack _scopeStack;
@@ -226,174 +389,6 @@
/// Used for try/throw/catch blocks.
size_t stop_pc;
-public:
-
- /// \brief
- /// Use this to push a try block.
- /// t will be copied
- void pushTryBlock(TryBlock& t);
-
- /// \brief
- /// Set the return value.
- void pushReturn(const as_value& t);
-
- /// The actual action buffer
- //
- /// TODO: provide a getter and make private
- ///
- const action_buffer& code;
-
- /// TODO: provide a getter and make private ?
- as_environment& env;
-
- /// TODO: provide a setter and make private ?
- as_value* retval;
-
- /// Create an execution thread
- //
- /// @param abuf
- /// the action code
- ///
- /// @param newEnv
- /// the execution environment (variables scope, stack etc.)
- ///
- /// @param abortOnUnloaded
- /// If true (the default) execution aborts as soon as the target
sprite is unloaded.
- /// NOTE: original target is fetched from the environment.
- ///
- ActionExec(const action_buffer& abuf, as_environment& newEnv, bool
abortOnUnloaded=true);
-
- /// Create an execution thread for a function call.
- //
- /// @param func
- /// The function
- ///
- /// @param newEnv
- /// The execution environment (variables scope, stack etc.)
- ///
- /// @param nRetval
- /// Where to return a value. If NULL any return will be discarded.
- ///
- ActionExec(const swf_function& func, as_environment& newEnv, as_value*
nRetVal, as_object* this_ptr);
-
- /// Is this execution thread a function2 call ?
- bool isFunction2() const;
-
- /// Is this execution thread a function call ?
- bool isFunction() const { return _func != 0; }
-
- /// Get the current 'this' pointer, for use in function calls
- as_object* getThisPointer();
-
- /// Returns the scope stack associated with this execution thread
- const ScopeStack& getScopeStack() const
- {
- return _scopeStack;
- }
-
- /// Push an entry to the with stack
- //
- /// @return true if the entry was pushed, false otherwise. This
- /// depends on the with stack limit.
- bool pushWith(const With& entry);
-
- /// Skip the specified number of action tags
- //
- /// The offset is relative to next_pc
- ///
- void skip_actions(size_t offset);
-
- /// Delete named variable, seeking for it in the with stack if any
- //
- /// @param name
- /// Name of the variable. Supports slash and dot syntax.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- bool delVariable(const std::string& name);
-
- /// Delete a named object member.
- //
- /// @param obj
- /// The object to remove the member/property from.
- ///
- /// @param name
- /// Name of the member.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- /// @return true if the member was successfully removed, false
otherwise.
- ///
- bool delObjectMember(as_object& obj, const std::string& name);
-
- /// Set a named variable, seeking for it in the with stack if any.
- //
- /// @param name
- /// Name of the variable. Supports slash and dot syntax.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- void setVariable(const std::string& name, const as_value& val);
-
- /// \brief
- /// If in a function context set a local variable,
- /// otherwise, set a normal variable.
- //
- /// @param name
- /// Name of the variable. Supports slash and dot syntax.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- void setLocalVariable(const std::string& name, const as_value& val);
-
- /// Get a named variable, seeking for it in the with stack if any.
- //
- /// @param name
- /// Name of the variable. Supports slash and dot syntax.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- as_value getVariable(const std::string& name);
-
- /// Get a named variable, seeking for it in the with stack if any.
- //
- /// @param name
- /// Name of the variable. Supports slash and dot syntax.
- /// Name is converted to lowercase if SWF version is < 7.
- ///
- /// @param target
- /// An output parameter, will be set to point to the object
- /// containing any found variable.
- /// The pointer may be set to NULL if the variable was not
- /// found or it belongs to no object (absolute references, for
instance).
- ///
- as_value getVariable(const std::string& name, as_object** target);
-
- /// Get current target.
- //
- /// This function returns top 'with' stack entry, if any.
- /// Main use for this function is for calling methods and
- /// properly setting the "this" pointer.
- ///
- /// TODO:
- /// A better, cleaner and less error-prone approach
- /// would be providing a callFunction() method in
- /// ActionExec. This will likely help debugger too
- as_object* getTarget();
-
- /// Execute.
- void operator()();
-
- // TODO: cut down these accessors.
- bool atActionTag(SWF::ActionType t) { return code[pc] == t; }
-
- size_t getCurrentPC() const { return pc; }
-
- void skipRemainingBuffer() { next_pc = stop_pc; }
-
- void adjustNextPC(int offset);
-
- size_t getNextPC() const { return next_pc; }
-
- void setNextPC(size_t pc) { next_pc = pc; }
-
- size_t getStopPC() const { return stop_pc; }
-
};
} // namespace gnash
=== modified file 'libcore/vm/Makefile.am'
--- a/libcore/vm/Makefile.am 2010-07-21 07:23:20 +0000
+++ b/libcore/vm/Makefile.am 2010-07-23 12:49:43 +0000
@@ -47,14 +47,12 @@
if ENABLE_AVM2
libgnashvm_la_SOURCES += \
- CodeStream.cpp \
Machine.cpp
$(NULL)
endif
noinst_HEADERS = \
ASHandlers.h \
- CodeStream.h \
ActionExec.h \
ExecutableCode.h \
$(NULL)
=== modified file 'testsuite/actionscript.all/delete.as'
--- a/testsuite/actionscript.all/delete.as 2008-11-07 21:12:29 +0000
+++ b/testsuite/actionscript.all/delete.as 2010-07-23 13:59:50 +0000
@@ -94,15 +94,29 @@
/* Check deleting a single variable with delete and delete2. This should fail
with delete */
o = 5;
+
+var reto;
+
+// This tests opcode delete called with only one stack item. The
+// result is pushed to a register, then assigned to reto. A normal
+// setvariable call needs the variable to be on the stack before the
+// value, but the the stack would have two items for the delete call...
asm {
push 'o'
delete
+ setregister r:3
+ push 'reto'
+ push r:3
+ setvariable
pop
};
+
#if OUTPUT_VERSION < 7
check_equals(o, undefined)
+ check_equals(reto, true)
#else
check_equals(o, 5);
+ check_equals(reto, false)
#endif
o = 5;
@@ -245,7 +259,7 @@
check_equals(o.b.c, 5);
-totals(27+14);
+totals(27+15);
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12329: Code cleanups, drop unused variables and functions.,
Benjamin Wolsey <=