Class: Duby::JVM::Types::JavaMethod
Instance Attribute Summary
Attributes inherited from JavaCallable
#member
Instance Method Summary
collapse
#argument_types, #declaring_class, #exceptions
#field?, #initialize, #name, #parameter_types
#convert_args
Instance Method Details
164
165
166
|
# File 'lib/duby/jvm/types/methods.rb', line 164
def abstract?
@member.abstract?
end
|
#actual_return_type ⇒ Object
152
153
154
155
156
157
158
|
# File 'lib/duby/jvm/types/methods.rb', line 152
def actual_return_type
if void?
Void
else
return_type
end
end
|
#call(compiler, ast, expression) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/duby/jvm/types/methods.rb', line 181
def call(compiler, ast, expression)
target = ast.target.inferred_type
ast.target.compile(compiler, true)
if expression && void?
compiler.method.dup
end
convert_args(compiler, ast.parameters)
if target.interface?
compiler.method.invokeinterface(
target,
name,
[@member.return_type, *@member.argument_types])
else
compiler.method.invokevirtual(
target,
name,
[@member.return_type, *@member.argument_types])
end
unless expression || void?
compiler.method.pop
end
end
|
#call_special(compiler, ast, expression) ⇒ Object
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/duby/jvm/types/methods.rb', line 211
def call_special(compiler, ast, expression)
target = ast.target.inferred_type
ast.target.compile(compiler, true)
if expression && void?
compiler.method.dup
end
convert_args(compiler, ast.parameters)
if target.interface?
raise "interfaces should not receive call_special"
else
compiler.method.invokespecial(
target,
name,
[@member.return_type, *@member.argument_types])
end
unless expression || void?
compiler.method.pop
end
end
|
#constructor? ⇒ Boolean
177
178
179
|
# File 'lib/duby/jvm/types/methods.rb', line 177
def constructor?
false
end
|
#return_type ⇒ Object
142
143
144
145
146
147
148
149
150
|
# File 'lib/duby/jvm/types/methods.rb', line 142
def return_type
@return_type ||= begin
if void?
declaring_class
else
AST.type(@member.return_type)
end
end
end
|
160
161
162
|
# File 'lib/duby/jvm/types/methods.rb', line 160
def static?
@member.static?
end
|
168
169
170
171
172
173
174
175
|
# File 'lib/duby/jvm/types/methods.rb', line 168
def void?
return_type = @member.return_type
return true if return_type.nil?
if return_type.respond_to?(:descriptor) && return_type.descriptor == 'V'
return true
end
false
end
|