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

Methods inherited from JavaConstructor

#constructor?, #declaring_class, #exceptions

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



345
346
347
# File 'lib/mirah/jvm/types/methods.rb', line 345

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

#call(compiler, ast, expression) ⇒ Object



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/mirah/jvm/types/methods.rb', line 349

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

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

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

#return_typeObject



341
342
343
# File 'lib/mirah/jvm/types/methods.rb', line 341

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