Class: SyntaxTree::YARV::PutChilledString

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

Overview

### Summary

‘putchilledstring` pushes an unfrozen string literal onto the stack that acts like a frozen string. This is a migration path to frozen string literals as the default in the future.

### 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) ⇒ PutChilledString

Returns a new instance of PutChilledString.



4876
4877
4878
# File 'lib/syntax_tree/yarv/instructions.rb', line 4876

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4874
4875
4876
# File 'lib/syntax_tree/yarv/instructions.rb', line 4874

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



4892
4893
4894
# File 'lib/syntax_tree/yarv/instructions.rb', line 4892

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

#call(vm) ⇒ Object



4904
4905
4906
# File 'lib/syntax_tree/yarv/instructions.rb', line 4904

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

#deconstruct_keys(_keys) ⇒ Object



4888
4889
4890
# File 'lib/syntax_tree/yarv/instructions.rb', line 4888

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



4880
4881
4882
# File 'lib/syntax_tree/yarv/instructions.rb', line 4880

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

#lengthObject



4896
4897
4898
# File 'lib/syntax_tree/yarv/instructions.rb', line 4896

def length
  2
end

#pushesObject



4900
4901
4902
# File 'lib/syntax_tree/yarv/instructions.rb', line 4900

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4884
4885
4886
# File 'lib/syntax_tree/yarv/instructions.rb', line 4884

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