Exemplo n.º 1
0
        private AsMultinameInfo ReadMultiname()
        {
            var r = new AsMultinameInfo {
                Kind = (AsMultinameKind)ReadU8()
            };

            switch (r.Kind)
            {
            case AsMultinameKind.QName:
            case AsMultinameKind.QNameA:
                r.QName = new AsMultinameQName {
                    Namespace = ReadU30(),
                    Name      = ReadU30()
                };
                break;

            case AsMultinameKind.RTQName:
            case AsMultinameKind.RTQNameA:
                r.RtqName = new AsMultinameRTQName {
                    Name = ReadU30()
                };
                break;

            case AsMultinameKind.RTQNameL:
            case AsMultinameKind.RTQNameLA:
                break;

            case AsMultinameKind.Multiname:
            case AsMultinameKind.MultinameA:
                r.Multiname = new AsMultinameMultiname {
                    Name         = ReadU30(),
                    NamespaceSet = ReadU30()
                };
                break;

            case AsMultinameKind.MultinameL:
            case AsMultinameKind.MultinameLA:
                r.MultinameL = new AsMultinameMultinameL {
                    NamespaceSet = ReadU30()
                };
                break;

            case AsMultinameKind.Generic:
                r.TypeName = new AsMultinameTypeName {
                    Name   = ReadU30(),
                    Params = ReadMultipleU30()
                };
                break;

            default:
                throw new Exception("Unknown Multiname kind " + r.Kind);
            }
            return(r);
        }
Exemplo n.º 2
0
        private void WriteMultiname(ref AsMultinameInfo multiname)
        {
            WriteU8((byte)multiname.Kind);
            switch (multiname.Kind)
            {
            case AsMultinameKind.QName:
            case AsMultinameKind.QNameA:
                WriteU30(multiname.QName.Namespace);
                WriteU30(multiname.QName.Name);
                break;

            case AsMultinameKind.RTQName:
            case AsMultinameKind.RTQNameA:
                WriteU30(multiname.RtqName.Name);
                break;

            case AsMultinameKind.RTQNameL:
            case AsMultinameKind.RTQNameLA:
                break;

            case AsMultinameKind.Multiname:
            case AsMultinameKind.MultinameA:
                WriteU30(multiname.Multiname.Name);
                WriteU30(multiname.Multiname.NamespaceSet);
                break;

            case AsMultinameKind.MultinameL:
            case AsMultinameKind.MultinameLA:
                WriteU30(multiname.MultinameL.NamespaceSet);
                break;

            case AsMultinameKind.Generic:
                WriteU30(multiname.TypeName.Name);
                WriteU30((uint)multiname.TypeName.Params.Length);
                foreach (var value in multiname.TypeName.Params)
                {
                    WriteU30(value);
                }
                break;

            default:
                throw new Exception("Unknown Multiname kind");
            }
        }
Exemplo n.º 3
0
 private AsMultinameInfo ReadMultiname()
 {
     var r = new AsMultinameInfo { Kind = (AsMultinameKind)ReadU8() };
     switch (r.Kind) {
         case AsMultinameKind.QName:
         case AsMultinameKind.QNameA:
             r.QName = new AsMultinameQName {
                 Namespace = ReadU30(),
                 Name = ReadU30()
             };
             break;
         case AsMultinameKind.RTQName:
         case AsMultinameKind.RTQNameA:
             r.RtqName = new AsMultinameRTQName {
                 Name = ReadU30()
             };
             break;
         case AsMultinameKind.RTQNameL:
         case AsMultinameKind.RTQNameLA:
             break;
         case AsMultinameKind.Multiname:
         case AsMultinameKind.MultinameA:
             r.Multiname = new AsMultinameMultiname {
                 Name = ReadU30(),
                 NamespaceSet = ReadU30()
             };
             break;
         case AsMultinameKind.MultinameL:
         case AsMultinameKind.MultinameLA:
             r.MultinameL = new AsMultinameMultinameL {
                 NamespaceSet = ReadU30()
             };
             break;
         case AsMultinameKind.Generic:
             r.TypeName = new AsMultinameTypeName {
                 Name = ReadU30(),
                 Params = ReadMultipleU30()
             };
             break;
         default:
             throw new Exception("Unknown Multiname kind " + r.Kind);
     }
     return r;
 }
