540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
# File 'lib/duby/transform.rb', line 540
def transform(transformer, parent)
actual_name = name
if name =~ /=$/
actual_name = name[0..-2] + '_set'
end
if name == 'initialize'
klass = ConstructorDefinition
else
klass = MethodDefinition
end
klass.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) && arg.type_node.respond_to?(:type_reference)
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
|