gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11132: Get as3compile testcases to


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11132: Get as3compile testcases to run.
Date: Tue, 16 Jun 2009 15:21:33 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11132
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-06-16 15:21:33 +0200
message:
  Get as3compile testcases to run.
  
  Add extremely hairy but (for most people) correct parsing of doubles. This
  is only used in AVM2 (and was dead wrong before), so no regressions.
  as3/basic.swf is expected to pass now.
  
  as3/class.swf shows various problems with the stack, but also runs.
modified:
  libcore/SWFStream.cpp
  libcore/as_object.cpp
  libcore/parser/abc_block.cpp
  libcore/vm/Machine.cpp
  libcore/vm/Machine.h
  testsuite/as3/Makefile.am
  testsuite/as3/class.as
    ------------------------------------------------------------
    revno: 11124.1.12
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:11:39 +0200
    message:
      Complete name.
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 11124.1.13
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:19:26 +0200
    message:
      Include namespace in property lookup.
    modified:
      libcore/as_object.cpp
    ------------------------------------------------------------
    revno: 11124.1.14
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:19:51 +0200
    message:
      Minor cleanup.
    modified:
      libcore/as_object.cpp
    ------------------------------------------------------------
    revno: 11124.1.15
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:36:15 +0200
    message:
      Log end of NEWCLASS.
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 11124.1.16
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:39:13 +0200
    message:
      Get values the right way round.
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 11124.1.17
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 12:53:13 +0200
    message:
      Clean up and log.
    modified:
      libcore/vm/Machine.h
    ------------------------------------------------------------
    revno: 11124.1.18
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:18:35 +0200
    message:
      Get arguments in the right order.
    modified:
      libcore/as_object.cpp
    ------------------------------------------------------------
    revno: 11124.1.19
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:32:53 +0200
    message:
      Expose the Global object.
    modified:
      libcore/vm/Machine.h
    ------------------------------------------------------------
    revno: 11124.1.20
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:34:51 +0200
    message:
      Comments.
    modified:
      libcore/vm/Machine.h
    ------------------------------------------------------------
    revno: 11124.1.21
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:36:31 +0200
    message:
      Reserve slots for namespaces (disabled by default).
    modified:
      libcore/parser/abc_block.cpp
    ------------------------------------------------------------
    revno: 11124.1.22
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:49:02 +0200
    message:
      Only drop object from stack if it is a QName (which is never is right
      now).
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 11124.1.23
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 13:59:37 +0200
    message:
      Enable reserveSlots by default now that the stack isn't so ruined by
      completeName (though it is still wrong for other reasons).
      
      Both basic.swf and class.swf run now, so are sane tests. Some passes,
      lots of failures due to VM bugs, some due to as_object and asClass bugs.
    modified:
      libcore/parser/abc_block.cpp
      testsuite/as3/Makefile.am
      testsuite/as3/basic.as
      testsuite/as3/class.as
    ------------------------------------------------------------
    revno: 11124.1.24
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:21:32 +0200
    message:
      Always access registers through get/setRegister for easier debugging
      (there is a mess up somewhere).
    modified:
      libcore/vm/Machine.cpp
      libcore/vm/Machine.h
    ------------------------------------------------------------
    revno: 11124.1.25
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:22:34 +0200
    message:
      Correct typos.
    modified:
      libcore/vm/Machine.cpp
    ------------------------------------------------------------
    revno: 11124.1.26
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:28:07 +0200
    message:
      Fix ref-to-non-const.
    modified:
      libcore/vm/Machine.cpp
      libcore/vm/Machine.h
    ------------------------------------------------------------
    revno: 11124.1.27
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:54:06 +0200
    message:
      Drop the phoney read_d64 version, add one that actually works (but only
      on little-endian machines and without any Standard compliance) in the
      hope that someone can improve it. Fixes failures in double constant
      parsing and the basic.swf tests.
    modified:
      libcore/SWFStream.cpp
    ------------------------------------------------------------
    revno: 11124.1.28
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:55:41 +0200
    message:
      Tests pass.
    modified:
      testsuite/as3/basic.as
    ------------------------------------------------------------
    revno: 11124.1.29
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Tue 2009-06-16 14:57:30 +0200
    message:
      Drop #endif too.
    modified:
      libcore/SWFStream.cpp
