Class: Duby::AST::JRubyAst::HashNode

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

Instance Method Summary collapse

Instance Method Details

#signature(parent) ⇒ Object

Create a signature definition using a literal hash syntax



687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/duby/transform.rb', line 687

def signature(parent)
  # flag this as a declaration, so it transforms to a noop
  @declaration = true

  arg_types = {:return => nil}

  list = list_node.child_nodes.to_a
  list.each_index do |index|
    if index % 2 == 0
      if SymbolNode === list[index] && list[index].name == 'return'
        arg_types[:return] = list[index + 1].type_reference(parent)
      else
        arg_types[list[index].name.intern] = list[index + 1].type_reference(parent)
      end
    end
  end
  return arg_types
end

#transform(transformer, parent) ⇒ Object



676
677
678
679
680
681
682
683
684
# File 'lib/duby/transform.rb', line 676

def transform(transformer, parent)
  @declaration ||= false

  if @declaration
    Noop.new(parent, position)
  else
    super
  end
end