Class: SyntaxTree::YARV::PutObject

Inherits:
Object
  • Object
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

Constructor Details

#initialize(object) ⇒ PutObject

Returns a new instance of PutObject.



4830
4831
4832
# File 'lib/syntax_tree/yarv/instructions.rb', line 4830

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4828
4829
4830
# File 'lib/syntax_tree/yarv/instructions.rb', line 4828

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4846
4847
4848
# File 'lib/syntax_tree/yarv/instructions.rb', line 4846

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

#call(vm) ⇒ Object



4866
4867
4868
# File 'lib/syntax_tree/yarv/instructions.rb', line 4866

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

#canonicalObject



4862
4863
4864
# File 'lib/syntax_tree/yarv/instructions.rb', line 4862

def canonical
  self
end

#deconstruct_keys(_keys) ⇒ Object



4842
4843
4844
# File 'lib/syntax_tree/yarv/instructions.rb', line 4842

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4834
4835
4836
# File 'lib/syntax_tree/yarv/instructions.rb', line 4834

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

#lengthObject



4850
4851
4852
# File 'lib/syntax_tree/yarv/instructions.rb', line 4850

def length
  2
end

#popsObject



4854
4855
4856
# File 'lib/syntax_tree/yarv/instructions.rb', line 4854

def pops
  0
end

#pushesObject



4858
4859
4860
# File 'lib/syntax_tree/yarv/instructions.rb', line 4858

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4838
4839
4840
# File 'lib/syntax_tree/yarv/instructions.rb', line 4838

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