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



108
109
110
111
112
113
114
115
116
# File 'lib/mirah/jvm/types/methods.rb', line 108

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

#call(compiler, ast, expression) ⇒ Object



136
137
138
139
140
141
142
143
144
145
# File 'lib/mirah/jvm/types/methods.rb', line 136

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

Returns:



147
148
149
# File 'lib/mirah/jvm/types/methods.rb', line 147

def constructor?
  true
end

#declaring_classObject



132
133
134
# File 'lib/mirah/jvm/types/methods.rb', line 132

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

#exceptionsObject



122
123
124
125
126
127
128
129
130
# File 'lib/mirah/jvm/types/methods.rb', line 122

def exceptions
  @member.exception_types.map do |exception|
    if exception.kind_of?(Mirah::JVM::Types::Type)
      exception
    else
      Mirah::AST.type(nil, exception.class_name)
    end
  end
end

#return_typeObject



118
119
120
# File 'lib/mirah/jvm/types/methods.rb', line 118

def return_type
  declaring_class
end