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.



1991
1992
1993
# File 'lib/syntax_tree/yarv/instructions.rb', line 1991

def initialize(index)
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



1989
1990
1991
# File 'lib/syntax_tree/yarv/instructions.rb', line 1989

def index
  @index
end

Instance Method Details

#==(other) ⇒ Object



2007
2008
2009
# File 'lib/syntax_tree/yarv/instructions.rb', line 2007

def ==(other)
  other.is_a?(GetLocalWC0) && other.index == index
end

#call(vm) ⇒ Object



2027
2028
2029
# File 'lib/syntax_tree/yarv/instructions.rb', line 2027

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

#canonicalObject



2023
2024
2025
# File 'lib/syntax_tree/yarv/instructions.rb', line 2023

def canonical
  GetLocal.new(index, 0)
end

#deconstruct_keys(_keys) ⇒ Object



2003
2004
2005
# File 'lib/syntax_tree/yarv/instructions.rb', line 2003

def deconstruct_keys(_keys)
  { index: index }
end

#disasm(fmt) ⇒ Object



1995
1996
1997
# File 'lib/syntax_tree/yarv/instructions.rb', line 1995

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

#lengthObject



2011
2012
2013
# File 'lib/syntax_tree/yarv/instructions.rb', line 2011

def length
  2
end

#popsObject



2015
2016
2017
# File 'lib/syntax_tree/yarv/instructions.rb', line 2015

def pops
  0
end

#pushesObject



2019
2020
2021
# File 'lib/syntax_tree/yarv/instructions.rb', line 2019

def pushes
  1
end

#to_a(iseq) ⇒ Object



1999
2000
2001
# File 'lib/syntax_tree/yarv/instructions.rb', line 1999

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