Class: SyntaxTree::YARV::OptGetConstantPath
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
::Object
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
Returns a new instance of OptGetConstantPath.
3313
3314
3315
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3313
def initialize(names)
@names = names
end
|
Instance Attribute Details
#names ⇒ Object
Returns the value of attribute names.
3311
3312
3313
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3311
def names
@names
end
|
Instance Method Details
#==(other) ⇒ Object
3330
3331
3332
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3330
def ==(other)
other.is_a?(OptGetConstantPath) && other.names == names
end
|
#call(vm) ⇒ Object
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3342
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
3326
3327
3328
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3326
def deconstruct_keys(_keys)
{ names: names }
end
|
#disasm(fmt) ⇒ Object
3317
3318
3319
3320
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3317
def disasm(fmt)
cache = "<ic:0 #{names.join("::")}>"
fmt.instruction("opt_getconstant_path", [cache])
end
|
#length ⇒ Object
3334
3335
3336
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3334
def length
2
end
|
#pushes ⇒ Object
3338
3339
3340
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3338
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
3322
3323
3324
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 3322
def to_a(_iseq)
[:opt_getconstant_path, names]
end
|