=== modified file 'libcore/SWFStream.cpp'
--- a/libcore/SWFStream.cpp     2009-06-15 11:32:49 +0000
+++ b/libcore/SWFStream.cpp     2009-06-16 13:21:33 +0000
@@ -27,6 +27,7 @@
 
 #include <cstring>
 #include <climits>
+#include <boost/static_assert.hpp>
 
 //#define USE_TU_FILE_BYTESWAPPING 1
 
@@ -305,33 +306,21 @@
 // Read a 64-bit double value
 double SWFStream::read_d64()
 {
-#ifdef USE_TU_FILE_BYTESWAPPING 
-    align();
-    return m_input->read_le_double64();
-#else
-    using boost::uint32_t;
 
+    // TODO: This is very dodgy and doesn't account for endianness!
     const unsigned short dataLength = 8;
-    unsigned char buf[dataLength];
-    
+    double d = 0;
+
+    BOOST_STATIC_ASSERT(sizeof(double) == dataLength);
+
     // Should align:
-    if (read(reinterpret_cast<char*>(buf), dataLength) < dataLength)
+    if (read(reinterpret_cast<char*>(&d), dataLength) < dataLength)
     {
         throw ParserException(_("Unexpected end of stream while reading"));
     }
-    
-    boost::uint64_t low = buf[0];
-    low |= buf[1] << 8;
-    low |= buf[2] << 16;
-    low |= buf[3] << 24;
-
-    boost::uint64_t hi = buf[4];
-    hi |= buf[5] << 8;
-    hi |= buf[6] << 16;
-    hi |= buf[7] << 24;
-
-    return static_cast<long double> ( low | (hi<<32) );
-#endif
+ 
+    return d;
+
 }
 
 boost::uint8_t    SWFStream::read_u8()

=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp     2009-06-16 05:45:41 +0000
+++ b/libcore/as_object.cpp     2009-06-16 11:18:35 +0000
@@ -484,11 +484,10 @@
                if ((i > 255 && swfVersion == 5) || i > 257)
                        throw ActionLimitException("Lookup depth exceeded.");
 
-               Property* prop = obj->_members.getProperty(key);
+               Property* prop = obj->_members.getProperty(key, nsname);
                if (prop && prop->visible(swfVersion) )
                {
-                       if (owner != NULL)
-                               *owner = obj.get();
+                       if (owner) *owner = obj.get();
                        return prop;
                }
                else
@@ -553,7 +552,7 @@
 as_object::reserveSlot(string_table::key name, string_table::key nsId,
        unsigned short slotId)
 {
-       _members.reserveSlot(name, nsId, slotId);
+       _members.reserveSlot(slotId, name, nsId);
 }
 
 bool

=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp      2009-06-16 09:32:44 +0000
+++ b/libcore/parser/abc_block.cpp      2009-06-16 11:59:37 +0000
@@ -28,6 +28,7 @@
 #include "namedStrings.h"
 #include "CodeStream.h"
 #include "action_buffer.h"
+#include "Machine.h"
 
 namespace gnash {
 
@@ -319,6 +320,17 @@
     std::for_each(_traits.begin(), _traits.end(),
             boost::bind(&Trait::finalize, _1, this));
 
+    // If the following is enabled, it reserves slots for all namespaces
+    // in the global object. This means that ABC_ACTION_SETSLOT does not
+    // fail as often, but doesn't really seem quite correct.
+#if 1
+    as_object* global = mach->global();
+    for (std::vector<asNamespace*>::iterator i = _namespacePool.begin(), 
+            e = _namespacePool.end(); i != e; ++i) {
+        assert(global);
+        global->reserveSlot((*i)->getURI(), 0, i - _namespacePool.begin());
+    }
+#endif
     _traits.clear();
 
 }

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2009-06-16 10:13:01 +0000
+++ b/libcore/vm/Machine.cpp    2009-06-16 13:21:33 +0000
@@ -272,7 +272,7 @@
 Machine::Machine(VM& vm)
         :
         mStack(),
-        mRegisters(),
+        _registers(),
         mScopeStack(),
         mStream(0),
         mST(vm.getStringTable()),
