Class: Duby::Typer::JavaTyper
- 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
Instance Method Summary collapse
-
#initialize ⇒ JavaTyper
constructor
A new instance of JavaTyper.
- #method_type(typer, target_type, name, parameter_types) ⇒ Object
- #name ⇒ Object
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
Methods included from Duby
compile, parse, plugins, print_error, reset, run, typer_plugins
Constructor Details
#initialize ⇒ JavaTyper
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. && name == 'new' && parameter_types == [] = target_type. if .respond_to?(:default_constructor) result = .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 |
#name ⇒ Object
15 16 17 |
# File 'lib/duby/plugin/java.rb', line 15 def name "Java" end |