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



2108
2109
2110
# File 'lib/syntax_tree/yarv/instructions.rb', line 2108

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

#call(vm) ⇒ Object



2120
2121
2122
# File 'lib/syntax_tree/yarv/instructions.rb', line 2120

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

#deconstruct_keys(_keys) ⇒ Object



2104
2105
2106
# File 'lib/syntax_tree/yarv/instructions.rb', line 2104

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



2096
2097
2098
# File 'lib/syntax_tree/yarv/instructions.rb', line 2096

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

#popsObject



2112
2113
2114
# File 'lib/syntax_tree/yarv/instructions.rb', line 2112

def pops
  1
end

#pushesObject



2116
2117
2118
# File 'lib/syntax_tree/yarv/instructions.rb', line 2116

def pushes
  1
end

#to_a(_iseq) ⇒ Object



2100
2101
2102
# File 'lib/syntax_tree/yarv/instructions.rb', line 2100

def to_a(_iseq)
  [:intern]
end