コード例 #1
0
        public virtual void  readTags(DebugHandler handler)
        {
            System.Collections.ArrayList lineRecords = new System.Collections.ArrayList();

            do
            {
                int tag = (int)in_Renamed.readUI32();
                switch (tag)
                {
                case kDebugScript:
                    DebugModule m  = new DebugModule();
                    int         id = (int)in_Renamed.readUI32();
                    m.id     = id;
                    m.bitmap = (int)in_Renamed.readUI32();
                    m.name   = in_Renamed.readString();
                    m.Text   = in_Renamed.readString();

                    adjustModuleName(m);

                    if (modules.contains(id))
                    {
                        DebugModule m2 = (DebugModule)modules.get_Renamed(id);
                        if (!m.Equals(m2))
                        {
                            handler.error("Module '" + m2.name + "' has the same ID as Module '" + m.name + "'");
                            handler.error("Let's check for kDebugOffset that came before Module '" + m2.name + "'");
                            handler.error("Before: Number of accumulated line records: " + lineRecords.Count);
                            lineRecords = purgeLineRecords(lineRecords, id, handler);
                            handler.error("After: Number of accumulated line records: " + lineRecords.Count);
                        }
                    }
                    modules.put(id, m);
                    handler.module(m);
                    break;

                case kDebugOffset:
                    id = (int)in_Renamed.readUI32();
                    int         lineno = (int)in_Renamed.readUI32();
                    DebugModule module = (DebugModule)modules.get_Renamed(id);
                    LineRecord  lr     = new LineRecord(lineno, module);
                    int         offset = (int)in_Renamed.readUI32();

                    if (module != null)
                    {
                        // not corrupted before we add the offset and offset add fails
                        bool wasCorrupt = module.corrupt;
                        if (!module.addOffset(lr, offset) && !wasCorrupt)
                        {
                            handler.error(module.name + ":" + lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
                        }
                        handler.offset(offset, lr);
                    }
                    else
                    {
                        lineRecords.Add((System.Int32)id);
                        lineRecords.Add(lr);
                        lineRecords.Add((System.Int32)offset);
                    }
                    break;

                case kDebugBreakpoint:
                    handler.breakpoint((int)in_Renamed.readUI32());
                    break;

                case kDebugRegisters:
                {
                    offset = (int)in_Renamed.readUI32();
                    int            size = in_Renamed.readUI8();
                    RegisterRecord r    = new RegisterRecord(offset, size);
                    for (int i = 0; i < size; i++)
                    {
                        int    nbr  = in_Renamed.readUI8();
                        String name = in_Renamed.readString();
                        r.addRegister(nbr, name);
                    }
                    handler.registers(offset, r);
                    break;
                }


                case kDebugID:
                    FlashUUID uuid = new FlashUUID();
                    in_Renamed.readFully(uuid.bytes);
                    handler.uuid(uuid);
                    break;

                case -1:
                    break;

                default:
                    throw new SwfFormatException("Unexpected tag id " + tag);
                }

                if (tag == -1)
                {
                    break;
                }
            }while (true);

            int i2 = 0, size2 = lineRecords.Count;

            while (i2 < size2)
            {
                int        id     = ((System.Int32)lineRecords[i2]);
                LineRecord lr     = (LineRecord)lineRecords[i2 + 1];
                int        offset = ((System.Int32)lineRecords[i2 + 2]);
                lr.module = (DebugModule)modules.get_Renamed(id);

                if (lr.module != null)
                {
                    //System.out.println("updated module "+id+" out of order");
                    // not corrupted before we add the offset and offset add fails
                    bool wasCorrupt = lr.module.corrupt;
                    if (!lr.module.addOffset(lr, offset) && !wasCorrupt)
                    {
                        handler.error(lr.module.name + ":" + lr.lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
                    }

                    handler.offset(offset, lr);
                }
                else
                {
                    handler.error("Could not find debug module (id = " + id + ") for offset = " + offset);
                }

                i2 += 3;
            }
        }
コード例 #2
0
        private Try decodeTry(ActionFactory factory)
        {
            Try a = new Try();

            a.flags = reader.readUI8();
            int trySize     = reader.readUI16();
            int catchSize   = reader.readUI16();
            int finallySize = reader.readUI16();

            if (a.hasRegister())
            {
                a.catchReg = reader.readUI8();
            }
            else
            {
                a.catchName = reader.readString();
            }

            // we have now consumed the try action.  what follows is label mgmt

            int tryEnd = reader.Offset + trySize;

            a.endTry = factory.getLabel(tryEnd);

            // place the catchLabel to mark the end point of the catch handler
            if (a.hasCatch())
            {
                a.endCatch = factory.getLabel(tryEnd + catchSize);
            }

            // place the finallyLabel to mark the end point of the finally handler
            if (a.hasFinally())
            {
                a.endFinally = factory.getLabel(tryEnd + finallySize + (a.hasCatch()?catchSize:0));
            }

            return(a);
        }