Class: SyntaxTree::YARV::OptGetConstantPath
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::OptGetConstantPath
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
opt_getconstant_path performs a constant lookup on a chain of constant names. It accepts as its argument an array of constant names, and pushes the value of the constant onto the stack.
### Usage
~~~ruby ::Object ~~~
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(names) ⇒ OptGetConstantPath
constructor
A new instance of OptGetConstantPath.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(names) ⇒ OptGetConstantPath
Returns a new instance of OptGetConstantPath.
3464 3465 3466 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3464 def initialize(names) @names = names end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
3462 3463 3464 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3462 def names @names end |
Instance Method Details
#==(other) ⇒ Object
3481 3482 3483 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3481 def ==(other) other.is_a?(OptGetConstantPath) && other.names == names end |
#call(vm) ⇒ Object
3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3501 def call(vm) current = vm.frame._self current = current.class unless current.is_a?(Class) names.each do |name| current = name == :"" ? Object : current.const_get(name) end vm.push(current) end |
#canonical ⇒ Object
3497 3498 3499 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3497 def canonical self end |
#deconstruct_keys(_keys) ⇒ Object
3477 3478 3479 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3477 def deconstruct_keys(_keys) { names: names } end |
#disasm(fmt) ⇒ Object
3468 3469 3470 3471 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3468 def disasm(fmt) cache = "<ic:0 #{names.join("::")}>" fmt.instruction("opt_getconstant_path", [cache]) end |
#length ⇒ Object
3485 3486 3487 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3485 def length 2 end |
#pops ⇒ Object
3489 3490 3491 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3489 def pops 0 end |
#pushes ⇒ Object
3493 3494 3495 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3493 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3473 3474 3475 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3473 def to_a(_iseq) [:opt_getconstant_path, names] end |