Exemplo n.º 4
0
 private void WriteMultiname(ref AsMultinameInfo multiname)
 {
     WriteU8((byte)multiname.Kind);
     switch (multiname.Kind) {
         case AsMultinameKind.QName:
         case AsMultinameKind.QNameA:
             WriteU30(multiname.QName.Namespace);
             WriteU30(multiname.QName.Name);
             break;
         case AsMultinameKind.RTQName:
         case AsMultinameKind.RTQNameA:
             WriteU30(multiname.RtqName.Name);
             break;
         case AsMultinameKind.RTQNameL:
         case AsMultinameKind.RTQNameLA:
             break;
         case AsMultinameKind.Multiname:
         case AsMultinameKind.MultinameA:
             WriteU30(multiname.Multiname.Name);
             WriteU30(multiname.Multiname.NamespaceSet);
             break;
         case AsMultinameKind.MultinameL:
         case AsMultinameKind.MultinameLA:
             WriteU30(multiname.MultinameL.NamespaceSet);
             break;
         case AsMultinameKind.Generic:
             WriteU30(multiname.TypeName.Name);
             WriteU30((uint)multiname.TypeName.Params.Length);
             foreach (var value in multiname.TypeName.Params)
                 WriteU30(value);
             break;
         default:
             throw new Exception("Unknown Multiname kind");
     }
 }
Exemplo n.º 5
0
        public AsConstantPoolInfo ReadConstantPool()
        {
            var res = new AsConstantPoolInfo();

            var resIntegers = new int[Math.Max(ReadU30(), 1)];

            for (var i = 1; i < resIntegers.Length; i++)
            {
                resIntegers[i] = ReadS32();
            }

            var resUnsignedIntegers = new uint[Math.Max(ReadU30(), 1)];

            for (var i = 1; i < resUnsignedIntegers.Length; i++)
            {
                resUnsignedIntegers[i] = ReadU32();
            }

            var resDoubles = new double[Math.Max(ReadU30(), 1)];

            resDoubles[0] = double.NaN;
            for (var i = 1; i < resDoubles.Length; i++)
            {
                resDoubles[i] = ReadD64();
            }

            var resStrings = new string[Math.Max(ReadU30(), 1)];

            resStrings[0] = string.Empty;
            for (var i = 1; i < resStrings.Length; i++)
            {
                resStrings[i] = ReadString();
            }

            var resNamespaces = new AsNamespaceInfo[Math.Max(ReadU30(), 1)];

            for (var i = 1; i < resNamespaces.Length; i++)
            {
                resNamespaces[i] = ReadNamespace();
            }

            var resNamespaceSets = new AsNamespaceSetInfo[Math.Max(ReadU30(), 1)];

            for (var i = 1; i < resNamespaceSets.Length; i++)
            {
                resNamespaceSets[i] = ReadNamespaceSet();
            }

            var resMultinames = new AsMultinameInfo[Math.Max(ReadU30(), 1)];

            for (var i = 1; i < resMultinames.Length; i++)
            {
                resMultinames[i] = ReadMultiname();
            }

            res.Integers         = resIntegers.ToList();
            res.UnsignedIntegers = resUnsignedIntegers.ToList();
            res.Doubles          = resDoubles.ToList();
            res.Strings          = resStrings.ToList();
            res.Namespaces       = resNamespaces.ToList();
            res.NamespaceSets    = resNamespaceSets.ToList();
            res.Multinames       = resMultinames.ToList();

            return(res);
        }