@@ -294,7 +294,7 @@
        // Local registers should be initialized at the beginning of each
     // function call, but we don't currently parse the number of local
     // registers for each function.
-    // mRegisters.resize(16);
+    // _registers.resize(16);
 }
 
 
@@ -449,7 +449,7 @@
                 case SWF::ABC_ACTION_KILL:
                 {
                     boost::uint32_t regNum = mStream->read_V32();
-                    mRegisters[regNum].set_undefined();
+                    setRegister(regNum, as_value());
                     break;
                 }
 
@@ -1094,8 +1094,8 @@
                     const boost::int32_t oindex = mStream->read_V32();
                     const boost::int32_t iindex = mStream->read_V32();
 
-                    as_value& objv = mRegisters[oindex];
-                    const as_value& indexv = mRegisters[iindex];
+                    const as_value& objv = getRegister(oindex);
+                    const as_value& indexv = getRegister(iindex);
                     
                     log_abc("HASNEXT2: Object is %s, index is %d",
                             objv, indexv);
@@ -1118,14 +1118,20 @@
 
                     if (next) {
                         push_stack(true);
-                        if (owner) mRegisters[oindex] = owner;
-                        else mRegisters[oindex].set_null();
-                        mRegisters[iindex] = next;
+                        if (owner) setRegister(oindex, owner);
+                        else {
+                            as_value null;
+                            null.set_null();
+                            setRegister(oindex, null);
+                        }
+                        setRegister(iindex, next);
                     }
                     else {
                         push_stack(false);
-                        mRegisters[oindex].set_null();
-                        mRegisters[iindex] = 0.0;
+                        as_value null;
+                        null.set_null();
+                        setRegister(oindex, null);
+                        setRegister(iindex, 0.0);
                     }
                     break;
                 }
@@ -1599,7 +1605,7 @@
                     boost::uint32_t cid = mStream->read_V32();
                     asClass *c = pool_class(cid, mPoolObject);
                     log_abc("Creating new class id=%u name=%s", c->getName(),
-                            mPoolObject->stringPoolAt(c->getName()));
+                            pool_string(c->getName(), mPoolObject));
                     
                     as_object* base_class = pop_stack().to_object().get();
                     as_object* new_class = c->getPrototype();
@@ -1631,6 +1637,9 @@
                     as_value value = call_method(property, env, new_class,
                             get_args(0));
 
+                    log_abc("NEWCLASS(%2%) finished. Return: %1%", value,
+                            pool_string(c->getName(), mPoolObject));
+
                     break;
                 }
                 
@@ -1681,6 +1690,10 @@
                 case SWF::ABC_ACTION_FINDPROPERTY:
                 {
                     asName a = pool_name(mStream->read_V32(), mPoolObject);
+                    if (a.isRuntime()) {
+                        mStack.drop(completeName(a));
+                    }
+
                     as_value ret = find_prop_strict(a);
 
 
@@ -1785,7 +1798,7 @@
                 case SWF::ABC_ACTION_GETLOCAL:
                 {
                     boost::uint32_t index = mStream->read_V32();
-                    push_stack(get_register(index));
+                    push_stack(getRegister(index));
                     break;
                 }
 
@@ -1800,7 +1813,7 @@
                 {
                     boost::uint32_t index = mStream->read_V32();
                     log_abc("Register index: %u",index);
-                    mRegisters[index] = pop_stack();
+                    setRegister(index, pop_stack());
                     break;
                 }
 
@@ -2275,32 +2288,35 @@
                     push_stack(as_value(val.to_number() + 1));
                     break;
                 }
-            /// 0x92 ABC_ACTION_INCLOCAL
-            /// Stream: V32 'frame_addr'
-            /// Frame: Load i from frame_addr and increment it.
+
+                /// 0x92 ABC_ACTION_INCLOCAL
+                /// Stream: V32 'frame_addr'
+                /// Frame: Load i from frame_addr and increment it.
                 case SWF::ABC_ACTION_INCLOCAL:
                 {
                     boost::uint32_t foff = mStream->read_V32();
-                    mRegisters[foff] = mRegisters[foff].to_number() + 1;
+                    setRegister(foff, getRegister(foff).to_number() + 1);
                     break;
                 }
