Example #1
0
        public static U30 GetNamespace(Abc46 abc, string argument)
        {
            NamespaceInfo ns;

            for (int i = 0, n = abc.ConstantPool.NamespaceTable.Count; i < n; ++i)
            {
                ns = (NamespaceInfo)abc.ConstantPool.NamespaceTable[i];

                string namespaceString = "";

                switch (ns.Kind)
                {
                    case NamespaceInfo.Namespace:
                    case NamespaceInfo.ExplicitNamespace:
                        //TODO implement this
                        //user defined
                        break;
                    case NamespaceInfo.PrivateNs:
                        namespaceString = "private";
                        break;
                    case NamespaceInfo.ProtectedNamespace:
                        namespaceString = "protected";
                        break;
                    case NamespaceInfo.StaticProtectedNs:
                        namespaceString = "protected$";
                        break;
                    case NamespaceInfo.PackageInternalNs:
                        namespaceString = "internal";
                        break;
                    case NamespaceInfo.PackageNamespace:
                        namespaceString = "public";
                        break;
                    default:
                        namespaceString = "*";
                        break;
                }

                namespaceString += "::" + ((StringInfo)abc.ConstantPool.StringTable[(int)ns.Name.Value]).ToString();

                if (argument.IndexOf(namespaceString) != -1)
                {
                    U30 nsIndex = new U30();
                    nsIndex.Value = (uint)i;

                    return nsIndex;
                }
            }

            NamespaceInfo newNs = new NamespaceInfo();

            string name = "";
            byte kind = 0;

            if(0 == argument.IndexOf("private::"))
            {
                kind = NamespaceInfo.PrivateNs;
                name = argument.Substring(8);
            }
            else if (0 == argument.IndexOf("public::"))
            {
                kind = NamespaceInfo.PackageNamespace;
                name = argument.Substring(7);
            }

            newNs.Kind = kind;

            if ("" == name)
                newNs.Name = (U30)0;
            else
                newNs.Name = (U30)abc.ConstantPool.ResolveString(name);

            U30 result = new U30();

            result.Value = (uint)abc.ConstantPool.NamespaceTable.Count;

            abc.ConstantPool.NamespaceTable.Add(newNs);

            return result;
        }
Example #2
0
        public void ReadExternal(BinaryReader input)
        {
            #region integer

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

            _intTable = new ArrayList(Capacity.Max(n));
            _intTable.Add(new S32());

            for (uint i = 1; i < n; ++i)
                _intTable.Add(Primitives.ReadS32(input));

            #endregion

            #region uinteger

            n = Primitives.ReadU30(input).Value;

            _uintTable = new ArrayList(Capacity.Max(n));
            _uintTable.Add(new U32());

            for (uint i = 1; i < n; ++i)
                _uintTable.Add(Primitives.ReadU32(input));

            #endregion

            #region double

            n = Primitives.ReadU30(input).Value;

            _doubleTable = new ArrayList(Capacity.Max(n));
            _doubleTable.Add(double.NaN);

            for (uint i = 1; i < n; ++i)
                _doubleTable.Add(input.ReadDouble());

            #endregion

            #region string_info

            n = Primitives.ReadU30(input).Value;

            _stringTable = new ArrayList(Capacity.Max(n));
            _stringTable.Add(new StringInfo());

            for (uint i = 1; i < n; ++i)
            {
                StringInfo stringInfo = new StringInfo();
                stringInfo.ReadExternal(input);

                _stringTable.Add(stringInfo);
            }

            #endregion

            #region namespace_info

            n = Primitives.ReadU30(input).Value;

            _namespaceTable = new ArrayList(Capacity.Max(n));
            _namespaceTable.Add(new NamespaceInfo());

            for (uint i = 1; i < n; ++i)
            {
                NamespaceInfo namespaceInfo = new NamespaceInfo();
                namespaceInfo.ReadExternal(input);

                _namespaceTable.Add(namespaceInfo);
            }

            #endregion

            #region ns_set_info

            n = Primitives.ReadU30(input).Value;

            _nsTable = new ArrayList(Capacity.Max(n));
            _nsTable.Add(new NamespaceSetInfo());

            for (uint i = 1; i < n; ++i)
            {
                NamespaceSetInfo nsInfo = new NamespaceSetInfo();
                nsInfo.ReadExternal(input);

                _nsTable.Add(nsInfo);
            }

            #endregion

            #region multiname_info

            n = Primitives.ReadU30(input).Value;

            _multinameTable = new ArrayList(Capacity.Max(n));
            _multinameTable.Add(new MultinameInfo());

            for (uint i = 1; i < n; ++i)
            {
                MultinameInfo multinameInfo = new MultinameInfo();
                multinameInfo.ReadExternal(input);

                _multinameTable.Add(multinameInfo);
            }

            #endregion
        }