Class: JvmBytecode::Constants::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/jvm_bytecode/constants/constant.rb

Direct Known Subclasses

Class, NameAndType, Ref, Utf8

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.tagObject (readonly)

Returns the value of attribute tag.



5
6
7
# File 'lib/jvm_bytecode/constants/constant.rb', line 5

def tag
  @tag
end

Class Method Details

.define(t) ⇒ Object



7
8
9
10
11
12
# File 'lib/jvm_bytecode/constants/constant.rb', line 7

def define(t)
  @@constants ||= {}
  @@constants[t] = self

  @tag = t
end

.fetch(t) ⇒ Object



14
15
16
# File 'lib/jvm_bytecode/constants/constant.rb', line 14

def fetch(t)
  @@constants[t] || raise(Errors::ConstantError, "Constant:#{t} is not implemented")
end

Instance Method Details

#additional_bytecodeObject



23
24
25
# File 'lib/jvm_bytecode/constants/constant.rb', line 23

def additional_bytecode
  ''
end

#bytecodeObject



19
20
21
# File 'lib/jvm_bytecode/constants/constant.rb', line 19

def bytecode
  [self.class.tag].pack('C') + additional_bytecode
end