Class: Mirah::JVM::Types::JavaFieldSetter

Inherits:
JavaFieldAccessor 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 JavaFieldAccessor

#field?, #final?, #public?

Methods inherited from JavaMethod

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

Methods inherited from JavaConstructor

#constructor?, #declaring_class, #exceptions, #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

#argument_typesObject



425
426
427
# File 'lib/mirah/jvm/types/methods.rb', line 425

def argument_types
  [@types.type(nil, @member.type)]
end

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



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/mirah/jvm/types/methods.rb', line 429

def call(compiler, ast, expression, parameters=nil)
  target = compiler.inferred_type(ast.target)

  # TODO: assert that no args are being passed, though that should have failed lookup

  parameters ||= ast.parameters
  if @member.static?
    convert_args(compiler, parameters)
    compiler.method.dup if expression
    compiler.method.putstatic(target, name, @member.type)
  else
    compiler.visit(ast.target, true)
    convert_args(compiler, parameters)
    compiler.method.dup_x2 if expression
    compiler.method.putfield(target, name, @member.type)
  end
end

#return_typeObject



421
422
423
# File 'lib/mirah/jvm/types/methods.rb', line 421

def return_type
  @types.type(nil, @member.type)
end