Class: JavaClass::LineNumberTableAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/javaclass/attribute.rb

Overview

行番号属性

Instance Attribute Summary collapse

Attributes inherited from Attribute

#java_class, #name_index

Instance Method Summary collapse

Methods inherited from Attribute

#name

Methods included from Base

#==, #===, #dump, #eql?, #hash, #to_byte

Constructor Details

#initialize(java_class, name_index, line_numbers = []) ⇒ LineNumberTableAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス *name_index::名前を示すconstant_poolのインデックス



871
872
873
874
# File 'lib/javaclass/attribute.rb', line 871

def initialize( java_class, name_index, line_numbers=[] )
  super( java_class, name_index)
  @line_numbers = line_numbers
end

Instance Attribute Details

#line_numbersObject

Returns the value of attribute line_numbers.



894
895
896
# File 'lib/javaclass/attribute.rb', line 894

def line_numbers
  @line_numbers
end

Instance Method Details

#line_number(start_pc) ⇒ Object

start_pcに対応する位置の行番号オブジェクトがあればそれを返す。

*start_pc::コードの番号 戻り値::start_pcに対応する位置のソースの行番号オブジェクト。見つからなければnil



880
881
882
883
884
# File 'lib/javaclass/attribute.rb', line 880

def line_number( start_pc )
  return @line_numbers.find {|l|
    l.start_pc == start_pc
  }
end

#to_bytesObject



885
886
887
888
889
890
891
892
893
# File 'lib/javaclass/attribute.rb', line 885

def to_bytes
  bytes = super
  body = to_byte( @line_numbers.length, 2 )
  @line_numbers.each {|l|
    body += l.to_bytes()
  }
  bytes += to_byte( body.length, 4 )
  bytes += body
end