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, #isVararg, #return_type, #type_parameters, #varargs?

Methods inherited from JavaCallable

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

Methods included from ArgumentConversion

#convert_args

Constructor Details

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

Instance Method Details

#accept(visitor, expression) ⇒ Object



381
382
383
# File 'lib/mirah/jvm/types/methods.rb', line 381

def accept(visitor, expression)
  visitor.visitStaticMethodCall(self, expression)
end

#call(compiler, ast, expression, parameters = nil) ⇒ Object



366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/mirah/jvm/types/methods.rb', line 366

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

#kindObject



385
386
387
# File 'lib/mirah/jvm/types/methods.rb', line 385

def kind
  Java::OrgMirahJvmTypes::MemberKind::STATIC_METHOD
end