Class: JavaClass::LocalVariable

Inherits:
Object
  • Object
show all
Includes:
Base, Converters
Defined in:
lib/javaclass/attribute.rb

Overview

ローカル変数

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Converters

convert_code, convert_field_descriptor, convert_method_descriptor

Methods included from Base

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

Constructor Details

#initialize(java_class, start_pc = nil, length = nil, name_index = nil, descriptor_index = nil, index = nil) ⇒ LocalVariable

Returns a new instance of LocalVariable.



961
962
963
964
965
966
967
968
969
# File 'lib/javaclass/attribute.rb', line 961

def initialize( java_class, start_pc=nil, \
  length=nil, name_index=nil, descriptor_index=nil, index=nil )
  @java_class=java_class
  @start_pc = start_pc
  @length = length
  @name_index = name_index
  @descriptor_index = descriptor_index
  @index = index
end

Instance Attribute Details

#descriptor_indexObject

Returns the value of attribute descriptor_index.



989
990
991
# File 'lib/javaclass/attribute.rb', line 989

def descriptor_index
  @descriptor_index
end

#indexObject

Returns the value of attribute index.



990
991
992
# File 'lib/javaclass/attribute.rb', line 990

def index
  @index
end

#lengthObject

Returns the value of attribute length.



987
988
989
# File 'lib/javaclass/attribute.rb', line 987

def length
  @length
end

#name_indexObject

Returns the value of attribute name_index.



988
989
990
# File 'lib/javaclass/attribute.rb', line 988

def name_index
  @name_index
end

#start_pcObject

Returns the value of attribute start_pc.



986
987
988
# File 'lib/javaclass/attribute.rb', line 986

def start_pc
  @start_pc
end

Instance Method Details

#descriptorObject



976
977
978
# File 'lib/javaclass/attribute.rb', line 976

def descriptor
  @java_class.get_constant_value( @descriptor_index )
end

#nameObject



973
974
975
# File 'lib/javaclass/attribute.rb', line 973

def name
  @java_class.get_constant_value( @name_index )
end

#to_bytesObject



979
980
981
982
983
984
985
# File 'lib/javaclass/attribute.rb', line 979

def to_bytes
  bytes =  to_byte( @start_pc, 2 )
  bytes += to_byte( @length, 2 )
  bytes += to_byte( @name_index, 2 )
  bytes += to_byte( @descriptor_index, 2 )
  bytes += to_byte( @index, 2 )
end

#to_sObject



970
971
972
# File 'lib/javaclass/attribute.rb', line 970

def to_s
  "#{convert_field_descriptor(descriptor)} #{name}"
end