Class: Mirah::JVM::Types::JavaConstructor

Inherits:
JavaCallable show all
Defined in:
lib/mirah/jvm/types/methods.rb

Direct Known Subclasses

JavaMethod

Instance Attribute Summary

Attributes inherited from JavaCallable

#member

Instance Method Summary collapse

Methods inherited from JavaCallable

#field?, #initialize, #name, #parameter_types

Methods included from ArgumentConversion

#convert_args

Constructor Details

This class inherits a constructor from Mirah::JVM::Types::JavaCallable

Instance Method Details

#argument_typesObject



157
158
159
160
161
162
163
164
165
# File 'lib/mirah/jvm/types/methods.rb', line 157

def argument_types
  @argument_types ||= @member.argument_types.map do |arg|
    if arg.kind_of?(Type) || arg.nil?
      arg
    else
      @types.type(nil, arg)
    end
  end
end

#call(compiler, ast, expression, parameters = nil, delegate = false) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/mirah/jvm/types/methods.rb', line 189

def call(compiler, ast, expression, parameters=nil, delegate=false)
  target = compiler.inferred_type(ast.target)
  unless delegate
    compiler.method.new target
    compiler.method.dup if expression
  end
  parameters ||= ast.parameters
  convert_args(compiler, parameters)
  compiler.method.invokespecial(
    target,
    "<init>",
    [nil, *@member.argument_types])
end

#constructor?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/mirah/jvm/types/methods.rb', line 203

def constructor?
  true
end

#declaring_classObject



181
182
183
# File 'lib/mirah/jvm/types/methods.rb', line 181

def declaring_class
  @types.type(nil, @member.declaring_class)
end

#exceptionsObject



171
172
173
174
175
176
177
178
179
# File 'lib/mirah/jvm/types/methods.rb', line 171

def exceptions
  @member.exception_types.map do |exception|
    if exception.kind_of?(ResolvedType)
      exception
    else
      @types.type(nil, exception.class_name)
    end
  end
end

#return_typeObject



167
168
169
# File 'lib/mirah/jvm/types/methods.rb', line 167

def return_type
  declaring_class
end

#type_parametersObject



185
186
187
# File 'lib/mirah/jvm/types/methods.rb', line 185

def type_parameters
  @declaring_class and @declaring_class.jvm_type.type_parameters
end

#varargs?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/mirah/jvm/types/methods.rb', line 207

def varargs?
  @member.varargs?
end