Class: JavaClass::ClassFile::Constants::Base

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

Overview

Superclass of all constant values in the constant pool. Every constant has a name, a tag and a size in bytes.

Author

Peter Kofler

Direct Known Subclasses

SingleReference, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Base

Set default constants.



17
18
19
20
21
22
# File 'lib/javaclass/classfile/constants/base.rb', line 17

def initialize(name=nil)
  @name = self.class.to_s[/::[^:]+$/][10..-1] # skip modules (::) and "Constant"
  @name = name if name
  @size = 3
  @slots = 1
end

Instance Attribute Details

#nameObject (readonly)

ZenTest FULL to find method name



11
12
13
# File 'lib/javaclass/classfile/constants/base.rb', line 11

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



13
14
15
# File 'lib/javaclass/classfile/constants/base.rb', line 13

def size
  @size
end

#slotsObject (readonly)

Returns the value of attribute slots.



14
15
16
# File 'lib/javaclass/classfile/constants/base.rb', line 14

def slots
  @slots
end

#tagObject (readonly)

Returns the value of attribute tag.



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

def tag
  @tag
end

Instance Method Details

#dumpObject

Return part of debug output.



25
26
27
# File 'lib/javaclass/classfile/constants/base.rb', line 25

def dump
  "#{@name}\t" # #{@tag} 
end