Class: SyntaxTree::YARV::PutSpecialObject

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

Overview

### Summary

putspecialobject pushes one of three special objects onto the stack. These are either the VM core special object, the class base special object, or the constant base special object.

### Usage

~~~ruby alias foo bar ~~~

Constant Summary collapse

OBJECT_VMCORE =
1
OBJECT_CBASE =
2
OBJECT_CONST_BASE =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ PutSpecialObject

Returns a new instance of PutSpecialObject.



4387
4388
4389
# File 'lib/syntax_tree/yarv/instructions.rb', line 4387

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4385
4386
4387
# File 'lib/syntax_tree/yarv/instructions.rb', line 4385

def object
  @object
end

Instance Method Details

#call(vm) ⇒ Object



4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
# File 'lib/syntax_tree/yarv/instructions.rb', line 4415

def call(vm)
  case object
  when OBJECT_VMCORE
    vm.push(vm.frozen_core)
  when OBJECT_CBASE
    value = vm.frame._self
    value = value.singleton_class unless value.is_a?(Class)
    vm.push(value)
  when OBJECT_CONST_BASE
    vm.push(vm.const_base)
  end
end

#canonicalObject



4411
4412
4413
# File 'lib/syntax_tree/yarv/instructions.rb', line 4411

def canonical
  self
end

#disasm(fmt) ⇒ Object



4391
4392
4393
# File 'lib/syntax_tree/yarv/instructions.rb', line 4391

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

#lengthObject



4399
4400
4401
# File 'lib/syntax_tree/yarv/instructions.rb', line 4399

def length
  2
end

#popsObject



4403
4404
4405
# File 'lib/syntax_tree/yarv/instructions.rb', line 4403

def pops
  0
end

#pushesObject



4407
4408
4409
# File 'lib/syntax_tree/yarv/instructions.rb', line 4407

def pushes
  1
end

#to_a(_iseq) ⇒ Object



4395
4396
4397
# File 'lib/syntax_tree/yarv/instructions.rb', line 4395

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