Class: JavaClass::LocalVariableTypeTableAttribute

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_type_table = []) ⇒ LocalVariableTypeTableAttribute

コンストラクタ

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



1003
1004
1005
1006
# File 'lib/javaclass/attribute.rb', line 1003

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

Instance Attribute Details

#local_variable_type_tableObject

Returns the value of attribute local_variable_type_table.



1026
1027
1028
# File 'lib/javaclass/attribute.rb', line 1026

def local_variable_type_table
  @local_variable_type_table
end

Instance Method Details

#find_by_index(index) ⇒ Object

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

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



1012
1013
1014
1015
1016
# File 'lib/javaclass/attribute.rb', line 1012

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

#to_bytesObject



1017
1018
1019
1020
1021
1022
1023
1024
1025
# File 'lib/javaclass/attribute.rb', line 1017

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