gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11197: Improve parse logging.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11197: Improve parse logging.
Date: Thu, 02 Jul 2009 16:20:38 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11197
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-07-02 16:20:38 +0200
message:
  Improve parse logging.
modified:
  libcore/asClass.cpp
  libcore/parser/abc_block.cpp
  libcore/parser/abc_block.h
    ------------------------------------------------------------
    revno: 11194.1.36
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-07-02 15:05:53 +0200
    message:
      Log constants by name.
    modified:
      libcore/parser/abc_block.cpp
      libcore/parser/abc_block.h
    ------------------------------------------------------------
    revno: 11194.1.37
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-07-02 15:06:26 +0200
    message:
      Add a space.
    modified:
      libcore/asClass.cpp
=== modified file 'libcore/asClass.cpp'
--- a/libcore/asClass.cpp       2009-06-29 09:42:53 +0000
+++ b/libcore/asClass.cpp       2009-07-02 13:06:26 +0000
@@ -85,7 +85,7 @@
        string_table::key nsname = ns ? ns->getURI() : 0;
 
        //TODO: Set flags.
-       if(slotId == 0) {
+       if (slotId == 0) {
                _prototype->init_member(name, as_value(), 0, nsname);
        }
        else {

=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp      2009-07-02 08:46:07 +0000
+++ b/libcore/parser/abc_block.cpp      2009-07-02 13:05:53 +0000
@@ -209,70 +209,74 @@
 
     switch (_kind)
        {
-       case KIND_SLOT:
-       case KIND_CONST:
-       {
-               _slotID = in->read_V32();
-               _typeIndex = in->read_V32();
-               boost::uint32_t vindex = in->read_V32();
-               log_abc("Slot ID=%u Type=%s Pool index=%u", _slotID, 
pBlock->_stringPool[pBlock->_multinamePool[_typeIndex].getABCName()], vindex);
-               if (vindex)
-               {
-                       if (!pBlock->pool_value(vindex, in->read_u8(), _value))
-                               return false; // Message done by pool_value
-                       _hasValue = true;
-               }
-               else
-                       _hasValue = false;
-               break;
-       }
-       case KIND_METHOD:
-       case KIND_GETTER:
-       case KIND_SETTER:
-       {
-               // Ignore the 'disp_id'
-               in->skip_V32();
-
-               boost::uint32_t offset = in->read_V32();
-               log_abc("Method index=%u", offset);
-               if (offset >= pBlock->_methods.size()) {
-                       log_error(_("Bad method id in trait."));
-                       return false;
-               }
-               _method = pBlock->_methods[offset];
-               break;
-       }
-       case KIND_CLASS:
-       {
-               _slotID = in->read_V32();
-               _classInfoIndex = in->read_V32();
-               log_abc("Slot id: %u Class index: %u Class Name: %s", _slotID, 
-                _classInfoIndex, 
-                pBlock->_stringPool[pBlock->
-                        _classes[_classInfoIndex]->getName()]);
-
-        if (_classInfoIndex >= pBlock->_classes.size()) {
-                       log_error(_("Bad Class id in trait."));
-                       return false;
-               }
-               break;
-       }
-       case KIND_FUNCTION:
-       {
-               _slotID = in->read_V32();
-               boost::uint32_t offset = in->read_V32();
-               if (offset >= pBlock->_methods.size()) {
-                       log_error(_("Bad method id in trait."));
-                       return false;
-               }
-               _method = pBlock->_methods[offset];
-               break;
-       }
-       default:
-       {
-               log_error(_("ABC: Unknown type of trait."));
-//             return false;
-       }
+        case KIND_SLOT:
+        case KIND_CONST:
+        {
+            _slotID = in->read_V32();
+            _typeIndex = in->read_V32();
+            boost::uint32_t vindex = in->read_V32();
+            log_abc("Slot ID=%u Type=%s Pool index=%u", _slotID,
+                    pBlock->_stringPool[
+                    pBlock->_multinamePool[_typeIndex].getABCName()], vindex);
+            
+            if (vindex) {
+                const abc_block::PoolConstant c =
+                    static_cast<abc_block::PoolConstant>(in->read_u8());
+
+                if (!pBlock->pool_value(vindex, c, _value))
+                    return false; // Message done by pool_value
+                _hasValue = true;
+            }
+            else _hasValue = false;
+            break;
+        }
+        case KIND_METHOD:
+        case KIND_GETTER:
+        case KIND_SETTER:
+        {
+            // Ignore the 'disp_id'
+            in->skip_V32();
+
+            boost::uint32_t offset = in->read_V32();
+            log_abc("Method index=%u", offset);
+            if (offset >= pBlock->_methods.size()) {
+                log_error(_("Bad method id in trait."));
+                return false;
+            }
+            _method = pBlock->_methods[offset];
+            break;
+        }
+        case KIND_CLASS:
+        {
+            _slotID = in->read_V32();
+            _classInfoIndex = in->read_V32();
+            log_abc("Slot id: %u Class index: %u Class Name: %s", _slotID, 
+                    _classInfoIndex, 
+                    pBlock->_stringPool[pBlock->
+                            _classes[_classInfoIndex]->getName()]);
+
+            if (_classInfoIndex >= pBlock->_classes.size()) {
+                log_error(_("Bad Class id in trait."));
+                return false;
+            }
+            break;
+        }
+        case KIND_FUNCTION:
+        {
+            _slotID = in->read_V32();
+            boost::uint32_t offset = in->read_V32();
+            if (offset >= pBlock->_methods.size()) {
+                log_error(_("Bad method id in trait."));
+                return false;
+            }
+            _method = pBlock->_methods[offset];
+            break;
+        }
+        default:
+        {
+            log_error(_("ABC: Unknown type of trait."));
+    //         return false;
+        }
        } // end of switch statement
 
        // Ignore the metadata, but it must be read to know how to ignore it.
@@ -407,27 +411,26 @@
 }
 
 asClass *
-abc_block::locateClass(asName &m)
+abc_block::locateClass(asName& m)
 {
-       asClass *found = NULL;
+       asClass* found = 0;
 
        if (m.getNamespace())
        {
                found = m.getNamespace()->getClass(m.getABCName());
-               if (found)
-                       return found;
+               if (found) return found;
        }
        if (m.namespaceSet() && !m.namespaceSet()->empty())
        {
                std::vector<asNamespace*>::const_iterator i;
-               for (i = m.namespaceSet()->begin(); i != 
m.namespaceSet()->end(); ++i)
-               {
+               for (i = m.namespaceSet()->begin(); i != 
m.namespaceSet()->end(); ++i) {
+
                        found = (*i)->getClass(m.getABCName());
-                       if (found)
-                               return found;
+                       if (found) return found;
                }
        }
 
+    log_abc("Failed to locate class in ABC block, looking in Global");
 
     // Look in known built-in classes.
     asNamespace* nsToFind = m.getNamespace();
@@ -544,10 +547,12 @@
        }
        for (unsigned int i = 1; i < count; ++i)
        {
-               boost::uint8_t kind = _stream->read_u8();
+               NamespaceConstant kind =
+            static_cast<NamespaceConstant>(_stream->read_u8());
+
                boost::uint32_t nameIndex = _stream->read_V32();
-               log_abc("Namespace %u: kind %s, index %u, name %s", i,
-                static_cast<int>(kind), nameIndex, _stringPool[nameIndex]);
+               log_abc("Namespace %u: %s, index %u, name %s", i, kind,
+                nameIndex, _stringPool[nameIndex]);
 
                if (nameIndex >= _stringPool.size()) {
                        log_error(_("ABC: Bad string given for namespace."));
@@ -682,7 +687,7 @@
 }
 
 bool
-abc_block::pool_value(boost::uint32_t index, boost::uint8_t type, as_value &v)
+abc_block::pool_value(boost::uint32_t index, PoolConstant type, as_value &v)
 {
        if (!index)
                return true;
@@ -862,7 +867,10 @@
             for (unsigned int j = 0; j < ocount; ++j) {
                                log_abc("  Reading optional arg: %u", j);
                                boost::uint32_t index = _stream->read_V32();
-                               boost::uint8_t kindof = _stream->read_u8();
+                               
+                PoolConstant kindof =
+                    static_cast<PoolConstant>(_stream->read_u8());
+
                                log_abc("   Index: %u Kindof: %u", index, 
kindof);
                                as_value v;
                                if (!pool_value(index, kindof, v)) {
@@ -1368,6 +1376,7 @@
     else {
         std::vector<std::string>::iterator it = 
             std::find(_stringPool.begin(), _stringPool.end(), className);
+        
         if (it == _stringPool.end()) return 0;
         a.setABCName(it - _stringPool.begin());
     }
@@ -1386,5 +1395,102 @@
        multiname->setGlobalName(new_key);      
 }
 
+std::ostream&
+operator<<(std::ostream& o, abc_block::NamespaceConstant c)
+{
+    switch (c)
+    {
+        case abc_block::PRIVATE_NS:
+            return o << "private namespace";
+        case abc_block::CONSTANT_NS:
+            return o << "constant namespace";
+        case abc_block::PACKAGE_NS:
+            return o << "package namespace";
+        case abc_block::PACKAGE_INTERNAL_NS:
+            return o << "package internal namespace";
+        case abc_block::PROTECTED_NS:
+            return o << "protected namespace";
+        case abc_block::EXPLICIT_NS:
+            return o << "explicit namespace";
+        case abc_block::STATIC_PROTECTED_NS:
+            return o << "static protected namespace";
+        default:
+            return o << "invalid namespace constant";
+    }
+}
+
+std::ostream&
+operator<<(std::ostream& o, abc_block::MethodConstant c)
+{
+    switch (c)
+    {
+        case abc_block::METHOD_ARGS:
+            return o << "method arg";
+        case abc_block::METHOD_ACTIVATION:
+            return o << "method activation";
+        case abc_block::METHOD_MORE:
+            return o << "method more";
+        case abc_block::METHOD_OPTIONAL_ARGS:
+            return o << "method optional args";
+        case abc_block::METHOD_IGNORE:
+            return o << "method ignore";
+        case abc_block::METHOD_NATIVE:
+            return o << "method native";
+        case abc_block::METHOD_DEFAULT_NS:
+            return o << "default namespace";
+        case abc_block::METHOD_ARG_NAMES:
+            return o << "method arg names";
+        default:
+            return o << "invalid method constant";
+    }
+}
+
+std::ostream&
+operator<<(std::ostream& o, abc_block::InstanceConstant c)
+{
+    switch (c)
+    {
+        case abc_block::INSTANCE_SEALED:
+            return o << "instance sealed";
+        case abc_block::INSTANCE_FINAL:
+            return o << "instance final";
+        case abc_block::INSTANCE_INTERFACE:
+            return o << "instance interface";
+        case abc_block::INSTANCE_DYNAMIC:
+            return o << "instance dynamic";
+        case abc_block::INSTANCE_PROTECTED_NS:
+            return o << "instance protected namespace";
+        default:
+            return o << "invalid instance constant";
+    }
+}
+
+std::ostream&
+operator<<(std::ostream& o, abc_block::PoolConstant c)
+{
+    switch (c)
+    {
+        case abc_block::POOL_STRING:
+            return o << "pool string";
+        case abc_block::POOL_INTEGER:
+            return o << "pool integer";
+        case abc_block::POOL_UINTEGER:
+            return o << "pool uinteger";
+        case abc_block::POOL_DOUBLE:
+            return o << "pool double";
+        case abc_block::POOL_NAMESPACE:
+            return o << "pool namespace";
+        case abc_block::POOL_FALSE:
+            return o << "pool false";
+        case abc_block::POOL_TRUE:
+            return o << "pool true";
+        case abc_block::POOL_NULL:
+            return o << "pool null";
+        default:
+            return o << "invalid pool constant";
+
+    }
+}
+
 } /* namespace gnash */
 

=== modified file 'libcore/parser/abc_block.h'
--- a/libcore/parser/abc_block.h        2009-06-29 08:24:27 +0000
+++ b/libcore/parser/abc_block.h        2009-07-02 13:05:53 +0000
@@ -140,6 +140,50 @@
 {
 public:
     
+    enum NamespaceConstant
+       {
+               PRIVATE_NS = 0x05,
+        CONSTANT_NS = 0x08,
+               PACKAGE_NS = 0x16,
+               PACKAGE_INTERNAL_NS = 0x17,
+               PROTECTED_NS = 0x18,
+               EXPLICIT_NS = 0x19,
+               STATIC_PROTECTED_NS = 0x1A
+    };
+
+    enum MethodConstant
+    {
+        METHOD_ARGS = 0x01,
+               METHOD_ACTIVATION = 0x02,
+               METHOD_MORE = 0x04,
+               METHOD_OPTIONAL_ARGS = 0x08,
+               METHOD_IGNORE = 0x10,
+               METHOD_NATIVE = 0x20,
+               METHOD_DEFAULT_NS = 0x40,
+               METHOD_ARG_NAMES = 0x80
+    };
+
+    enum InstanceConstant
+    {
+               INSTANCE_SEALED = 0x01,
+               INSTANCE_FINAL = 0x02,
+               INSTANCE_INTERFACE = 0x04,
+               INSTANCE_DYNAMIC = 0x00,
+               INSTANCE_PROTECTED_NS = 0x08
+    };
+
+    enum PoolConstant
+    {
+               POOL_STRING = 0x01,
+               POOL_INTEGER = 0x03,
+               POOL_UINTEGER = 0x04,
+               POOL_DOUBLE = 0x06,
+               POOL_NAMESPACE = 0x08,
+               POOL_FALSE = 0x0A,
+               POOL_TRUE = 0x0B,
+               POOL_NULL = 0x0C
+       };
+    
     typedef std::vector<asNamespace*> NamespaceSet;
 
        abc_block();
@@ -157,8 +201,6 @@
        
     bool read(SWFStream& in);
 
-       bool pool_value(boost::uint32_t index, boost::uint8_t type, as_value 
&v);
-
        void update_global_name(unsigned int multiname_index);
 
     const std::vector<asClass*>& scripts() const {
@@ -209,37 +251,10 @@
 
 private:
        
-    enum Constant
-       {
-               PRIVATE_NS = 0x05,
-               PACKAGE_NS = 0x16,
-               PACKAGE_INTERNAL_NS = 0x17,
-               PROTECTED_NS = 0x18,
-               METHOD_ARGS = 0x01,
-               METHOD_ACTIVATION = 0x02,
-               METHOD_MORE = 0x04,
-               METHOD_OPTIONAL_ARGS = 0x08,
-               METHOD_IGNORE = 0x10,
-               METHOD_NATIVE = 0x20,
-               METHOD_DEFAULT_NS = 0x40,
-               METHOD_ARG_NAMES = 0x80,
-               INSTANCE_SEALED = 0x01,
-               INSTANCE_FINAL = 0x02,
-               INSTANCE_INTERFACE = 0x04,
-               INSTANCE_DYNAMIC = 0x00,
-               INSTANCE_PROTECTED_NS = 0x08,
-               POOL_STRING = 0x01,
-               POOL_INTEGER = 0x03,
-               POOL_UINTEGER = 0x04,
-               POOL_DOUBLE = 0x06,
-               POOL_NAMESPACE = 0x08,
-               POOL_FALSE = 0x0A,
-               POOL_TRUE = 0x0B,
-               POOL_NULL = 0x0C
-       };
-
     friend class abc::Trait;
 
+       bool pool_value(boost::uint32_t index, PoolConstant type, as_value &v);
+
        bool read_version();
        bool read_integer_constants();
        bool read_unsigned_integer_constants();
@@ -289,6 +304,10 @@
 
 };
 
+std::ostream& operator<<(std::ostream& o, abc_block::NamespaceConstant c);
+std::ostream& operator<<(std::ostream& o, abc_block::MethodConstant c);
+std::ostream& operator<<(std::ostream& o, abc_block::InstanceConstant c);
+std::ostream& operator<<(std::ostream& o, abc_block::PoolConstant c);
 
 } 
 


reply via email to

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