-            /// 0x93 ABC_ACTION_DECREMENT
-            /// Stack In:
-            ///  num -- A number, integer or double
-            /// Stack Out:
-            ///  num - 1
+
+                /// 0x93 ABC_ACTION_DECREMENT
+                /// Stack In:
+                ///  num -- A number, integer or double
+                /// Stack Out:
+                ///  num - 1
                 case SWF::ABC_ACTION_DECREMENT:
                 {
                     mStack.top(0) = mStack.top(0).to_number() - 1;
                     break;
                 }
-            /// 0x94 ABC_ACTION_DECLOCAL
-            /// Stream: V32 'frame_addr'
-            /// Frame: Load i from frame_addr and decrement it.
+
+                /// 0x94 ABC_ACTION_DECLOCAL
+                /// Stream: V32 'frame_addr'
+                /// Frame: Load i from frame_addr and decrement it.
                 case SWF::ABC_ACTION_DECLOCAL:
                 {
-                    boost::uint32_t foff = mStream->read_V32();
-                    mRegisters[foff] = mRegisters[foff].to_number() - 1;
+                    const boost::uint32_t foff = mStream->read_V32();
+                    setRegister(foff, getRegister(foff).to_number() - 1);
                     break;
                 }
 
@@ -2645,23 +2661,28 @@
                 }
 
                 /// 0xC2 ABC_ACTION_INCLOCAL_I
-                /// See: 0x92 (ABC_ACTION_INCLOCAL), but forces types to int, 
not double
+                /// See: 0x92 (ABC_ACTION_INCLOCAL), but forces types to int
+                /// not double
                 case SWF::ABC_ACTION_INCLOCAL_I:
                 {
-                    boost::uint32_t foff = mStream->read_V32();
-                    mRegisters[foff] = mRegisters[foff].to_int() + 1;
+                    const boost::uint32_t foff = mStream->read_V32();
+                    setRegister(foff,  getRegister(foff).to_int() + 1);
                     break;
                 }
-            /// 0xC3 ABC_ACTION_DECLOCAL_I
-            /// See: 0x94 (ABC_ACTION_DECLOCAL), but forces types to int, not 
double
+
+                /// 0xC3 ABC_ACTION_DECLOCAL_I
+                /// See: 0x94 (ABC_ACTION_DECLOCAL), but forces types to int,
+                /// not double
                 case SWF::ABC_ACTION_DECLOCAL_I:
                 {
-                    boost::uint32_t foff = mStream->read_V32();
-                    mRegisters[foff] = mRegisters[foff].to_int() - 1;
+                    const boost::uint32_t foff = mStream->read_V32();
+                    setRegister(foff, getRegister(foff).to_int() - 1);
                     break;
                 }
