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, #isVararg, #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



472
473
474
475
476
477
478
# File 'lib/mirah/jvm/types/methods.rb', line 472

def accept(visitor, expression)
  if self.static?
    visitor.visitStaticFieldAssign(self, expression)
  else
    visitor.visitFieldAssign(self, expression)
  end
end

#argument_typesObject



450
451
452
# File 'lib/mirah/jvm/types/methods.rb', line 450

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

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



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/mirah/jvm/types/methods.rb', line 454

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

#kindObject



480
481
482
483
484
485
486
# File 'lib/mirah/jvm/types/methods.rb', line 480

def kind
  if self.static?
    Java::OrgMirahJvmTypes::MemberKind::STATIC_FIELD_ASSIGN
  else
    Java::OrgMirahJvmTypes::MemberKind::FIELD_ASSIGN
  end
end

#return_typeObject



446
447
448
# File 'lib/mirah/jvm/types/methods.rb', line 446

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