Class: SyntaxTree::YARV::InvokeBlock
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::InvokeBlock
- Defined in:
- lib/syntax_tree/yarv/instructions.rb
Overview
### Summary
invokeblock invokes the block given to the current method. It pops the arguments for the block off the stack and pushes the result of running the block onto the stack.
### Usage
~~~ruby def foo
yield
end ~~~
Instance Attribute Summary collapse
-
#calldata ⇒ Object
readonly
Returns the value of attribute calldata.
Instance Method Summary collapse
- #call(vm) ⇒ Object
- #canonical ⇒ Object
- #disasm(fmt) ⇒ Object
-
#initialize(calldata) ⇒ InvokeBlock
constructor
A new instance of InvokeBlock.
- #length ⇒ Object
- #pops ⇒ Object
- #pushes ⇒ Object
- #to_a(_iseq) ⇒ Object
Constructor Details
#initialize(calldata) ⇒ InvokeBlock
Returns a new instance of InvokeBlock.
1970 1971 1972 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1970 def initialize(calldata) @calldata = calldata end |
Instance Attribute Details
#calldata ⇒ Object (readonly)
Returns the value of attribute calldata.
1968 1969 1970 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1968 def calldata @calldata end |
Instance Method Details
#call(vm) ⇒ Object
1998 1999 2000 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1998 def call(vm) vm.push(vm.frame_yield.block.call(*vm.pop(calldata.argc))) end |
#canonical ⇒ Object
1994 1995 1996 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1994 def canonical self end |
#disasm(fmt) ⇒ Object
1974 1975 1976 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1974 def disasm(fmt) fmt.instruction("invokeblock", [fmt.calldata(calldata)]) end |
#length ⇒ Object
1982 1983 1984 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1982 def length 2 end |
#pops ⇒ Object
1986 1987 1988 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1986 def pops calldata.argc end |
#pushes ⇒ Object
1990 1991 1992 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1990 def pushes 1 end |
#to_a(_iseq) ⇒ Object
1978 1979 1980 |
# File 'lib/syntax_tree/yarv/instructions.rb', line 1978 def to_a(_iseq) [:invokeblock, calldata.to_h] end |