class SyntaxTree::YARV::CheckKeyword
### Summary
‘checkkeyword` checks if a keyword was passed at the callsite that called into the method represented by the instruction sequence. It has two arguments: the index of the local variable that stores the keywords metadata and the index of the keyword within that metadata. It pushes a boolean onto the stack indicating whether or not the keyword was given.
### Usage
~~~ruby def evaluate(value: rand)
value
end
evaluate(value: 3) ~~~
Attributes
keyword_bits_index[R]
keyword_index[R]
Public Class Methods
new(keyword_bits_index, keyword_index)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 362 def initialize(keyword_bits_index, keyword_index) @keyword_bits_index = keyword_bits_index @keyword_index = keyword_index end
Public Instance Methods
==(other)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 386 def ==(other) other.is_a?(CheckKeyword) && other.keyword_bits_index == keyword_bits_index && other.keyword_index == keyword_index end
call(vm)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 400 def call(vm) vm.push(vm.local_get(keyword_bits_index, 0)[keyword_index]) end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 382 def deconstruct_keys(_keys) { keyword_bits_index: keyword_bits_index, keyword_index: keyword_index } end
disasm(fmt)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 367 def disasm(fmt) fmt.instruction( "checkkeyword", [fmt.object(keyword_bits_index), fmt.object(keyword_index)] ) end
length()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 392 def length 3 end
pushes()
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 396 def pushes 1 end
to_a(iseq)
click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 374 def to_a(iseq) [ :checkkeyword, iseq.local_table.offset(keyword_bits_index), keyword_index ] end