Exemplo n.º 1
0
 /// <summary>
 /// Writes the inner class info to an output stream.
 /// </summary>
 /// <param name="writer">The writer representing the output stream.</param>
 public void Write(IBigEndianWriter writer)
 {
     writer.Write(InnerClassInfoIndex);
     writer.Write(OuterClassInfoIndex);
     writer.Write(NameIndex);
     writer.Write((ushort)InnerClassAccessFlags);
 }
Exemplo n.º 2
0
 public void Write(IBigEndianWriter writer)
 {
     writer.Write(StartOffset);
     writer.Write(EndOffset);
     writer.Write(HandlerOffset);
     writer.Write(CatchType);
 }
 public void Write(IBigEndianWriter writer)
 {
     writer.Write(StartOffset);
     writer.Write(Length);
     writer.Write(NameIndex);
     writer.Write(DescriptorIndex);
     writer.Write(LocalIndex);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Writes the entry to an output stream.
 /// </summary>
 /// <param name="writer">The writer to use.</param>
 public void Write(IBigEndianWriter writer)
 {
     writer.Write(MethodRefIndex);
     writer.Write((ushort)Arguments.Count);
     foreach (ushort argument in Arguments)
     {
         writer.Write(argument);
     }
 }
Exemplo n.º 5
0
 public void Write(IBigEndianWriter writer, int baseOffset)
 {
     writer.Write(DefaultOffset - baseOffset);
     writer.Write(Low);
     writer.Write(High);
     foreach (var offset in Offsets)
     {
         writer.Write(offset - baseOffset);
     }
 }
Exemplo n.º 6
0
 public void Write(IBigEndianWriter writer, int baseOffset)
 {
     writer.Write(DefaultOffset - baseOffset);
     writer.Write(Table.Count);
     foreach (var entry in Table)
     {
         writer.Write(entry.Key);
         writer.Write(entry.Value - baseOffset);
     }
 }
Exemplo n.º 7
0
        /// <inheritdoc />
        public void WriteBody(JvmAttribute attribute, IBigEndianWriter writer)
        {
            if (attribute.Data is null)
            {
                throw new ArgumentException(nameof(attribute));
            }

            writer.Write(attribute.Data);
        }
Exemplo n.º 8
0
        private static void WriteUtf8Constant(Utf8Constant constant, IBigEndianWriter writer)
        {
            var    encoder = JavaUtf8.Instance;
            string value   = constant.Value;

            byte[] array = Pool.Rent(encoder.GetMaxByteCount(value.Length));
            int    chars = encoder.GetBytes(value, 0, value.Length, array, 0);

            writer.WriteU2((ushort)chars);
            writer.Write(array.AsSpan().Slice(0, chars));
            Pool.Return(array, true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Writes a single instruction to the output stream.
        /// </summary>
        /// <param name="instruction">The instruction to write.</param>
        /// <remarks>
        /// Some instructions have different byte layouts depending on the offsets they are located at.
        /// Make sure the offsets have been calculated before passing on the instructions to the assembler.
        /// </remarks>
        public void Write(ByteCodeInstruction instruction)
        {
            _writer.Write((byte)instruction.OpCode.Code);

            WriteOperand(instruction);
        }