예제 #1
0
파일: Abc46.cs 프로젝트: wl3780/as3c
        public void ReadExternal(BinaryReader input)
        {
            #region frame

            char chr;
            _name = "";

            while ((chr = (char)input.ReadByte()) != 0)
            {
                _name += chr;
            }

            #endregion

            #region version

            _minor = input.ReadUInt16();
            _major = input.ReadUInt16();

            if (_major > VERSION_MAJOR)
            {
                throw new Exception(String.Format("Unsupported .abc format {0}.{1}.", MajorVersion, MinorVersion));
            }

            #endregion

            #region cpool_info

            _cpool = new ConstantPool();
            _cpool.ReadExternal(input);

            #endregion

            #region method_info

            uint n = Primitives.ReadU30(input).Value;

            _methods = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MethodInfo method = new MethodInfo();
                method.ReadExternal(input);

                _methods.Add(method);
            }

            #endregion

            #region metadata_info

            n = Primitives.ReadU30(input).Value;

            _metadata = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MetadataInfo metadata = new MetadataInfo();
                metadata.ReadExternal(input);

                _metadata.Add(metadata);
            }

            #endregion

            #region instance_info

            n = Primitives.ReadU30(input).Value;

            _instanceInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                InstanceInfo instanceInfo = new InstanceInfo();
                instanceInfo.ReadExternal(input);

                _instanceInfo.Add(instanceInfo);
            }

            #endregion

            #region class_info

            //n is same as for instance_info

            _classInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                ClassInfo classInfo = new ClassInfo();
                classInfo.ReadExternal(input);

                _classInfo.Add(classInfo);
            }

            #endregion

            #region script_info

            n = Primitives.ReadU30(input).Value;

            _scriptInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                ScriptInfo scriptInfo = new ScriptInfo();
                scriptInfo.ReadExternal(input);

                _scriptInfo.Add(scriptInfo);
            }

            #endregion

            #region method_body_info

            n = Primitives.ReadU30(input).Value;

            _methodBodyInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MethodBodyInfo methodBodyInfo = new MethodBodyInfo();
                methodBodyInfo.ReadExternal(input);

                _methodBodyInfo.Add(methodBodyInfo);
            }

            #endregion
        }
예제 #2
0
파일: Abc46.cs 프로젝트: nguyenbs/as3c
        public void ReadExternal(BinaryReader input)
        {
            #region frame

            char chr;
            _name = "";

            while ((chr = (char)input.ReadByte()) != 0)
            {
                _name += chr;
            }

            #endregion

            #region version

            _minor = input.ReadUInt16();
            _major = input.ReadUInt16();

            if (_major > VERSION_MAJOR)
            {
                throw new Exception(String.Format("Unsupported .abc format {0}.{1}.", MajorVersion, MinorVersion));
            }

            #endregion

            #region cpool_info

            _cpool = new ConstantPool();
            _cpool.ReadExternal(input);

            #endregion

            #region method_info

            uint n = Primitives.ReadU30(input).Value;

            _methods = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MethodInfo method = new MethodInfo();
                method.ReadExternal(input);

                _methods.Add(method);
            }

            #endregion

            #region metadata_info

            n = Primitives.ReadU30(input).Value;

            _metadata = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MetadataInfo metadata = new MetadataInfo();
                metadata.ReadExternal(input);

                _metadata.Add(metadata);
            }

            #endregion

            #region instance_info

            n = Primitives.ReadU30(input).Value;

            _instanceInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                InstanceInfo instanceInfo = new InstanceInfo();
                instanceInfo.ReadExternal(input);

                _instanceInfo.Add(instanceInfo);
            }

            #endregion

            #region class_info

            //n is same as for instance_info

            _classInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                ClassInfo classInfo = new ClassInfo();
                classInfo.ReadExternal(input);

                _classInfo.Add(classInfo);
            }

            #endregion

            #region script_info

            n = Primitives.ReadU30(input).Value;

            _scriptInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                ScriptInfo scriptInfo = new ScriptInfo();
                scriptInfo.ReadExternal(input);

                _scriptInfo.Add(scriptInfo);
            }

            #endregion

            #region method_body_info

            n = Primitives.ReadU30(input).Value;

            _methodBodyInfo = new ArrayList(Capacity.Max(n));

            for (uint i = 0; i < n; ++i)
            {
                MethodBodyInfo methodBodyInfo = new MethodBodyInfo();
                methodBodyInfo.ReadExternal(input);

                _methodBodyInfo.Add(methodBodyInfo);
            }

            #endregion
        }