[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11556: Drop more unused or obsolete
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11556: Drop more unused or obsolete code. |
Date: |
Fri, 09 Oct 2009 09:07:05 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11556 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-10-09 09:07:05 +0200
message:
Drop more unused or obsolete code.
modified:
libcore/as_environment.cpp
libcore/as_environment.h
libcore/vm/ActionExec.cpp
libcore/vm/ActionExec.h
=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp 2009-10-08 16:09:26 +0000
+++ b/libcore/as_environment.cpp 2009-10-09 06:32:11 +0000
@@ -44,6 +44,48 @@
namespace gnash {
+namespace {
+
+/// Find a variable in the given as_object
+//
+/// @param varname
+/// Name of the local variable
+///
+/// @param ret
+/// If a variable is found it's assigned to this parameter.
+/// Untouched if the variable is not found.
+///
+/// @return true if the variable was found, false otherwise
+bool
+getLocal(as_object* locals, const std::string& name, as_value& ret)
+{
+ string_table& st = getStringTable(*locals);
+ return locals->get_member(st.find(name), &ret);
+}
+
+/// Delete a local variable
+//
+/// @param varname
+/// Name of the local variable
+///
+/// @return true if the variable was found and deleted, false otherwise
+///
+bool
+deleteLocal(as_object* locals, const std::string& varname)
+{
+ string_table& st = getStringTable(*locals);
+ return locals->delProperty(st.find(varname)).second;
+}
+
+as_object*
+getElement(as_object* obj, string_table::key key)
+{
+ //Global_as* gl = getGlobal(*obj);
+ return obj->get_path_element(key);
+}
+
+}
+
as_value as_environment::undefVal;
as_environment::as_environment(VM& vm)
@@ -183,14 +225,8 @@
}
// Check locals for getting them
- if ( swfVersion < 6 ) // for SWF6 and up locals should be in the scope
stack
- {
- if ( findLocal(varname, val, retTarget) )
- {
- return val;
- }
- }
-
+ // for SWF6 and up locals should be in the scope stack
+ if (swfVersion < 6 && findLocal(varname, val, retTarget)) return val;
// Check current target members. TODO: shouldn't target be in scope stack ?
if (m_target)
@@ -300,14 +336,6 @@
return _vm.getGlobal()->delProperty(varkey).second;
}
-// varname must be a plain variable name; no path parsing.
-as_value
-as_environment::get_variable_raw(const std::string& varname) const
-{
- static ScopeStack empty_scopeStack;
- return get_variable_raw(varname, empty_scopeStack);
-}
-
// Given a path to variable, set its value.
void
as_environment::set_variable(const std::string& varname, const as_value& val,
@@ -418,14 +446,6 @@
}
}
-void
-as_environment::set_variable_raw( const std::string& varname,
- const as_value& val)
-{
- static ScopeStack empty_scopeStack;
- set_variable_raw(varname, val, empty_scopeStack);
-}
-
// Set/initialize the value of the local variable.
void
as_environment::set_local(const std::string& varname, const as_value& val)
@@ -461,7 +481,6 @@
assert( ! _localFrames.empty() );
assert( ! varname.empty() ); // null varnames are invalid!
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());
}
}
@@ -487,16 +506,16 @@
log_debug("path: %s, var: %s", thePath, theVar);
#endif
- if ( thePath.empty() ) return false;
+ if (thePath.empty()) return false;
// this check should be performed by callers (getvariable/setvariable
// in particular)
size_t pathlen = thePath.length();
- size_t i = pathlen-1;
+ size_t i = pathlen - 1;
size_t consecutiveColons = 0;
- while ( i && thePath[i--] == ':' )
+ while (i && thePath[i--] == ':')
{
- if ( ++consecutiveColons > 1 )
+ if (++consecutiveColons > 1)
{
#ifdef DEBUG_TARGET_FINDING
log_debug("path '%s' ends with too many colon chars, not "
@@ -518,8 +537,8 @@
{
std::string path;
std::string var;
- if ( ! parse_path(var_path, path, var) ) return false;
- as_object* target_ptr = find_object(path);
+ if (!parse_path(var_path, path, var)) return false;
+ as_object* target_ptr = find_object(path);
if ( ! target_ptr ) return false;
target_ptr->get_member(_vm.getStringTable().find(var), &val);
@@ -533,34 +552,29 @@
next_slash_or_dot(const char* word)
{
for (const char* p = word; *p; p++) {
- if (*p == '.' && p[1] == '.') {
- p++;
- } else if (*p == '.' || *p == '/' || *p == ':') {
- return p;
- }
+ if (*p == '.' && p[1] == '.') {
+ p++;
+ } else if (*p == '.' || *p == '/' || *p == ':') {
+ return p;
+ }
}
return NULL;
}
-// Find the sprite/movie referenced by the given path.
-//
-// Supports both /slash/syntax and dot.syntax
-//
+/// Find the sprite/movie referenced by the given path.
+//
+/// Supports both /slash/syntax and dot.syntax
+//
+/// @return The found DisplayObject or 0 if it is not a DisplayObject.
DisplayObject*
as_environment::find_target(const std::string& path_in) const
{
as_object* o = find_object(path_in);
- if ( o ) return o->toDisplayObject(); // can be NULL (not a
DisplayObject)...
- else return NULL;
+ if (o) return o->toDisplayObject();
+ return 0;
}
-as_object*
-getElement(as_object* obj, string_table::key key)
-{
- //Global_as* gl = getGlobal(*obj);
- return obj->get_path_element(key);
-}
as_object*
as_environment::find_object(const std::string& path,
@@ -802,7 +816,6 @@
PropMap 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;
for (PropMap::iterator i=props.begin(), e=props.end(); i!=e; ++i)
{
@@ -853,55 +866,38 @@
if ( defined ) out << ss.str() << std::endl;
}
-/*private*/
bool
-as_environment::findLocal(const std::string& varname, as_value& ret,
as_object** retTarget)
+as_environment::findLocal(const std::string& varname, as_value& ret,
+ as_object** retTarget) const
{
- if ( _localFrames.empty() ) return false;
- if ( findLocal(_localFrames.back().locals, varname, ret) )
- {
- if ( retTarget ) *retTarget = _localFrames.back().locals;
+ if (_localFrames.empty()) return false;
+
+ if (getLocal(_localFrames.back().locals, varname, ret)) {
+
+ if (retTarget) *retTarget = _localFrames.back().locals;
return true;
}
+
return false;
}
-/* private */
-bool
-as_environment::findLocal(as_object* locals, const std::string& name,
as_value& ret)
-{
- // TODO: get VM passed as arg
- return locals->get_member(_vm.getStringTable().find(name), &ret);
-}
-
-/* private */
-bool
-as_environment::delLocal(as_object* locals, const std::string& varname)
-{
- // TODO: get VM passed as arg
- return locals->delProperty(_vm.getStringTable().find(varname)).second;
-}
-
-/* private */
bool
as_environment::delLocal(const std::string& varname)
{
- if ( _localFrames.empty() ) return false;
- return delLocal(_localFrames.back().locals, varname);
+ if (_localFrames.empty()) return false;
+ return deleteLocal(_localFrames.back().locals, varname);
}
-/* private */
bool
as_environment::setLocal(const std::string& varname, const as_value& val)
{
- if ( _localFrames.empty() ) return false;
+ if (_localFrames.empty()) return false;
return setLocal(_localFrames.back().locals, varname, val);
}
-/* private */
bool
-as_environment::setLocal(as_object* locals,
- const std::string& varname, const as_value& val)
+as_environment::setLocal(as_object* locals, const std::string& varname,
+ const as_value& val)
{
Property* prop =
locals->getOwnProperty(_vm.getStringTable().find(varname));
if ( ! prop ) return false;
@@ -909,15 +905,6 @@
return true;
}
-
-void
-as_environment::padStack(size_t /*offset*/, size_t /*count*/)
-{
- // do nothing here, instead return undefined from top() and pop()
- //assert( offset <= _stack.size() );
- //m_stack.insert(m_stack.begin()+offset, count, as_value());
-}
-
void
as_environment::pushCallFrame(as_function* func)
{
@@ -968,10 +955,10 @@
void
as_environment::add_local(const std::string& varname, const as_value& val)
{
- assert( ! varname.empty() ); // null varnames are invalid!
- assert( ! _localFrames.empty() );
+ assert(!varname.empty());
+ assert(!_localFrames.empty());
+
as_object* locals = _localFrames.back().locals;
- //locals.push_back(frame_slot(varname, val));
locals->set_member(_vm.getStringTable().find(varname), val);
}
@@ -1002,16 +989,14 @@
unsigned int
as_environment::setRegister(unsigned int regnum, const as_value& v)
{
- if ( _localFrames.empty() || _localFrames.back().registers.empty() )
- {
+ if (_localFrames.empty() || _localFrames.back().registers.empty()) {
if ( regnum >= numGlobalRegisters ) return 0;
m_global_register[regnum] = v;
return 1;
}
Registers& registers = _localFrames.back().registers;
- if ( regnum < registers.size() )
- {
+ if (regnum < registers.size()) {
registers[regnum] = v;
return 2;
}
@@ -1022,16 +1007,14 @@
unsigned int
as_environment::getRegister(unsigned int regnum, as_value& v)
{
- if ( _localFrames.empty() || _localFrames.back().registers.empty() )
- {
+ if (_localFrames.empty() || _localFrames.back().registers.empty()) {
if ( regnum >= numGlobalRegisters ) return 0;
v = m_global_register[regnum];
return 1;
}
Registers& registers = _localFrames.back().registers;
- if ( regnum < registers.size() )
- {
+ if (regnum < registers.size()) {
v = registers[regnum];
return 2;
}
@@ -1042,23 +1025,15 @@
void
as_environment::markReachableResources() const
{
- for (size_t i=0; i<4; ++i)
- {
+ for (size_t i = 0; i < 4; ++i) {
m_global_register[i].setReachable();
}
- if ( m_target ) m_target->setReachable();
- if ( _original_target ) _original_target->setReachable();
-
- assert ( _localFrames.empty() );
-#if 1 // I think we expect the stack to be empty !
- for (CallStack::const_iterator i=_localFrames.begin(),
e=_localFrames.end(); i!=e; ++i)
- {
- i->markReachableResources();
- }
-#endif
-
- assert ( _stack.empty() );
+ if (m_target) m_target->setReachable();
+ if (_original_target) _original_target->setReachable();
+
+ assert (_localFrames.empty());
+ assert (_stack.empty());
}
#endif // GNASH_USE_GC
=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h 2009-07-14 15:33:46 +0000
+++ b/libcore/as_environment.h 2009-10-09 06:32:11 +0000
@@ -47,9 +47,6 @@
/// A stack of objects used for variables/members lookup
typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
- /// The variables container (case-insensitive)
- typedef std::map<std::string, as_value, StringNoCaseLessThan> Variables;
-
typedef std::vector<as_value> Registers;
as_environment(VM& vm);
@@ -67,23 +64,20 @@
///
void set_target(DisplayObject* target);
- void set_original_target(DisplayObject* target) { _original_target =
target; }
+ void set_original_target(DisplayObject* target) {
+ _original_target = target;
+ }
DisplayObject* get_original_target() { return _original_target; }
// Reset target to its original value
void reset_target() { m_target = _original_target; }
- /// @name Stack access/manipulation
- /// @{
-
/// Push a value on the stack
- void push(const as_value& val)
- {
+ void push(const as_value& val) {
_stack.push(val);
}
-
/// Pops an as_value off the stack top and return it.
as_value pop()
{
@@ -92,10 +86,6 @@
} catch (StackException&) {
return undefVal;
}
- //assert( ! _stack.empty() );
- //as_value result = m_stack.back();
- //m_stack.pop_back();
- //return result;
}
/// Get stack value at the given distance from top.
@@ -111,9 +101,6 @@
} catch (StackException&) {
return undefVal;
}
- //size_t ssize = m_stack.size();
- //assert ( ssize > dist );
- //return m_stack[ssize - 1 - dist];
}
/// Get stack value at the given distance from bottom.
@@ -129,35 +116,18 @@
} catch (StackException&) {
return undefVal;
}
- //assert ( m_stack.size() > index );
- //return m_stack[index];
}
/// Drop 'count' values off the top of the stack.
- //
- /// Throw StackException if there's not enough to drop
- ///
void drop(size_t count)
{
// in case count > stack size, just drop all, forget about
// exceptions...
_stack.drop(std::min(count, _stack.size()));
- //size_t ssize = m_stack.size();
- //assert ( ssize >= count );
- //m_stack.resize(ssize - count);
}
- /// Insert 'count' undefined values before 'offset'.
- //
- /// An offset of 0 will prepend the values,
- /// An offset of size() [too far] will append the values.
- ///
- void padStack(size_t offset, size_t count);
-
size_t stack_size() const { return _stack.size(); }
- /// @} end of stack access/manipulation
-
/// \brief
/// Return the (possibly UNDEFINED) value of the named variable
//
@@ -168,7 +138,6 @@
/// so make sure you do it yourself. Note that
/// ActionExec performs the conversion
/// before calling this method.
- ///
as_value get_variable(const std::string& varname) const;
/// \brief
@@ -185,7 +154,6 @@
///
/// @param scopeStack
/// The Scope stack to use for lookups.
- ///
bool delVariableRaw(const std::string& varname,
const ScopeStack& scopeStack);
@@ -229,20 +197,6 @@
///
void set_variable(const std::string& path, const as_value& val);
- /// Given a variable name, set its value (no support for path)
- //
- /// If no variable with that name is found, a new one
- /// will be created as a member of current target.
- ///
- /// @param var
- /// Variable name. Can not contain path elements.
- /// TODO: should be case-insensitive up to SWF6.
- ///
- /// @param val
- /// The value to assign to the variable, if found.
- ///
- void set_variable_raw(const std::string& var, const as_value& val);
-
/// \brief
/// Given a path to variable, set its value.
//
@@ -289,14 +243,13 @@
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);
+ void declare_local(const std::string& varname);
/// Add 'count' local registers (add space to end)
//
/// Local registers are only meaningful within a function2 context.
///
- void add_local_registers(unsigned int register_count)
- {
+ void add_local_registers(unsigned int register_count) {
assert(!_localFrames.empty());
return _localFrames.back().registers.resize(register_count);
}
@@ -358,36 +311,31 @@
//
/// Local registers are only meaningful within a function2 context.
///
- as_value& local_register(boost::uint8_t n)
- {
+ as_value& local_register(boost::uint8_t n) {
assert(!_localFrames.empty());
return _localFrames.back().registers[n];
}
- /// Set the Nth local register to something
- void set_local_register(boost::uint8_t n, as_value &val)
- {
- if ( ! _localFrames.empty() )
- {
+ /// Set the Nth local register to something
+ void set_local_register(boost::uint8_t n, as_value &val) {
+ if (! _localFrames.empty()) {
Registers& registers = _localFrames.back().registers;
- if ( n < registers.size() )
- {
+ if (n < registers.size()) {
registers[n] = val;
}
}
}
/// Return a reference to the Nth global register.
- as_value& global_register(unsigned int n)
- {
+ as_value& global_register(unsigned int n) {
assert(n<4);
return m_global_register[n];
}
- /// Set the Nth local register to something
- void set_global_register(boost::uint8_t n, as_value &val) {
+ /// Set the Nth local register to something
+ void set_global_register(boost::uint8_t n, as_value &val) {
if (n <= 4) {
- m_global_register[n] = val;
+ m_global_register[n] = val;
}
}
@@ -533,8 +481,7 @@
VM& _vm;
/// Stack of as_values in this environment
- //std::vector<as_value> m_stack;
- SafeStack<as_value>& _stack;
+ SafeStack<as_value>& _stack;
static const short unsigned int numGlobalRegisters = 4;
@@ -567,16 +514,17 @@
///
void popCallFrame();
- /// Return the (possibly UNDEFINED) value of the named variable.
+ /// Given a variable name, set its value (no support for path)
//
- /// @param varname
+ /// If no variable with that name is found, a new one
+ /// will be created as a member of current target.
+ ///
+ /// @param var
/// Variable name. Can not contain path elements.
- /// NOTE: no case conversion is performed currently,
- /// so make sure you do it yourself.
+ /// TODO: should be case-insensitive up to SWF6.
///
- as_value get_variable_raw(const std::string& varname) const;
-
- /// Given a variable name, set its value (no support for path)
+ /// @param val
+ /// The value to assign to the variable, if found.
void set_variable_raw(const std::string& path, const as_value& val,
const ScopeStack& scopeStack);
@@ -589,7 +537,6 @@
as_value get_variable_raw(const std::string& varname,
const ScopeStack& scopeStack, as_object** retTarget=NULL) const;
-
/// \brief
/// Get a local variable given its name,
//
@@ -606,27 +553,10 @@
///
/// @return true if the variable was found, false otherwise
///
- bool findLocal(const std::string& varname, as_value& ret, as_object**
retTarget=NULL);
-
- bool findLocal(const std::string& varname, as_value& ret, as_object**
retTarget=NULL) const
- {
- return const_cast<as_environment*>(this)->findLocal(varname, ret,
retTarget);
- }
-
- /// Find a variable in the given as_object
- //
- /// @param varname
- /// Name of the local variable
- ///
- /// @param ret
- /// If a variable is found it's assigned to this parameter.
- /// Untouched if the variable is not found.
- ///
- /// @return true if the variable was found, false otherwise
- ///
- bool findLocal(as_object* locals, const std::string& name, as_value& ret);
-
- /// Delete a local variable
+ bool findLocal(const std::string& varname, as_value& ret,
+ as_object** retTarget = 0) const;
+
+ /// Delete a variable from the given as_object
//
/// @param varname
/// Name of the local variable
@@ -635,15 +565,6 @@
///
bool delLocal(const std::string& varname);
- /// Delete a variable from the given as_object
- //
- /// @param varname
- /// Name of the local variable
- ///
- /// @return true if the variable was found, false otherwise
- ///
- bool delLocal(as_object* locals, const std::string& varname);
-
/// Set a local variable, if it exists.
//
/// @param varname
=== modified file 'libcore/vm/ActionExec.cpp'
--- a/libcore/vm/ActionExec.cpp 2009-07-14 13:40:32 +0000
+++ b/libcore/vm/ActionExec.cpp 2009-10-09 06:16:57 +0000
@@ -754,26 +754,6 @@
return obj.get_member(st.find(var), &val);
}
-/*private*/
-void
-ActionExec::fixStackUnderrun(size_t required)
-{
- size_t slots_left = env.stack_size() - _initialStackSize;
- size_t missing = required-slots_left;
-
- // FIXME, the IF_VERBOSE used to be commented out. strk, know why?
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Stack underrun: %d elements required, "
- "%d/%d available. "
- "Fixing by inserting %d undefined values on the"
- " missing slots."),
- required, _initialStackSize, env.stack_size(),
- missing);
- );
-
- env.padStack(_initialStackSize, missing);
-}
-
as_object*
ActionExec::getTarget()
{
=== modified file 'libcore/vm/ActionExec.h'
--- a/libcore/vm/ActionExec.h 2009-06-15 11:32:49 +0000
+++ b/libcore/vm/ActionExec.h 2009-10-09 06:16:57 +0000
@@ -196,16 +196,6 @@
bool _returning;
- /// Warn about a stack underrun and fix it
- //
- /// The fix is padding the stack with undefined
- /// values for the missing slots.
- ///
- /// @param required
- /// Number of items required.
- ///
- void fixStackUnderrun(size_t required);
-
bool _abortOnUnload;
/// Program counter (offset of current action tag)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11556: Drop more unused or obsolete code.,
Benjamin Wolsey <=