Class: SyntaxTree::YARV::PutString

Inherits:
Object
  • Object
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

Constructor Details

#initialize(object) ⇒ PutString

Returns a new instance of PutString.



4442
4443
4444
# File 'lib/syntax_tree/yarv/instructions.rb', line 4442

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4440
4441
4442
# File 'lib/syntax_tree/yarv/instructions.rb', line 4440

def object
  @object
end

Instance Method Details

#call(vm) ⇒ Object



4470
4471
4472
# File 'lib/syntax_tree/yarv/instructions.rb', line 4470

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

#canonicalObject



4466
4467
4468
# File 'lib/syntax_tree/yarv/instructions.rb', line 4466

def canonical
  self
end

#disasm(fmt) ⇒ Object



4446
4447
4448
# File 'lib/syntax_tree/yarv/instructions.rb', line 4446

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

#lengthObject



4454
4455
4456
# File 'lib/syntax_tree/yarv/instructions.rb', line 4454

def length
  2
end

#popsObject



4458
4459
4460
# File 'lib/syntax_tree/yarv/instructions.rb', line 4458

def pops
  0
end

#pushesObject



4462
4463
4464
# File 'lib/syntax_tree/yarv/instructions.rb', line 4462

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4450
4451
4452
# File 'lib/syntax_tree/yarv/instructions.rb', line 4450

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