Class: Duby::Typer::JavaTyper

Inherits:
BaseTyper show all
Includes:
JVM::MethodLookup, JVM::Types
Defined in:
lib/duby/plugin/java.rb

Constant Summary

Constants included from JVM::Types

JVM::Types::Boolean, JVM::Types::Byte, JVM::Types::Char, JVM::Types::Double, JVM::Types::Float, JVM::Types::Int, JVM::Types::Iterable, JVM::Types::Long, JVM::Types::Null, JVM::Types::Object, JVM::Types::Short, JVM::Types::String, JVM::Types::TYPE_ORDERING, JVM::Types::Void, JVM::Types::WIDENING_CONVERSIONS

Constants included from Duby

Duby::TransformError

Instance Method Summary collapse

Methods included from JVM::MethodLookup

#each_is_exact, #each_is_exact_or_subtype_or_convertible, #field_lookup, #find_jls, #find_method, #inner_class, #is_more_specific?, #log, #phase1, #phase2, #phase3, #primitive_convertible?

Methods inherited from BaseTyper

#log, #to_s

Methods included from Duby

compile, parse, plugins, print_error, reset, run, typer_plugins

Constructor Details

#initializeJavaTyper

Returns a new instance of JavaTyper.



12
13
# File 'lib/duby/plugin/java.rb', line 12

def initialize
end

Instance Method Details

#method_type(typer, target_type, name, parameter_types) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/duby/plugin/java.rb', line 19

def method_type(typer, target_type, name, parameter_types)
  return if target_type.nil? or parameter_types.any? {|t| t.nil?}
  if target_type.respond_to? :get_method
    method = target_type.get_method(name, parameter_types)
    unless method || target_type.basic_type.kind_of?(TypeDefinition)
      raise NoMethodError, "Method %s(%s) on %s not found" %
          [name, parameter_types.join(', '), target_type]
    end
    if method
      result = method.return_type
    elsif typer.last_chance && target_type.meta? &&
        name == 'new' && parameter_types == []
      unmeta = target_type.unmeta
      if unmeta.respond_to?(:default_constructor)
        result = unmeta.default_constructor
        typer.last_chance = false if result
      end
    end
  end

  if result
    log "Method type for \"#{name}\" #{parameter_types} on #{target_type} = #{result}"
  else
    log "Method type for \"#{name}\" #{parameter_types} on #{target_type} not found"
  end

  result
end

#nameObject



15
16
17
# File 'lib/duby/plugin/java.rb', line 15

def name
  "Java"
end