Class: SyntaxTree::YARV::Intern

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

Overview

### Summary

‘intern` converts the top element of the stack to a symbol and pushes the symbol onto the stack.

### Usage

~~~ruby :“#”foo“” ~~~

Instance Method Summary collapse

Methods inherited from Instruction

#branch_targets, #canonical, #falls_through?, #leaves?, #length, #side_effects?

Instance Method Details

#==(other) ⇒ Object



2055
2056
2057
# File 'lib/syntax_tree/yarv/instructions.rb', line 2055

def ==(other)
  other.is_a?(Intern)
end

#call(vm) ⇒ Object



2067
2068
2069
# File 'lib/syntax_tree/yarv/instructions.rb', line 2067

def call(vm)
  vm.push(vm.pop.to_sym)
end

#deconstruct_keys(_keys) ⇒ Object



2051
2052
2053
# File 'lib/syntax_tree/yarv/instructions.rb', line 2051

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



2043
2044
2045
# File 'lib/syntax_tree/yarv/instructions.rb', line 2043

def disasm(fmt)
  fmt.instruction("intern")
end

#popsObject



2059
2060
2061
# File 'lib/syntax_tree/yarv/instructions.rb', line 2059

def pops
  1
end

#pushesObject



2063
2064
2065
# File 'lib/syntax_tree/yarv/instructions.rb', line 2063

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2047
2048
2049
# File 'lib/syntax_tree/yarv/instructions.rb', line 2047

def to_a(_iseq)
  [:intern]
end