-            /// 0xC4 ABC_ACTION_NEGATE_I
-            /// See: 0x90 (ABC_ACTION_NEGATE), but forces type to int, not 
double
+
+                /// 0xC4 ABC_ACTION_NEGATE_I
+                /// See: 0x90 (ABC_ACTION_NEGATE), but forces type to int,
+                /// not double
                 case SWF::ABC_ACTION_NEGATE_I:
                 {
                     mStack.top(0) = - mStack.top(0).to_int();
@@ -2672,7 +2693,8 @@
                 /// See: 0xA0 (ABC_ACTION_ADD), but forces type to int
                 case SWF::ABC_ACTION_ADD_I:
                 {
-                    mStack.top(1) = mStack.top(1).to_int() + 
mStack.top(0).to_int();
+                    mStack.top(1) = mStack.top(1).to_int() +
+                        mStack.top(0).to_int();
                     mStack.drop(1);
                     break;
                 }
@@ -2681,25 +2703,28 @@
                 /// See: 0xA1 (ABC_ACTION_SUBTRACT), but forces type to int
                 case SWF::ABC_ACTION_SUBTRACT_I:
                 {
-                    mStack.top(1) = mStack.top(1).to_int() - 
mStack.top(0).to_int();
+                    mStack.top(1) = mStack.top(1).to_int() -
+                        mStack.top(0).to_int();
                     mStack.drop(1);
                     break;
                 }
-            /// 0xC7 ABC_ACTION_MULTIPLY_I
-            /// See: 0xA2 (ABC_ACTION_MULTIPLY), but forces type to int
+
+                /// 0xC7 ABC_ACTION_MULTIPLY_I
+                /// See: 0xA2 (ABC_ACTION_MULTIPLY), but forces type to int
                 case SWF::ABC_ACTION_MULTIPLY_I:
                 {
                     mStack.top(1) = mStack.top(0).to_int() * 
mStack.top(1).to_int();
                     mStack.drop(1);
                     break;
                 }
-            /// 0xD0 ABC_ACTION_GETLOCAL0
-            /// 0xD1 ABC_ACTION_GETLOCAL1
-            /// 0xD2 ABC_ACTION_GETLOCAL2
-            /// 0xD3 ABC_ACTION_GETLOCAL3
-            /// Frame: Load frame[#] as val
-            /// Stack Out:
-            ///  val
+
+                /// 0xD0 ABC_ACTION_GETLOCAL0
+                /// 0xD1 ABC_ACTION_GETLOCAL1
+                /// 0xD2 ABC_ACTION_GETLOCAL2
+                /// 0xD3 ABC_ACTION_GETLOCAL3
+                /// Frame: Load frame[#] as val
+                /// Stack Out:
+                ///  val
                 case SWF::ABC_ACTION_GETLOCAL0:
                 case SWF::ABC_ACTION_GETLOCAL1:
                 case SWF::ABC_ACTION_GETLOCAL2:
@@ -2710,8 +2735,8 @@
             //         mStack.grow(1);
             //         mStack.push() instead?
 
-                    push_stack(get_register(opcode- 
SWF::ABC_ACTION_GETLOCAL0));
-            //         mStack.top(0) = mRegisters.value(opcode - 
SWF::ABC_ACTION_GETLOCAL0);
+                    push_stack(getRegister(opcode- SWF::ABC_ACTION_GETLOCAL0));
+            //         mStack.top(0) = _registers.value(opcode - 
SWF::ABC_ACTION_GETLOCAL0);
                     break;
                 }
             /// 0xD4 ABC_ACTION_SETLOCAL0
@@ -2728,7 +2753,8 @@
                 case SWF::ABC_ACTION_SETLOCAL2:
                 case SWF::ABC_ACTION_SETLOCAL3:
                 {
-                    mRegisters[opcode - SWF::ABC_ACTION_SETLOCAL0] = 
pop_stack();
+                    setRegister(opcode - SWF::ABC_ACTION_SETLOCAL0,
+                            pop_stack());
                     break;
                 }
 
@@ -2847,8 +2873,8 @@
                as_value obj = mStack.top(offset);
                if (obj.is_object() && obj.to_object()->isQName()) {
                        name.fill(obj.to_object().get());
+            ++size;
         }
-               ++size;
 
                if (name.isRtns())
                        ++size; // Ignore the Namespace.
@@ -2973,7 +2999,7 @@
 //     mScopeStack.setAllSizes(s.mScopeTotalSize, s.mScopeStackDepth);
        mScopeStack.setAllSizes(s.mScopeTotalSize, s.mScopeStackDepth);
        mStream = s.mStream;
-       mRegisters = s.mRegisters;
+       _registers = s._registers;
        mCurrentFunction = s.mFunction;
 //     mExitWithReturn = s.mReturn;
 //     mDefaultXMLNamespace = s.mDefaultXMLNamespace;
@@ -2998,7 +3024,7 @@
 //     s.mScopeTotalSize = mScopeStack.totalSize();
        s.mStream = mStream;
        s.to_debug_string();
-       s.mRegisters = mRegisters;
+       s._registers = _registers;
        s.mFunction = mCurrentFunction;
 //     s.mReturn = mExitWithReturn;
 //     s.mDefaultXMLNamespace = mDefaultXMLNamespace;
@@ -3019,7 +3045,7 @@
        log_debug("Loding code stream.");
        mStream = constructor->getBody();
        mCurrentFunction = constructor->getPrototype();
-       mRegisters[0] = as_value(global);
+       setRegister(0, global);
        mGlobalObject = global;
 }
 
