Class: JavaClass::ClassFile::Methods

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

Overview

Container of the methods - skips the fields for now.

Author

Peter Kofler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, start, constant_pool) ⇒ Methods

Parse the method 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/methods.rb', line 14

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

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

    # access_flags = data.u2(start + @size) # later ... MethodAccessFlag.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 methods structure in bytes.



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

def size
  @size
end