Class: Duby::AST::JRubyAst::DefsNode

Inherits:
Object
  • Object
show all
Defined in:
lib/duby/transform.rb

Instance Method Summary collapse

Instance Method Details

#transform(transformer, parent) ⇒ Object



581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/duby/transform.rb', line 581

def transform(transformer, parent)
  actual_name = name
  if name =~ /=$/
    actual_name = name[0..-2] + '_set'
  end
  StaticMethodDefinition.new(parent,
                             position,
                             actual_name,
                             transformer.annotations) do |defn|
    signature = {:return => nil}
    if args_node && args_node.args
      args_node.args.child_nodes.each do |arg|
        if arg.respond_to? :type_node
          signature[arg.name.intern] =
            arg.type_node.type_reference(parent)
        end
      end
    end
    if body_node
      for node in body_node.child_nodes
        sig = node.signature(defn)
        break unless sig
        signature.update(sig) if sig.kind_of? ::Hash
      end
    end
    [
      signature,
      args_node ? transformer.transform(args_node, defn) : nil,
      body_node ? transformer.transform(body_node, defn) : nil
    ]
  end
end