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.



4520
4521
4522
# File 'lib/syntax_tree/yarv/instructions.rb', line 4520

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4518
4519
4520
# File 'lib/syntax_tree/yarv/instructions.rb', line 4518

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



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

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

#call(vm) ⇒ Object



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

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

#deconstruct_keys(_keys) ⇒ Object



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

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4524
4525
4526
# File 'lib/syntax_tree/yarv/instructions.rb', line 4524

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

#lengthObject



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

def length
  2
end

#pushesObject



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

def pushes
  1
end

#side_effects?Boolean

Returns:

  • (Boolean)


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

def side_effects?
  false
end

#to_a(_iseq) ⇒ Object



4528
4529
4530
# File 'lib/syntax_tree/yarv/instructions.rb', line 4528

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