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



4684
4685
4686
# File 'lib/syntax_tree/yarv/instructions.rb', line 4684

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

#call(vm) ⇒ Object



4692
4693
4694
# File 'lib/syntax_tree/yarv/instructions.rb', line 4692

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

#deconstruct_keys(_keys) ⇒ Object



4680
4681
4682
# File 'lib/syntax_tree/yarv/instructions.rb', line 4680

def deconstruct_keys(_keys)
  {}
end

#disasm(fmt) ⇒ Object



4672
4673
4674
# File 'lib/syntax_tree/yarv/instructions.rb', line 4672

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

#pushesObject



4688
4689
4690
# File 'lib/syntax_tree/yarv/instructions.rb', line 4688

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4696
4697
4698
# File 'lib/syntax_tree/yarv/instructions.rb', line 4696

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4676
4677
4678
# File 'lib/syntax_tree/yarv/instructions.rb', line 4676

def to_a(_iseq)
  [:putself]
end