Class: Duby::JVM::Types::JavaDynamicMethod

Inherits:
JavaMethod show all
Defined in:
lib/duby/jvm/types/methods.rb

Instance Attribute Summary

Attributes inherited from JavaCallable

#member

Instance Method Summary collapse

Methods inherited from JavaMethod

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

Methods inherited from JavaConstructor

#actual_return_type, #constructor?, #exceptions

Methods inherited from JavaCallable

#field?, #name, #parameter_types

Methods included from ArgumentConversion

#convert_args

Constructor Details

#initialize(name, *types) ⇒ JavaDynamicMethod

Returns a new instance of JavaDynamicMethod.



256
257
258
259
# File 'lib/duby/jvm/types/methods.rb', line 256

def initialize(name, *types)
  @name = name
  @types = types
end

Instance Method Details

#argument_typesObject



269
270
271
# File 'lib/duby/jvm/types/methods.rb', line 269

def argument_types
  @types
end

#call(compiler, ast, expression) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/duby/jvm/types/methods.rb', line 273

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

  ast.parameters.each do |param|
    param.compile(compiler, true)
  end
  compiler.method.invokedynamic(
    target,
    "dyn:callPropWithThis:#{name}",
    [return_type, target, *@types])

  unless expression
    compiler.method.pop
  end

  compiler.bootstrap_dynamic
end

#declaring_classObject



265
266
267
# File 'lib/duby/jvm/types/methods.rb', line 265

def declaring_class
  java.lang.Object
end

#return_typeObject



261
262
263
# File 'lib/duby/jvm/types/methods.rb', line 261

def return_type
  AST.type('dynamic')
end