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::Long, JVM::Types::Null, JVM::Types::Object, JVM::Types::Short, JVM::Types::String, JVM::Types::TYPE_ORDERING, JVM::Types::Void

Constants included from JVM::MethodLookup

JVM::MethodLookup::BOOLEAN, JVM::MethodLookup::BYTE, JVM::MethodLookup::CHAR, JVM::MethodLookup::DOUBLE, JVM::MethodLookup::FLOAT, JVM::MethodLookup::INT, JVM::MethodLookup::LONG, JVM::MethodLookup::PrimitiveConversions, JVM::MethodLookup::SHORT

Constants included from Duby

Duby::TransformError, VERSION

Instance Method Summary collapse

Methods included from JVM::MethodLookup

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

Methods inherited from BaseTyper

#log, #to_s

Methods included from Duby

compile, parse, 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
# 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
    result = method.return_type if method
  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