Class: JavaClass::LocalVariableTableAttribute

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, local_variable_table = []) ⇒ LocalVariableTableAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス*name_index::名前を示すconstant_poolのインデックス*local_variable_table::ローカル変数テーブル



925
926
927
928
# File 'lib/javaclass/attribute.rb', line 925

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

Instance Attribute Details

#local_variable_tableObject

Returns the value of attribute local_variable_table.



948
949
950
# File 'lib/javaclass/attribute.rb', line 948

def local_variable_table
  @local_variable_table
end

Instance Method Details

#find_by_index(index) ⇒ Object

indexに対応するローカル変数情報を取得します。

*index::ローカル変数名戻り値::名前に対応するローカル変数情報。見つからなければnil



934
935
936
937
938
# File 'lib/javaclass/attribute.rb', line 934

def find_by_index( index )
  return @local_variable_table.find {|l|
    l.index == index
  }
end

#to_bytesObject



939
940
941
942
943
944
945
946
947
# File 'lib/javaclass/attribute.rb', line 939

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