gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/as_environment.cpp tests...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_environment.cpp tests...
Date: Sun, 14 Oct 2007 21:38:11 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/10/14 21:38:11

Modified files:
        .              : ChangeLog 
        server         : as_environment.cpp 
        testsuite/actionscript.all: with.as 

Log message:
                * server/as_environment.cpp (get_variable_raw, 
set_variable_raw): don't
                  explicitly look in locals for SWF6 and higher, as locals 
should already
                  be in the scope chain; look in scope chain *before* locals in 
the
                  SWF5- case (only 'with stack' in that case).
                * testsuite/actionscript.all/with.as: fixed a couple of tests 
about locals
                  and 'with' stack seek order.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4605&r2=1.4606
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.95&r2=1.96
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/with.as?cvsroot=gnash&r1=1.27&r2=1.28

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4605
retrieving revision 1.4606
diff -u -b -r1.4605 -r1.4606
--- ChangeLog   14 Oct 2007 20:36:42 -0000      1.4605
+++ ChangeLog   14 Oct 2007 21:38:10 -0000      1.4606
@@ -1,5 +1,14 @@
 2007-10-14 Sandro Santilli <address@hidden>
 
+       * server/as_environment.cpp (get_variable_raw, set_variable_raw): don't
+         explicitly look in locals for SWF6 and higher, as locals should 
already
+         be in the scope chain; look in scope chain *before* locals in the
+         SWF5- case (only 'with stack' in that case).
+       * testsuite/actionscript.all/with.as: fixed a couple of tests about 
locals
+         and 'with' stack seek order.
+
+2007-10-14 Sandro Santilli <address@hidden>
+
        * server/as_environment.cpp (get_variable_raw): reduce calls to
          string_table::find.
        * testsuite/misc-ming.all/Makefile.am: don't build and run 
PlaceObject2Test

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -b -r1.95 -r1.96
--- server/as_environment.cpp   14 Oct 2007 20:36:43 -0000      1.95
+++ server/as_environment.cpp   14 Oct 2007 21:38:11 -0000      1.96
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: as_environment.cpp,v 1.95 2007/10/14 20:36:43 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.96 2007/10/14 21:38:11 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -112,7 +112,7 @@
     string_table& st = vm.getStringTable();
     string_table::key key = st.find(varname);
 
-    // Check the with-stack.
+    // Check the scope stack.
     for (size_t i = scopeStack.size(); i > 0; --i)
     {
         // const_cast needed due to non-const as_object::get_member 
@@ -126,14 +126,16 @@
     }
 
     // Check locals for getting them
-    //as_environment::frame_slot slot;
+    if ( swfVersion < 6 ) // for SWF6 and up locals should be in the scope 
stack
+    {
     if ( findLocal(varname, val, retTarget) ) 
     {
         return val;
     }
+    }
 
 
-    // Check current target members.
+    // Check current target members. TODO: shouldn't target be in scope stack ?
     if (m_target->get_member(key, &val)) {
         if ( retTarget ) *retTarget = m_target;
         return val;
@@ -280,28 +282,54 @@
     const ScopeStack& scopeStack)
 {
 
-       string_table::key varkey = VM::get().getStringTable().find(varname);
+    VM& vm = VM::get();
+    int swfVersion = vm.getSWFVersion();
+    string_table& st = vm.getStringTable();
+    string_table::key varkey = st.find(varname);
 
-       // Check locals for setting them
-       // TODO: check if local variable takes precedence over 'with' scope 
when setting
-       if ( setLocal(varname, val) )
+    if ( swfVersion < 6 ) 
        {
+        // in SWF5 and lower, scope stack should just contain 'with' elements 
+
+        // Check the with-stack.
+        for (size_t i = scopeStack.size(); i > 0; --i)
+        {
+            // const_cast needed due to non-const as_object::get_member 
+            as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
+            as_value   dummy;
+            if (obj && obj->get_member(varkey, &dummy))
+            {
+                // This object has the member; so set it here.
+                obj->set_member(varkey, val);
                return;
        }
+        }
 
-       // Check the with-stack.
+        // Check locals for setting them
+        if ( setLocal(varname, val) ) return;
+
+    }
+    else // SWF >= 6
+    {
+
+        // Check the scope-stack (would include locals)
+        //
        for (size_t i = scopeStack.size(); i > 0; --i)
        {
                // const_cast needed due to non-const as_object::get_member 
                as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
                as_value        dummy;
-               if (obj && obj->get_member(varkey, &dummy)) {
+            if (obj && obj->get_member(varkey, &dummy))
+            {
                    // This object has the member; so set it here.
                    obj->set_member(varkey, val);
                    return;
                }
        }
     
+    }
+    
+    // TODO: shouldn't m_target be in the scope chain ?
        assert(m_target);
        m_target->set_member(varkey, val);
 }

Index: testsuite/actionscript.all/with.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/with.as,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- testsuite/actionscript.all/with.as  12 Oct 2007 01:59:53 -0000      1.27
+++ testsuite/actionscript.all/with.as  14 Oct 2007 21:38:11 -0000      1.28
@@ -21,7 +21,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: with.as,v 1.27 2007/10/12 01:59:53 zoulunkai Exp $";
+rcsid="$Id: with.as,v 1.28 2007/10/14 21:38:11 strk Exp $";
 
 #include "check.as"
 
@@ -397,7 +397,7 @@
        check_equals(c, "with o");
        check_equals(d, "with o");
        check_equals(typeof(e), "undefined");
-       xcheck_equals(f, "empty"); // gnash fails by giving precedence to 
locals when setting the variable in 'with' context
+       check_equals(f, "empty"); 
 
        _root.newFunc = function()
        {
@@ -432,7 +432,8 @@
 check_equals(typeof(o.c), 'undefined');
 check_equals(typeof(o.d), 'undefined');
 check_equals(o.e, 'with o');
-xcheck_equals(o.f, 'with o'); // gnash fails by giving precedence to locals 
when setting the variable in 'with' context
+check_equals(o.f, 'with o'); 
+
 asm {
        push  'checkpoint'   
        push  'o.g.h'   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]