Method: Ikra::Symbolic::ArrayCommand#block_def_node
- Defined in:
- lib/symbolic/symbolic.rb
#block_def_node ⇒ Object
Returns the abstract syntax tree for a parallel section.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/symbolic/symbolic.rb', line 334 def block_def_node if @ast == nil if block == nil return nil end # Get array of block parameter names block_params = block.parameters.map do |param| param[1] end parser_local_vars = command_binding.local_variables + block_params source = Parsing.parse_block(block, parser_local_vars) @ast = AST::BlockDefNode.new( parameters: block_params, ruby_block: block, # necessary to get binding body: AST::Builder.from_parser_ast(source)) end # Ensure `return` is there @ast.accept(Translator::LastStatementReturnsVisitor.new) return @ast end |