Example #1
0
        public MultinameInfo ReadMultinameInfo(ConstantPoolInfo constantPool, uint index)
        {
            MultinameInfo result = new MultinameInfo(index);

            result.Kind = (MultinameKind)ReadByte();
            switch (result.Kind)
            {
            case MultinameKind.QName:
            case MultinameKind.QNameA:
                var mkQName = new MKQName();
                mkQName.Namespace = constantPool.GetNamespaceAt(ReadU30());
                mkQName.Name      = constantPool.GetStringAt(ReadU30());
                result.Data       = mkQName;
                break;

            case MultinameKind.RTQName:
            case MultinameKind.RTQNameA:
                var mkRtkName = new MKRTQName();
                mkRtkName.Name = constantPool.GetStringAt(ReadU30());
                result.Data    = mkRtkName;
                break;

            case MultinameKind.RTQNameL:
            case MultinameKind.RTQNameLA:
                var mkRtqNameL = new MKRTQNameL();
                result.Data = mkRtqNameL;
                break;

            case MultinameKind.Multiname:
            case MultinameKind.MultinameA:
                var mkMultiname = new MKMultiname();

                mkMultiname.Name         = constantPool.GetStringAt(ReadU30());
                mkMultiname.NamespaceSet = constantPool.GetNamespaceSetAt(ReadU30());
                result.Data = mkMultiname;
                break;

            case MultinameKind.MultinameL:
            case MultinameKind.MultinameLA:
                var mkMultinameL = new MKMultinameL();
                mkMultinameL.NamespaceSet = constantPool.GetNamespaceSetAt(ReadU30());
                result.Data = mkMultinameL;
                break;

            case MultinameKind.GenericName:
                var mkGenericName = new MKGenericName(constantPool);
                mkGenericName.TypeDefinitionIndex = ReadU30();
                mkGenericName.ParamArrayIndexes   = ReadU30Array(ReadU30());
                result.Data = mkGenericName;
                break;

            default:
                throw new Exception();
            }
            return(result);
        }
Example #2
0
        public void WriteConstantPool(ConstantPoolInfo value)
        {
            WriteU30(value.IntArrayLength);
            for (uint i = 1; i < value.IntArrayLength; i++)
            {
                WriteS32(value.GetIntAt(i));
            }

            WriteU30(value.UIntArrayLength);
            for (uint i = 1; i < value.UIntArrayLength; i++)
            {
                WriteU30(value.GetUIntAt(i));
            }

            WriteU30(value.DoubleArrayLength);
            for (uint i = 1; i < value.DoubleArrayLength; i++)
            {
                WriteDouble(value.GetDoubleAt(i));
            }

            WriteU30(value.StringArrayLength);
            for (uint i = 1; i < value.StringArrayLength; i++)
            {
                StringInfo stringInfo = value.GetStringAt(i);

                WriteString(stringInfo);
            }


            WriteU30(value.NamespaceArrayLength);
            for (uint i = 1; i < value.NamespaceArrayLength; i++)
            {
                var namespaceInfo = value.GetNamespaceAt(i);
                WriteByte((Byte)namespaceInfo.Kind);
                WriteU30(namespaceInfo.Name?.Index ?? 0);
            }

            WriteU30(value.NamespaceSetArrayLength);
            for (uint i = 1; i < value.NamespaceSetArrayLength; i++)
            {
                WriteU30Array((from n in value.GetNamespaceSetAt(i).NamespaceArray select n.Index).ToArray(), true);
            }

            WriteU30(value.MultinameArrayLength);
            for (uint i = 1; i < value.MultinameArrayLength; i++)
            {
                WriteMultinameInfo(value.GetMultinameAt(i));
            }
        }
Example #3
0
 public MKMultiname(ConstantPoolInfo cPool)
     : base(cPool)
 {
     Name         = cPool.GetStringAt(1);
     NamespaceSet = cPool.GetNamespaceSetAt(1);
 }