class SyntaxTree::YARV::DefineMethod
### Summary
‘definemethod` defines a method on the 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.
### Usage
~~~ruby def value = “value” ~~~
Attributes
method_iseq[R]
method_name[R]
Public Class Methods
new(method_name, method_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1071 def initialize(method_name, method_iseq) @method_name = method_name @method_iseq = method_iseq end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1092 def ==(other) other.is_a?(DefineMethod) && other.method_name == method_name && other.method_iseq == method_iseq end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1101 def call(vm) name = method_name nesting = vm.frame.nesting iseq = method_iseq vm .frame ._self .__send__(:define_method, name) do |*args, **kwargs, &block| vm.run_method_frame( name, nesting, iseq, self, *args, **kwargs, &block ) end end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1088 def deconstruct_keys(_keys) { method_name: method_name, method_iseq: method_iseq } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1076 def disasm(fmt) fmt.enqueue(method_iseq) fmt.instruction( "definemethod", [fmt.object(method_name), method_iseq.name] ) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1097 def length 3 end
to_a(_iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 1084 def to_a(_iseq) [:definemethod, method_name, method_iseq.to_a] end