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.



4821
4822
4823
# File 'lib/syntax_tree/yarv/instructions.rb', line 4821

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4819
4820
4821
# File 'lib/syntax_tree/yarv/instructions.rb', line 4819

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



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

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

#call(vm) ⇒ Object



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

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

#deconstruct_keys(_keys) ⇒ Object



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

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4825
4826
4827
# File 'lib/syntax_tree/yarv/instructions.rb', line 4825

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

#lengthObject



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

def length
  2
end

#pushesObject



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

def pushes
  1
end

#to_a(_iseq) ⇒ Object



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

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