Class: SyntaxTree::YARV::GetLocalWC0

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

getlocal_WC_0 is a specialized version of the getlocal instruction. It fetches the value of a local variable from the current frame determined by the index given as its only argument.

### Usage

~~~ruby value = 5 value ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ GetLocalWC0

Returns a new instance of GetLocalWC0.



1772
1773
1774
# File 'lib/syntax_tree/yarv/instructions.rb', line 1772

def initialize(index)
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



1770
1771
1772
# File 'lib/syntax_tree/yarv/instructions.rb', line 1770

def index
  @index
end

Instance Method Details

#call(vm) ⇒ Object



1800
1801
1802
# File 'lib/syntax_tree/yarv/instructions.rb', line 1800

def call(vm)
  canonical.call(vm)
end

#canonicalObject



1796
1797
1798
# File 'lib/syntax_tree/yarv/instructions.rb', line 1796

def canonical
  GetLocal.new(index, 0)
end

#disasm(fmt) ⇒ Object



1776
1777
1778
# File 'lib/syntax_tree/yarv/instructions.rb', line 1776

def disasm(fmt)
  fmt.instruction("getlocal_WC_0", [fmt.local(index, implicit: 0)])
end

#lengthObject



1784
1785
1786
# File 'lib/syntax_tree/yarv/instructions.rb', line 1784

def length
  2
end

#popsObject



1788
1789
1790
# File 'lib/syntax_tree/yarv/instructions.rb', line 1788

def pops
  0
end

#pushesObject



1792
1793
1794
# File 'lib/syntax_tree/yarv/instructions.rb', line 1792

def pushes
  1
end

#to_a(iseq) ⇒ Object



1780
1781
1782
# File 'lib/syntax_tree/yarv/instructions.rb', line 1780

def to_a(iseq)
  [:getlocal_WC_0, iseq.local_table.offset(index)]
end