Class: Duby::JVM::Types::JavaConstructor

Inherits:
Object
  • Object
show all
Includes:
ArgumentConversion
Defined in:
lib/duby/jvm/types/methods.rb

Direct Known Subclasses

JavaMethod

Instance Method Summary collapse

Methods included from ArgumentConversion

#convert_args

Constructor Details

#initialize(member) ⇒ JavaConstructor

Returns a new instance of JavaConstructor.



64
65
66
# File 'lib/duby/jvm/types/methods.rb', line 64

def initialize(member)
  @member = member
end

Instance Method Details

#actual_return_typeObject



82
83
84
# File 'lib/duby/jvm/types/methods.rb', line 82

def actual_return_type
  return_type
end

#argument_typesObject



72
73
74
75
76
# File 'lib/duby/jvm/types/methods.rb', line 72

def argument_types
  @argument_types ||= @member.argument_types.map do |arg|
    AST.type(arg) if arg
  end
end

#call(compiler, ast, expression) ⇒ Object



96
97
98
99
100
101
102
103
104
105
# File 'lib/duby/jvm/types/methods.rb', line 96

def call(compiler, ast, expression)
  target = ast.target.inferred_type
  compiler.method.new target
  compiler.method.dup if expression
  convert_args(compiler, ast.parameters)
  compiler.method.invokespecial(
    target,
    "<init>",
    [nil, *@member.argument_types])        
end

#constructor?Boolean

Returns:



107
108
109
# File 'lib/duby/jvm/types/methods.rb', line 107

def constructor?
  true
end

#declaring_classObject



92
93
94
# File 'lib/duby/jvm/types/methods.rb', line 92

def declaring_class
  AST.type(@member.declaring_class)
end

#exceptionsObject



86
87
88
89
90
# File 'lib/duby/jvm/types/methods.rb', line 86

def exceptions
  @member.exception_types.map do |exception|
    AST.type(exception.name)
  end
end

#nameObject



68
69
70
# File 'lib/duby/jvm/types/methods.rb', line 68

def name
  @name ||= @member.name
end

#return_typeObject



78
79
80
# File 'lib/duby/jvm/types/methods.rb', line 78

def return_type
  declaring_class
end