public ConstantPoolInfo ReadConstantPoolInfo() { ConstantPoolInfo result = new ConstantPoolInfo(); result.IntArrayCapacity = ReadU30(); for (uint i = 1; i < result.IntArrayCapacity; i++) { result.SetIntAt(ReadS32(), i); } result.UIntArrayCapacity = ReadU30(); for (uint i = 1; i < result.UIntArrayCapacity; i++) { result.SetUIntAt(ReadU30(), i); } result.DoubleArrayCapacity = ReadU30(); for (uint i = 1; i < result.DoubleArrayCapacity; i++) { result.SetDoubleAt(ReadDouble(), i); } result.StringArrayCapacity = ReadU30(); for (uint i = 1; i < result.StringArrayCapacity; i++) { result.SetStringAt(new StringInfo(i, ReadString()), i); } result.NamespaceArrayCapacity = ReadU30(); for (uint i = 1; i < result.NamespaceArrayCapacity; i++) { NamespaceInfo namespaceInfo = new NamespaceInfo(result, i); namespaceInfo.Kind = (NamespaceKind)ReadByte(); namespaceInfo.Name = result.GetStringAt(ReadU30()); result.SetNamespaceAt(namespaceInfo, i); } result.NamespaceSetArrayCapacity = ReadU30(); for (uint i = 1; i < result.NamespaceSetArrayCapacity; i++) { NamespaceSetInfo namespaceSetInfo = new NamespaceSetInfo(i); namespaceSetInfo.NamespaceArray = new NamespaceInfo[ReadU30()]; for (int j = 0; j < namespaceSetInfo.NamespaceArray.Length; j++) { namespaceSetInfo.NamespaceArray[j] = result.GetNamespaceAt(ReadU30()); } result.SetNamespaceSetAt(namespaceSetInfo, i); } result.MultinameArrayCapacity = ReadU30(); for (uint i = 1; i < result.MultinameArrayCapacity; i++) { result.SetMultinameAt(ReadMultinameInfo(result, i), i); } return(result); }
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); }
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)); } }