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.



4922
4923
4924
# File 'lib/syntax_tree/yarv/instructions.rb', line 4922

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4920
4921
4922
# File 'lib/syntax_tree/yarv/instructions.rb', line 4920

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4938
4939
4940
# File 'lib/syntax_tree/yarv/instructions.rb', line 4938

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

#call(vm) ⇒ Object



4950
4951
4952
# File 'lib/syntax_tree/yarv/instructions.rb', line 4950

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

#deconstruct_keys(_keys) ⇒ Object



4934
4935
4936
# File 'lib/syntax_tree/yarv/instructions.rb', line 4934

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4926
4927
4928
# File 'lib/syntax_tree/yarv/instructions.rb', line 4926

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

#lengthObject



4942
4943
4944
# File 'lib/syntax_tree/yarv/instructions.rb', line 4942

def length
  2
end

#pushesObject



4946
4947
4948
# File 'lib/syntax_tree/yarv/instructions.rb', line 4946

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4930
4931
4932
# File 'lib/syntax_tree/yarv/instructions.rb', line 4930

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