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



4730
4731
4732
# File 'lib/syntax_tree/yarv/instructions.rb', line 4730

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

#call(vm) ⇒ Object



4738
4739
4740
# File 'lib/syntax_tree/yarv/instructions.rb', line 4738

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

#deconstruct_keys(_keys) ⇒ Object



4726
4727
4728
# File 'lib/syntax_tree/yarv/instructions.rb', line 4726

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



4718
4719
4720
# File 'lib/syntax_tree/yarv/instructions.rb', line 4718

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

#pushesObject



4734
4735
4736
# File 'lib/syntax_tree/yarv/instructions.rb', line 4734

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4742
4743
4744
# File 'lib/syntax_tree/yarv/instructions.rb', line 4742

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4722
4723
4724
# File 'lib/syntax_tree/yarv/instructions.rb', line 4722

def to_a(_iseq)
  [:putself]
end