Class: Java::OrgJrubyAst::HashNode

Inherits:
Object
  • Object
show all
Defined in:
lib/duby/old/compiler_old.rb,
lib/duby/old/declaration.rb,
lib/duby/old/signature.rb

Instance Method Summary collapse

Instance Method Details

#compile(builder) ⇒ Object



538
539
540
541
542
543
544
545
546
547
548
# File 'lib/duby/old/compiler_old.rb', line 538

def compile(builder)
  @declared ||= false
  
  if @declared
    # hash was used for type declaration, so we just push a null to skip it
    # TODO: it would be nice if we could just skip the null too, but BlockNode wants to pop it
    builder.aconst_null
  else
    raise CompileError.new(position, "Literal hash syntax not yet supported")
  end
end

#declare_types(builder) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/duby/old/declaration.rb', line 56

def declare_types(builder)
  @declared = true
  list = list_node.child_nodes.to_a
  list.each_index do |index|
    builder.local(list[index].name, list[index + 1].declared_type(builder)) if index % 2 == 0
  end
end

#signature(builder) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/duby/old/signature.rb', line 33

def signature(builder)
  @declared = true
  arg_types = []
  return_type = Void
  list = list_node.child_nodes.to_a
  list.each_index do |index|
    if index % 2 == 0
      if SymbolNode === list[index] && list[index].name == 'return'
        return_type = list[index + 1].declared_type(builder)
      else
        arg_types << list[index + 1].declared_type(builder)
      end
    end
  end
  return [return_type, *arg_types]
end