Class: Atomy::Code::Block
Defined Under Namespace
Classes: PushProc
Instance Method Summary collapse
- #bytecode(gen, mod) ⇒ Object
-
#initialize(body, args = [], proc_argument = nil, lambda_style = true) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(body, args = [], proc_argument = nil, lambda_style = true) ⇒ Block
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/atomy/code/block.rb', line 4 def initialize(body, args = [], proc_argument = nil, lambda_style = true) @body = body @arguments = args.dup if args.last.is_a?(Atomy::Grammar::AST::Prefix) && args.last.operator == :* @splat_argument = @arguments.pop end @proc_argument = proc_argument @lambda_style = lambda_style end |
Instance Method Details
#bytecode(gen, mod) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/atomy/code/block.rb', line 17 def bytecode(gen, mod) blk = build_block(gen.state.scope, mod) if @lambda_style gen.push_cpath_top gen.find_const :Proc end gen.create_block(blk) if @lambda_style gen.send(:__from_block__, 1) gen.dup gen.send(:lambda_style!, 0) gen.pop end end |