Class: JavaClass::ClassFile::Constants::SingleReference

Inherits:
Base
  • Object
show all
Defined in:
lib/javaclass/classfile/constants/single_reference.rb

Overview

Superclass of single reference constants like ConstantClass (Class) in the constant pool.

Author

Peter Kofler

Direct Known Subclasses

ConstantClass, ConstantString, DoubleReference

Instance Attribute Summary collapse

Attributes inherited from Base

#name, #size, #slots, #tag

Instance Method Summary collapse

Constructor Details

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

Define a single reference into pool from data beginning at start



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

def initialize(pool, data, start, name=nil)
  super(name)
  @tag = data.u1(start)
  
  @enclosing_pool = pool
  @first_index = data.u2(start+1)
end

Instance Attribute Details

#first_indexObject (readonly)

Returns the value of attribute first_index.



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

def first_index
  @first_index
end

Instance Method Details

#dumpObject

Return part of debug output.



30
31
32
# File 'lib/javaclass/classfile/constants/single_reference.rb', line 30

def dump
  super + "##{@first_index};\t//  #{to_s}"
end

#first_valueObject Also known as: to_s

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



24
25
26
# File 'lib/javaclass/classfile/constants/single_reference.rb', line 24

def first_value
  get(@first_index)
end