class JvmBytecode::Method
Constants
- ACCESS_FLAGS
Public Class Methods
decode_serial(cp, io)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 21 def self.decode_serial(cp, io) Array.new(io.read(2).unpack('S>').first) do new(cp).tap { |m| m.decode(io) } end end
new(cp)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 27 def initialize(cp) @cp = cp @name = 0 @descriptor = 0 @attributes = [] end
Public Instance Methods
bytecode()
click to toggle source
# File lib/jvm_bytecode/method.rb, line 49 def bytecode [access_flag, @name, @descriptor].pack('S>*') + @attributes.join_bytecodes end
code(&block)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 42 def code(&block) @attributes .push(Attributes::Code.new(@cp)) .last .instance_eval(&block) end
decode(io)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 53 def decode(io) acc_flag, @name, @descriptor = io.read(6).unpack('S>3') set_access_flag(acc_flag) @attributes = Attributes::Attribute.decode_serial(@cp, io) end
descriptor(d)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 38 def descriptor(d) @descriptor = @cp.index_or_utf8(d) end
name(n)
click to toggle source
# File lib/jvm_bytecode/method.rb, line 34 def name(n) @name = @cp.index_or_utf8(n) end
to_hash()
click to toggle source
# File lib/jvm_bytecode/method.rb, line 60 def to_hash { name_index: @name, descriptor_index: @descriptor, access_flag: access_flag, attributes: @attributes.map(&:to_hash) } end