@@ -3037,9 +3063,9 @@
        CodeStream *stream = function->getBody();
        load_function(stream, function->getMaxRegisters());
        mExitWithReturn = true;
-       mRegisters[0] = as_value(fn.this_ptr);
+       setRegister(0, fn.this_ptr);
        for (unsigned int i=0;i<fn.nargs;i++) {
-               mRegisters[i+1] = fn.arg(i);
+               setRegister(i + 1, fn.arg(i));
        }
        //TODO:  There is probably a better way to do this.
     //
@@ -3085,10 +3111,10 @@
        mStack.clear();
        mScopeStack.clear();
 
-    // The value at mRegisters[0] is generally pushed to the stack for
+    // The value at _registers[0] is generally pushed to the stack for
     // CONSTRUCTSUPER, which apparently expects the object whose super
     // is to be constructed. Setting it to global as before seems to be wrong.
-       mRegisters[0] = cl->getPrototype();
+       setRegister(0, cl->getPrototype());
        executeCodeblock(ctor->getBody());
     log_debug("Finished instantiating class %s", className);
 }
@@ -3235,8 +3261,8 @@
 void
 Machine::clearRegisters(boost::uint32_t maxRegisters)
 {
-       mRegisters.clear();
-       mRegisters.resize(maxRegisters);
+       _registers.clear();
+       _registers.resize(maxRegisters);
 }
 
 

=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h      2009-06-15 11:32:49 +0000
+++ b/libcore/vm/Machine.h      2009-06-16 12:28:07 +0000
@@ -212,6 +212,16 @@
 
        Machine(VM& vm);
 
+    /// Return the Global object.
+    //
+    /// TODO: is this really necessary? Which object should we
+    /// return anyway, i.e. why not mGlobalObject? (that is null
+    /// at inopportune moments right now, which is why VM::getGlobal()
+    /// is returned.
+    as_object* global() {
+        return _vm.getGlobal();
+    }
+
 private:
        /// The state of the machine.
        class State
@@ -227,7 +237,7 @@
                as_object *mCurrentScope;
                as_value *mGlobalReturn;
                as_object *mThis;
