Class: SyntaxTree::YARV::PutSelf

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

Overview

### Summary

‘putself` pushes the current value of self onto the stack.

### Usage

~~~ruby puts “Hello, world!” ~~~

Instance Method Summary collapse

Methods inherited from Instruction

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

Instance Method Details

#==(other) ⇒ Object



4783
4784
4785
# File 'lib/syntax_tree/yarv/instructions.rb', line 4783

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

#call(vm) ⇒ Object



4791
4792
4793
# File 'lib/syntax_tree/yarv/instructions.rb', line 4791

def call(vm)
  vm.push(vm.frame._self)
end

#deconstruct_keys(_keys) ⇒ Object



4779
4780
4781
# File 'lib/syntax_tree/yarv/instructions.rb', line 4779

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



4771
4772
4773
# File 'lib/syntax_tree/yarv/instructions.rb', line 4771

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

#pushesObject



4787
4788
4789
# File 'lib/syntax_tree/yarv/instructions.rb', line 4787

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4795
4796
4797
# File 'lib/syntax_tree/yarv/instructions.rb', line 4795

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4775
4776
4777
# File 'lib/syntax_tree/yarv/instructions.rb', line 4775

def to_a(_iseq)
  [:putself]
end