Class: Duby::JVM::Types::JavaStaticMethod

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

Instance Method Summary collapse

Methods inherited from JavaMethod

#actual_return_type, #constructor?, #static?, #void?

Methods inherited from JavaConstructor

#actual_return_type, #argument_types, #constructor?, #declaring_class, #exceptions, #initialize, #name

Methods included from ArgumentConversion

#convert_args

Constructor Details

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

Instance Method Details

#call(compiler, ast, expression) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/duby/jvm/types/methods.rb', line 185

def call(compiler, ast, expression)
  target = ast.target.inferred_type
  convert_args(compiler, ast.parameters)
  compiler.method.invokestatic(
    target,
    name,
    [@member.return_type, *@member.argument_types])
  # if expression, void static methods return null, for consistency
  # TODO: inference phase needs to track that signature is void
  # but actual type is null object
  compiler.method.aconst_null if expression && void?
  compiler.method.pop unless expression || void?
end

#return_typeObject



175
176
177
178
179
180
181
182
183
# File 'lib/duby/jvm/types/methods.rb', line 175

def return_type
  @return_type ||= begin
    if @member.return_type
      AST.type(@member.return_type)
    else
      Void
    end
  end
end