Class: JavaClass::ClassFile::Constants::DoubleReference

Inherits:
SingleReference show all
Defined in:
lib/javaclass/classfile/constants/double_reference.rb

Overview

Superclass of double reference constants like ConstantField (FieldRef) in the constant pool.

Author

Peter Kofler

Instance Attribute Summary collapse

Attributes inherited from SingleReference

#first_index

Attributes inherited from Base

#name, #size, #slots, #tag

Instance Method Summary collapse

Methods inherited from SingleReference

#first_value

Constructor Details

#initialize(pool, data, start, name = nil) ⇒ DoubleReference

Define a double reference into pool from data beginning at start



15
16
17
18
19
20
# File 'lib/javaclass/classfile/constants/double_reference.rb', line 15

def initialize(pool, data, start, name=nil)
  super(pool, data, start, name)
  @size = 5
  
  @second_index = data.u2(start+3)
end

Instance Attribute Details

#second_indexObject (readonly)

Returns the value of attribute second_index.



12
13
14
# File 'lib/javaclass/classfile/constants/double_reference.rb', line 12

def second_index
  @second_index
end

Instance Method Details

#dumpObject

Return part of debug output.



33
34
35
# File 'lib/javaclass/classfile/constants/double_reference.rb', line 33

def dump
  "#{@name}\t##{@first_index}.##{@second_index};\t//  #{to_s}"
end

#second_valueObject

Return the second value, which is the referenced value from the pool.



23
24
25
# File 'lib/javaclass/classfile/constants/double_reference.rb', line 23

def second_value
  get(@second_index)
end

#to_sObject

Return the value, which are both referenced values from the pool.



28
29
30
# File 'lib/javaclass/classfile/constants/double_reference.rb', line 28

def to_s
  "#{super}.#{second_value}"
end