Class: SyntaxTree::YARV::PutSpecialObject
- Inherits:
-
Instruction
- Object
- Instruction
- SyntaxTree::YARV::PutSpecialObject
- 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
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(object) ⇒ PutSpecialObject
constructor
A new instance of PutSpecialObject.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(object) ⇒ PutSpecialObject
Returns a new instance of PutSpecialObject.
4819 4820 4821 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4819 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4817 4818 4819 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4817 def object @object end |
Instance Method Details
#==(other) ⇒ Object
4835 4836 4837 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4835 def ==(other) other.is_a?(PutSpecialObject) && other.object == object end |
#call(vm) ⇒ Object
4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4847 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 |
#deconstruct_keys(_keys) ⇒ Object
4831 4832 4833 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4831 def deconstruct_keys(_keys) { object: object } end |
#disasm(fmt) ⇒ Object
4823 4824 4825 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4823 def disasm(fmt) fmt.instruction("putspecialobject", [fmt.object(object)]) end |
#length ⇒ Object
4839 4840 4841 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4839 def length 2 end |
#pushes ⇒ Object
4843 4844 4845 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4843 def pushes 1 end |
#to_a(_iseq) ⇒ Object
4827 4828 4829 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 4827 def to_a(_iseq) [:putspecialobject, object] end |