Class: Mirah::JVM::Types::JavaStaticMethod

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

Instance Attribute Summary

Attributes inherited from JavaCallable

#member

Instance Method Summary collapse

Methods inherited from JavaMethod

#abstract?, #call_special, #constructor?, #return_type, #static?, #void?

Methods inherited from JavaConstructor

#argument_types, #constructor?, #declaring_class, #exceptions, #return_type

Methods inherited from JavaCallable

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

Methods included from ArgumentConversion

#convert_args

Constructor Details

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

Instance Method Details

#call(compiler, ast, expression) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/mirah/jvm/types/methods.rb', line 243

def call(compiler, ast, expression)
  target = declaring_class
  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?
  return_type.pop(compiler.method) unless expression || void?
end