Class: SyntaxTree::YARV::PutString

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

Overview

### Summary

‘putstring` pushes an unfrozen string literal onto the stack.

### Usage

~~~ruby “foo” ~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Instruction

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

Constructor Details

#initialize(object) ⇒ PutString

Returns a new instance of PutString.



4763
4764
4765
# File 'lib/syntax_tree/yarv/instructions.rb', line 4763

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4761
4762
4763
# File 'lib/syntax_tree/yarv/instructions.rb', line 4761

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4779
4780
4781
# File 'lib/syntax_tree/yarv/instructions.rb', line 4779

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

#call(vm) ⇒ Object



4791
4792
4793
# File 'lib/syntax_tree/yarv/instructions.rb', line 4791

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

#deconstruct_keys(_keys) ⇒ Object



4775
4776
4777
# File 'lib/syntax_tree/yarv/instructions.rb', line 4775

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4767
4768
4769
# File 'lib/syntax_tree/yarv/instructions.rb', line 4767

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

#lengthObject



4783
4784
4785
# File 'lib/syntax_tree/yarv/instructions.rb', line 4783

def length
  2
end

#pushesObject



4787
4788
4789
# File 'lib/syntax_tree/yarv/instructions.rb', line 4787

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4771
4772
4773
# File 'lib/syntax_tree/yarv/instructions.rb', line 4771

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