Class: SyntaxTree::YARV::OptGetConstantPath
- Inherits:
-
Instruction
- Object
- Instruction
- 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
- #deconstruct_keys(_keys) ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(names) ⇒ OptGetConstantPath
constructor
A new instance of OptGetConstantPath.
- #length ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(names) ⇒ OptGetConstantPath
Returns a new instance of OptGetConstantPath.
3202 3203 3204 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3202 def initialize(names) @names = names end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
3200 3201 3202 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3200 def names @names end |
Instance Method Details
#==(other) ⇒ Object
3219 3220 3221 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3219 def ==(other) other.is_a?(OptGetConstantPath) && other.names == names end |
#call(vm) ⇒ Object
3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3231 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 |
#deconstruct_keys(_keys) ⇒ Object
3215 3216 3217 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3215 def deconstruct_keys(_keys) { names: names } end |
#disasm(fmt) ⇒ Object
3206 3207 3208 3209 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3206 def disasm(fmt) cache = "<ic:0 #{names.join("::")}>" fmt.instruction("opt_getconstant_path", [cache]) end |
#length ⇒ Object
3223 3224 3225 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3223 def length 2 end |
#pushes ⇒ Object
3227 3228 3229 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3227 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3211 3212 3213 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3211 def to_a(_iseq) [:opt_getconstant_path, names] end |