public bool Equals(NameAndTypeInfo x, NameAndTypeInfo y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null) || ReferenceEquals(y, null)) { return(false); } return(x.NameIndex == y.NameIndex && x.DescriptorIndex == y.DescriptorIndex); }
public int GetNameAndTypeIndex(string name, IMemberDescriptor descriptor) { var nameAndTypeInfo = new NameAndTypeInfo( (ushort)GetUtf8Index(name), (ushort)GetDescriptorIndex(descriptor)); if (!_nameAndTypeInfos.TryGetValue(nameAndTypeInfo, out int index)) { index = AddConstant(nameAndTypeInfo); _nameAndTypeInfos.Add(nameAndTypeInfo, index); } return(index); }
private ConstantPoolInfo[] ParseConstantPool(ref ReadOnlySpan <byte> fileData) { ushort poolCount = fileData.ReadTwoBytes(); var infos = new ConstantPoolInfo[poolCount]; for (int i = 1; i < poolCount; i++) { var tag = (ConstantPoolTag)fileData.ReadOneByte(); switch (tag) { case ConstantPoolTag.Class: infos[i] = new ClassInfo(ref fileData); break; case ConstantPoolTag.Fieldref: infos[i] = new FieldrefInfo(ref fileData); break; case ConstantPoolTag.Methodref: infos[i] = new MethodrefInfo(ref fileData); break; case ConstantPoolTag.InterfaceMethodref: infos[i] = new InterfaceMethodrefInfo(ref fileData); break; case ConstantPoolTag.String: infos[i] = new StringInfo(ref fileData); break; case ConstantPoolTag.Integer: infos[i] = new IntegerInfo(ref fileData); break; case ConstantPoolTag.Float: infos[i] = new FloatInfo(ref fileData); break; case ConstantPoolTag.Long: infos[i] = new LongInfo(ref fileData); i++; break; case ConstantPoolTag.Double: infos[i] = new DoubleInfo(ref fileData); i++; break; case ConstantPoolTag.NameAndType: infos[i] = new NameAndTypeInfo(ref fileData); break; case ConstantPoolTag.Utf8: infos[i] = new Utf8Info(ref fileData); break; case ConstantPoolTag.MethodHandle: fileData.ReadOneByte(); fileData.ReadTwoBytes(); break; case ConstantPoolTag.MethodType: fileData.ReadTwoBytes(); break; case ConstantPoolTag.InvokeDynamic: fileData.ReadFourBytes(); break; default: throw new InvalidDataException(); } } foreach (ConstantPoolInfo info in infos) { info?.Init(infos); } return(infos); }
public int GetHashCode(NameAndTypeInfo obj) { return((obj.NameIndex << 16) | obj.DescriptorIndex); }