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.



4578
4579
4580
# File 'lib/syntax_tree/yarv/instructions.rb', line 4578

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4576
4577
4578
# File 'lib/syntax_tree/yarv/instructions.rb', line 4576

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4594
4595
4596
# File 'lib/syntax_tree/yarv/instructions.rb', line 4594

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

#call(vm) ⇒ Object



4606
4607
4608
# File 'lib/syntax_tree/yarv/instructions.rb', line 4606

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

#deconstruct_keys(_keys) ⇒ Object



4590
4591
4592
# File 'lib/syntax_tree/yarv/instructions.rb', line 4590

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4582
4583
4584
# File 'lib/syntax_tree/yarv/instructions.rb', line 4582

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

#lengthObject



4598
4599
4600
# File 'lib/syntax_tree/yarv/instructions.rb', line 4598

def length
  2
end

#pushesObject



4602
4603
4604
# File 'lib/syntax_tree/yarv/instructions.rb', line 4602

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4610
4611
4612
# File 'lib/syntax_tree/yarv/instructions.rb', line 4610

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4586
4587
4588
# File 'lib/syntax_tree/yarv/instructions.rb', line 4586

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