# Get an instance of a array for a vararg
fun vararg_instance(mpropdef: MPropDef, recv: RuntimeVariable, varargs: Array[RuntimeVariable], elttype: MType): RuntimeVariable is abstract
src/compiler/abstract_compiler.nit:1849,2--1850,141
redef fun vararg_instance(mpropdef, recv, varargs, elttype)
do
# A vararg must be stored into an new array
# The trick is that the dymaic type of the array may depends on the receiver
# of the method (ie recv) if the static type is unresolved
# This is more complex than usual because the unresolved type must not be resolved
# with the current receiver (ie self).
# Therefore to isolate the resolution from self, a local StaticFrame is created.
# One can see this implementation as an inlined method of the receiver whose only
# job is to allocate the array
var old_frame = self.frame
var frame = new StaticFrame(self, mpropdef, mpropdef.mclassdef.bound_mtype, [recv])
self.frame = frame
#print "required Array[{elttype}] for recv {recv.inspect}. bound=Array[{self.resolve_for(elttype, recv)}]. selfvar={frame.arguments.first.inspect}"
var res = self.array_instance(varargs, elttype)
self.frame = old_frame
return res
end
src/compiler/separate_compiler.nit:1672,2--1689,4
# FIXME: this is currently buggy since recv is not exact
redef fun vararg_instance(mpropdef, recv, varargs, elttype)
do
elttype = self.resolve_for(elttype, recv)
return self.array_instance(varargs, elttype)
end
src/compiler/global_compiler.nit:721,2--726,4