/// <summary> /// Adds a constant to the pool. /// </summary> /// <param name="constant">The constant to add.</param> /// <returns>The index assigned to the constant.</returns> public int AddConstant(ConstantInfo constant) { var index = GetIndexCount(); _constants.Add(index, constant); return(index); }
/// <summary> /// Reads an entire constant pool at the current position of the provided reader. /// </summary> /// <param name="reader">The reader to use.</param> /// <returns>The constant pool that was read.</returns> public static ConstantPool FromReader(IBigEndianReader reader) { var pool = new ConstantPool { StartOffset = reader.StartPosition }; ushort count = reader.ReadUInt16(); for (int i = 0; i < count - 1; i++) { pool.Constants.Add(ConstantInfo.FromReader(reader)); } return(pool); }
/// <summary> /// Reads an entire constant pool at the current position of the provided reader. /// </summary> /// <param name="reader">The reader to use.</param> /// <returns>The constant pool that was read.</returns> public static ConstantPool FromReader(IBigEndianReader reader) { var pool = new ConstantPool { StartOffset = reader.StartPosition }; ushort count = reader.ReadUInt16(); for (var index = 1; index < count;) { var constant = ConstantInfo.FromReader(reader); pool._constants.Add(index, constant); index += constant.Size; } return(pool); }