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

Inherits:
JavaCallable show all
Defined in:
lib/duby/jvm/types/methods.rb

Direct Known Subclasses

JavaMethod

Instance Attribute Summary

Attributes inherited from JavaCallable

#member

Instance Method Summary collapse

Methods inherited from JavaCallable

#field?, #initialize, #name, #parameter_types

Methods included from ArgumentConversion

#convert_args

Constructor Details

This class inherits a constructor from Duby::JVM::Types::JavaCallable

Instance Method Details

#actual_return_typeObject



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

def actual_return_type
  return_type
end

#argument_typesObject



93
94
95
96
97
98
99
100
101
# File 'lib/duby/jvm/types/methods.rb', line 93

def argument_types
  @argument_types ||= @member.argument_types.map do |arg|
    if arg.kind_of?(AST::TypeReference) || arg.nil?
      arg
    else
      AST.type(arg)
    end
  end
end

#call(compiler, ast, expression) ⇒ Object



125
126
127
128
129
130
131
132
133
134
# File 'lib/duby/jvm/types/methods.rb', line 125

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:



136
137
138
# File 'lib/duby/jvm/types/methods.rb', line 136

def constructor?
  true
end

#declaring_classObject



121
122
123
# File 'lib/duby/jvm/types/methods.rb', line 121

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

#exceptionsObject



111
112
113
114
115
116
117
118
119
# File 'lib/duby/jvm/types/methods.rb', line 111

def exceptions
  @member.exception_types.map do |exception|
    if exception.kind_of?(Duby::JVM::Types::Type)
      exception
    else
      Duby::AST.type(exception.class_name)
    end
  end
end

#return_typeObject



103
104
105
# File 'lib/duby/jvm/types/methods.rb', line 103

def return_type
  declaring_class
end