Class: JavaClass::ClassFile::Fields

Inherits:
Object
  • Object
show all
Defined in:
lib/javaclass/classfile/fields.rb

Overview

Container of the fields - skips the fields for now.

Author

Peter Kofler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, start, constant_pool) ⇒ Fields

Parse the field structure from the bytes data beginning at position start.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/javaclass/classfile/fields.rb', line 14

def initialize(data, start, constant_pool)
  count = data.u2(start)
  @size = 2

  (1..count).each do |i|
    # TODO Implement parsing of fields into Field class

    # access_flags = data.u2(start + @size) # later ... FieldAccessFlag.new(data, start + @size)
    # @size += 2
    # name_index = data.u2(start + @size) # later ... get from ConstantPool
    # @size += 2
    # descriptor_index = data.u2(start + @size) # later ... get from ConstantPool
    # @size += 2
    @size += 6

    attributes = Attributes::Attributes.new(data, start + @size, constant_pool)
    @size += attributes.size
  end
end

Instance Attribute Details

#sizeObject (readonly)

Size of the whole fields structure in bytes.



11
12
13
# File 'lib/javaclass/classfile/fields.rb', line 11

def size
  @size
end