Class: SyntaxTree::YARV::PutObject

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

Overview

### Summary

‘putobject` pushes a known value onto the stack.

### Usage

~~~ruby 5 ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Instruction

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

Constructor Details

#initialize(object) ⇒ PutObject

Returns a new instance of PutObject.



4631
4632
4633
# File 'lib/syntax_tree/yarv/instructions.rb', line 4631

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4629
4630
4631
# File 'lib/syntax_tree/yarv/instructions.rb', line 4629

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4647
4648
4649
# File 'lib/syntax_tree/yarv/instructions.rb', line 4647

def ==(other)
  other.is_a?(PutObject) && other.object == object
end

#call(vm) ⇒ Object



4659
4660
4661
# File 'lib/syntax_tree/yarv/instructions.rb', line 4659

def call(vm)
  vm.push(object)
end

#deconstruct_keys(_keys) ⇒ Object



4643
4644
4645
# File 'lib/syntax_tree/yarv/instructions.rb', line 4643

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4635
4636
4637
# File 'lib/syntax_tree/yarv/instructions.rb', line 4635

def disasm(fmt)
  fmt.instruction("putobject", [fmt.object(object)])
end

#lengthObject



4651
4652
4653
# File 'lib/syntax_tree/yarv/instructions.rb', line 4651

def length
  2
end

#pushesObject



4655
4656
4657
# File 'lib/syntax_tree/yarv/instructions.rb', line 4655

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4663
4664
4665
# File 'lib/syntax_tree/yarv/instructions.rb', line 4663

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4639
4640
4641
# File 'lib/syntax_tree/yarv/instructions.rb', line 4639

def to_a(_iseq)
  [:putobject, object]
end