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.



4532
4533
4534
# File 'lib/syntax_tree/yarv/instructions.rb', line 4532

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4530
4531
4532
# File 'lib/syntax_tree/yarv/instructions.rb', line 4530

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4548
4549
4550
# File 'lib/syntax_tree/yarv/instructions.rb', line 4548

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

#call(vm) ⇒ Object



4560
4561
4562
# File 'lib/syntax_tree/yarv/instructions.rb', line 4560

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

#deconstruct_keys(_keys) ⇒ Object



4544
4545
4546
# File 'lib/syntax_tree/yarv/instructions.rb', line 4544

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4536
4537
4538
# File 'lib/syntax_tree/yarv/instructions.rb', line 4536

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

#lengthObject



4552
4553
4554
# File 'lib/syntax_tree/yarv/instructions.rb', line 4552

def length
  2
end

#pushesObject



4556
4557
4558
# File 'lib/syntax_tree/yarv/instructions.rb', line 4556

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


4564
4565
4566
# File 'lib/syntax_tree/yarv/instructions.rb', line 4564

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4540
4541
4542
# File 'lib/syntax_tree/yarv/instructions.rb', line 4540

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