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?, #type_parameters, #void?

Methods inherited from JavaConstructor

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

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, parameters = nil) ⇒ Object



317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/mirah/jvm/types/methods.rb', line 317

def call(compiler, ast, expression, parameters=nil)
  target = declaring_class
  parameters ||= ast.parameters
  convert_args(compiler, 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