Class: Duby::JVM::Types::JavaConstructor
- Includes:
- ArgumentConversion
- Defined in:
- lib/duby/jvm/types/methods.rb
Direct Known Subclasses
Instance Method Summary collapse
- #actual_return_type ⇒ Object
- #argument_types ⇒ Object
- #call(compiler, ast, expression) ⇒ Object
- #constructor? ⇒ Boolean
- #declaring_class ⇒ Object
- #exceptions ⇒ Object
-
#initialize(member) ⇒ JavaConstructor
constructor
A new instance of JavaConstructor.
- #name ⇒ Object
- #return_type ⇒ Object
Methods included from ArgumentConversion
Constructor Details
#initialize(member) ⇒ JavaConstructor
Returns a new instance of JavaConstructor.
64 65 66 |
# File 'lib/duby/jvm/types/methods.rb', line 64 def initialize(member) @member = member end |
Instance Method Details
#actual_return_type ⇒ Object
82 83 84 |
# File 'lib/duby/jvm/types/methods.rb', line 82 def actual_return_type return_type end |
#argument_types ⇒ Object
72 73 74 75 76 |
# File 'lib/duby/jvm/types/methods.rb', line 72 def argument_types @argument_types ||= @member.argument_types.map do |arg| AST.type(arg) if arg end end |
#call(compiler, ast, expression) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/duby/jvm/types/methods.rb', line 96 def call(compiler, ast, expression) target = ast.target.inferred_type compiler.method.new target compiler.method.dup if expression convert_args(compiler, ast.parameters) compiler.method.invokespecial( target, "<init>", [nil, *@member.argument_types]) end |
#constructor? ⇒ Boolean
107 108 109 |
# File 'lib/duby/jvm/types/methods.rb', line 107 def constructor? true end |
#declaring_class ⇒ Object
92 93 94 |
# File 'lib/duby/jvm/types/methods.rb', line 92 def declaring_class AST.type(@member.declaring_class) end |
#exceptions ⇒ Object
86 87 88 89 90 |
# File 'lib/duby/jvm/types/methods.rb', line 86 def exceptions @member.exception_types.map do |exception| AST.type(exception.name) end end |
#name ⇒ Object
68 69 70 |
# File 'lib/duby/jvm/types/methods.rb', line 68 def name @name ||= @member.name end |
#return_type ⇒ Object
78 79 80 |
# File 'lib/duby/jvm/types/methods.rb', line 78 def return_type declaring_class end |