-               std::vector<as_value> mRegisters;
+               std::vector<as_value> _registers;
                abc_function* mFunction;
        void to_debug_string(){
                log_abc("StackDepth=%u StackTotalSize=%u ScopeStackDepth=%u 
ScopeTotalSize=%u",mStackDepth,mStackTotalSize,mScopeStackDepth,mScopeTotalSize);
@@ -272,33 +282,43 @@
 
        void clearRegisters(boost::uint32_t maxRegsiters);
 
-       as_value get_register(int index){
-               log_abc("Getting value at a register %d ",index);
-               return mRegisters[index];
+       const as_value& getRegister(int index){
+               log_abc("Getting value at a register %d ", index);
+               return _registers[index];
        }
 
+    void setRegister(size_t index, const as_value& val) {
+        log_abc("Putting %s in register %s", val, index);
+        if (_registers.size() <= index) {
+            log_abc("Register doesn't exist! Adding new registers!");
+            _registers.resize(index + 1);
+        }
+        _registers[index] = val;
+    }
+
        void push_stack(as_value object){
-               log_abc("Pushing value %s onto stack.",object.toDebugString());
+               log_abc("Pushing value %s onto stack.", object);
                mStack.push(object);
        }
 
        as_value pop_stack(){
                as_value value = mStack.pop();
-               log_abc("Popping value %s off the 
stack.",value.toDebugString());
+               log_abc("Popping value %s off the stack.", value);
                return value;
        }
 
        void push_scope_stack(as_value object){
                boost::intrusive_ptr<as_object> scopeObj = object.to_object();
                assert(scopeObj.get());
-               log_abc("Pushing value %s onto scope 
stack.",object.toDebugString());
+               log_abc("Pushing value %s onto scope stack.", object);
                mScopeStack.push(scopeObj);
                print_scope_stack();
        }
 
        boost::intrusive_ptr<as_object> pop_scope_stack() {
-               log_abc("Popping value off the scope stack.  There will be "
-                "%u items left.",mScopeStack.size()-1);
+               log_abc("Popping value %s off the scope stack.  There will be "
+                "%u items left.", as_value(mScopeStack.top(0)),
+                mScopeStack.size()-1);
                return mScopeStack.pop();
        }
 
@@ -311,7 +331,7 @@
 
        SafeStack<as_value> mStack;
        SafeStack<State> mStateStack;
-       std::vector<as_value> mRegisters;
+       std::vector<as_value> _registers;
        SafeStack<boost::intrusive_ptr<as_object> > mScopeStack;
        CodeStream *mStream;
 

=== modified file 'testsuite/as3/Makefile.am'
--- a/testsuite/as3/Makefile.am 2009-06-15 17:07:37 +0000
+++ b/testsuite/as3/Makefile.am 2009-06-16 11:59:37 +0000
@@ -24,13 +24,13 @@
 
 # These will get executed and parsed for test output
 SANE_AS3TESTS = \
-       $(NULL)
-
-BOGUS_AS3TESTS = \
        basic.as \
        class.as \
        $(NULL)
 
+BOGUS_AS3TESTS = \
+       $(NULL)
+
 AS3TESTS=$(SANE_AS3TESTS) $(BOGUS_AS3TESTS)
 
 EXTRA_DIST = $(AS3TESTS) dejagnu.as

=== modified file 'testsuite/as3/class.as'
--- a/testsuite/as3/class.as    2009-06-15 19:42:48 +0000
+++ b/testsuite/as3/class.as    2009-06-16 11:59:37 +0000
@@ -44,46 +44,48 @@
 
         public function Hello() {
 
-            check_equals(this, "[object Hello]");
-            check_equals(this.constructor, "[class Hello]");
-            check_equals(this.constructor.constructor, "[class Class]");
+            xcheck_equals(this, "[object Hello]");
+            xcheck_equals(this.constructor, "[class Hello]");
+            xcheck_equals(this.constructor.constructor, "[class Class]");
 
-            check_equals(S, "[class S]");
-            check_equals(S.constructor, "[class Class]");
-            check_equals(S.__constructor__, undefined);
+            xcheck_equals(S, "[class S]");
+            xcheck_equals(S.constructor, "[class Class]");
+            xcheck_equals(S.__constructor__, undefined);
             
             check_equals(S.s, null);
-            check_equals(typeof(S.s), "object");
+            xcheck_equals(typeof(S.s), "object");
 
             S.s = "Hello ";
             check_equals(S.s, "Hello ");
 
-            check_equals(Base, "[class Base]");
-            check_equals(Derived, "[class Derived]");
-
-            check_equals(Derived.constructor, "[class Class]");
-            check_equals(Base.constructor, "[class Class]");
-            check_equals(Derived.__constructor__, undefined);
-            check_equals(Base.__constructor__, undefined);
+            trace(Base);
+
+            xcheck_equals(Base, "[class Base]");
+            xcheck_equals(Derived, "[class Derived]");
+
+            xcheck_equals(Derived.constructor, "[class Class]");
+            xcheck_equals(Base.constructor, "[class Class]");
+            xcheck_equals(Derived.__constructor__, undefined);
+            xcheck_equals(Base.__constructor__, undefined);
 
             var b1 : Base = new Base();
-            check(b1 instanceof Base);
+            xcheck(b1 instanceof Base);
             check(!(b1 instanceof Derived));
             check_equals(S.s, "Hello Base ");
             
-            check_equals(b1.constructor, "[class Base]");
+            xcheck_equals(b1.constructor, "[class Base]");
             
             S.s = "";
             var b2 : Base = new Derived();
-            check(b2 instanceof Base);
-            check(b2 instanceof Derived);
-            check_equals(S.s, "Base Derived ");
+            xcheck(b2 instanceof Base);
+            xcheck(b2 instanceof Derived);
+            xcheck_equals(S.s, "Base Derived ");
 
             S.s = "";
             var d1 : Derived = new Derived();
-            check(d1 instanceof Base);
-            check(d1 instanceof Derived);
-            check_equals(S.s, "Base Derived ");
+            xcheck(d1 instanceof Base);
+            xcheck(d1 instanceof Derived);
+            xcheck_equals(S.s, "Base Derived ");
 
             totals(25);
 


reply via email to

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