Class: JavaClass::Code
Overview
コード
Instance Attribute Summary collapse
-
#index ⇒ Object
インデックス.
-
#java_class ⇒ Object
JavaClass.
-
#opcode ⇒ Object
opcode.
-
#operands ⇒ Object
operands.
-
#wide ⇒ Object
wideかどうか.
Instance Method Summary collapse
-
#initialize(java_class, index, opcode, operands = [], wide = false) ⇒ Code
constructor
A new instance of Code.
- #to_bytes ⇒ Object
- #to_s ⇒ Object
Methods included from Base
#==, #===, #dump, #eql?, #hash, #to_byte
Constructor Details
#initialize(java_class, index, opcode, operands = [], wide = false) ⇒ Code
Returns a new instance of Code.
8 9 10 11 12 13 14 |
# File 'lib/javaclass/code.rb', line 8 def initialize( java_class, index, opcode, operands=[], wide=false ) @java_class = java_class @index = index @opcode = opcode @operands = operands @wide = wide end |
Instance Attribute Details
#index ⇒ Object
インデックス
41 42 43 |
# File 'lib/javaclass/code.rb', line 41 def index @index end |
#java_class ⇒ Object
JavaClass
39 40 41 |
# File 'lib/javaclass/code.rb', line 39 def java_class @java_class end |
#opcode ⇒ Object
opcode
43 44 45 |
# File 'lib/javaclass/code.rb', line 43 def opcode @opcode end |
#operands ⇒ Object
operands
45 46 47 |
# File 'lib/javaclass/code.rb', line 45 def operands @operands end |
#wide ⇒ Object
wideかどうか
47 48 49 |
# File 'lib/javaclass/code.rb', line 47 def wide @wide end |
Instance Method Details
#to_bytes ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/javaclass/code.rb', line 29 def to_bytes bytes = [] bytes += to_byte( 0xC4, 1 ) if wide bytes += to_byte( opcode, 1 ) operands.each {|o| bytes += o.to_bytes } return bytes end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/javaclass/code.rb', line 15 def to_s # opts = values = operands.inject(""){|str,i| # if i.name == "index" # c = @java_class.get_constant(i.value) # str += c.kind_of?(MemberRefConstant) ? c.name_and_type.name : c.to_s # end # str # } values = operands.map{|i|i.to_s} values.unshift( Converters.convert_code(opcode) ) values.unshift( "#{@index} :" ) # values.push( "#" + opts ) if !opts.empty? return values.join(" ") end |