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
- #call(vm) ⇒ Object
- #canonical ⇒ 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.
3040 3041 3042 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3040 def initialize(names) @names = names end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
3038 3039 3040 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3038 def names @names end |
Instance Method Details
#call(vm) ⇒ Object
3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3069 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
3065 3066 3067 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3065 def canonical self end |
#disasm(fmt) ⇒ Object
3044 3045 3046 3047 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3044 def disasm(fmt) cache = "<ic:0 #{names.join("::")}>" fmt.instruction("opt_getconstant_path", [cache]) end |
#length ⇒ Object
3053 3054 3055 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3053 def length 2 end |
#pops ⇒ Object
3057 3058 3059 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3057 def pops 0 end |
#pushes ⇒ Object
3061 3062 3063 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3061 def pushes 1 end |
#to_a(_iseq) ⇒ Object
3049 3050 3051 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 3049 def to_a(_iseq) [:opt_getconstant_path, names] end |