Class: SyntaxTree::YARV::GetSpecial

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

Overview

### Summary

getspecial pushes the value of a special local variable onto the stack.

### Usage

~~~ruby 1 if (a == 1) .. (b == 2) ~~~

Constant Summary collapse

SVAR_LASTLINE =

$_

0
SVAR_BACKREF =

$~

1
SVAR_FLIPFLOP_START =

flipflop

2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, type) ⇒ GetSpecial

Returns a new instance of GetSpecial.



1871
1872
1873
1874
# File 'lib/syntax_tree/yarv/instructions.rb', line 1871

def initialize(key, type)
  @key = key
  @type = type
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



1869
1870
1871
# File 'lib/syntax_tree/yarv/instructions.rb', line 1869

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



1869
1870
1871
# File 'lib/syntax_tree/yarv/instructions.rb', line 1869

def type
  @type
end

Instance Method Details

#call(vm) ⇒ Object



1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
# File 'lib/syntax_tree/yarv/instructions.rb', line 1900

def call(vm)
  case key
  when SVAR_LASTLINE
    raise NotImplementedError, "getspecial SVAR_LASTLINE"
  when SVAR_BACKREF
    raise NotImplementedError, "getspecial SVAR_BACKREF"
  when SVAR_FLIPFLOP_START
    vm.frame_svar.svars[SVAR_FLIPFLOP_START]
  end
end

#canonicalObject



1896
1897
1898
# File 'lib/syntax_tree/yarv/instructions.rb', line 1896

def canonical
  self
end

#disasm(fmt) ⇒ Object



1876
1877
1878
# File 'lib/syntax_tree/yarv/instructions.rb', line 1876

def disasm(fmt)
  fmt.instruction("getspecial", [fmt.object(key), fmt.object(type)])
end

#lengthObject



1884
1885
1886
# File 'lib/syntax_tree/yarv/instructions.rb', line 1884

def length
  3
end

#popsObject



1888
1889
1890
# File 'lib/syntax_tree/yarv/instructions.rb', line 1888

def pops
  0
end

#pushesObject



1892
1893
1894
# File 'lib/syntax_tree/yarv/instructions.rb', line 1892

def pushes
  1
end

#to_a(_iseq) ⇒ Object



1880
1881
1882
# File 'lib/syntax_tree/yarv/instructions.rb', line 1880

def to_a(_iseq)
  [:getspecial, key, type]
end