class SyntaxTree::YARV::DefineSMethod
### Summary
‘definesmethod` defines a method on the singleton class of the current value of `self`. It accepts two arguments. The first is the name of the method being defined. The second is the instruction sequence representing the body of the method. It pops the object off the stack that the method should be defined on.
### Usage
~~~ruby def self.value = “value” ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1193 def initialize(method_name, method_iseq) @method_name = method_name @method_iseq = method_iseq end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1214 def ==(other) other.is_a?(DefineSMethod) && other.method_name == method_name && other.method_iseq == method_iseq end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1227 def call(vm) name = method_name nesting = vm.frame.nesting iseq = method_iseq vm .frame ._self .__send__(:define_singleton_method, name) do |*args, **kwargs, &block| vm.run_method_frame( name, nesting, iseq, self, *args, **kwargs, &block ) end end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1210 def deconstruct_keys(_keys) { method_name: method_name, method_iseq: method_iseq } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1198 def disasm(fmt) fmt.enqueue(method_iseq) fmt.instruction( "definesmethod", [fmt.object(method_name), method_iseq.name] ) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1206 def to_a(_iseq) [:definesmethod, method_name, method_iseq.to_a] end