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.



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

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4773
4774
4775
# File 'lib/syntax_tree/yarv/instructions.rb', line 4773

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



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

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

#call(vm) ⇒ Object



4803
4804
4805
# File 'lib/syntax_tree/yarv/instructions.rb', line 4803

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

#deconstruct_keys(_keys) ⇒ Object



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

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



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

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

#lengthObject



4795
4796
4797
# File 'lib/syntax_tree/yarv/instructions.rb', line 4795

def length
  2
end

#pushesObject



4799
4800
4801
# File 'lib/syntax_tree/yarv/instructions.rb', line 4799

def pushes
  1
end

#to_a(_iseq) ⇒ Object



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

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