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::ローカル変数テーブル



929
930
931
932
# File 'lib/javaclass/attribute.rb', line 929

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.



952
953
954
# File 'lib/javaclass/attribute.rb', line 952

def local_variable_table
  @local_variable_table
end

Instance Method Details

#find_by_index(index) ⇒ Object

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

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



938
939
940
941
942
# File 'lib/javaclass/attribute.rb', line 938

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

#to_bytesObject



943
944
945
946
947
948
949
950
951
# File 'lib/javaclass/attribute.rb', line 943

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