else if mclass.name == "NativeString" then
return "char*"
else if mclass.name == "NativeArray" then
- assert self isa MGenericType
return "{self.arguments.first.ctype}*"
else if mclass.kind == extern_kind then
return "void*"
v.ret(v.new_expr("(char*)GC_MALLOC({arguments[1]})", ret.as(not null)))
return
else if pname == "calloc_array" then
- var elttype = arguments.first.mtype.supertype_to(v.compiler.mainmodule,arguments.first.mtype.as(MClassType),v.get_class("ArrayCapable")).as(MGenericType).arguments.first
+ var elttype = arguments.first.mtype.supertype_to(v.compiler.mainmodule,arguments.first.mtype.as(MClassType),v.get_class("ArrayCapable")).arguments.first
v.ret(v.new_expr("({elttype.ctype}*)GC_MALLOC({arguments[1]} * sizeof({elttype.ctype}))", ret.as(not null)))
return
else if pname == "object_id" then
redef class AArrayExpr
redef fun expr(v)
do
- var mtype = self.mtype.as(MGenericType).arguments.first
+ var mtype = self.mtype.as(MClassType).arguments.first
var array = new Array[RuntimeVariable]
for nexpr in self.n_exprs.n_exprs do
var i = v.expr(nexpr, mtype)
else if p.mtype.mclass == sup.mtype.mclass then
# found the same class (ie. p.mclass = B[B#0] = sup.mclass)
# compare formal types arguments
- for i in [0..p.mtype.as(MGenericType).arguments.length[ do
+ for i in [0..p.mtype.arguments.length[ do
# erase nullable annotation of p arg
- var sarg = p.mtype.as(MGenericType).arguments[i]
+ var sarg = p.mtype.arguments[i]
if sarg isa MNullableType then sarg = sarg.mtype
var sft = typing.load_type(sarg.as(MClassType))
# erase nullable annotation of super arg
- var suparg = sup.mtype.as(MGenericType).arguments[i]
+ var suparg = sup.mtype.arguments[i]
if suparg isa MNullableType then suparg = suparg.mtype
var pft = typing.load_type(suparg.as(MClassType))
if not sft.is_subtype_fallback(pft) then
if not sup isa MGenericType then return true
var sub2 = sub.supertype_to(mmodule, anchor, sup.mclass)
assert sub2.mclass == sup.mclass
- assert sub2 isa MGenericType
for i in [0..sup.mclass.arity[ do
var sub_arg = sub2.arguments[i]
var sup_arg = sup.arguments[i]
if t.mclass == goalclass then
# Yeah! c specialize goalclass with a "super `t'". So the question is what is the argument of f
# FIXME: Here, we stop on the first goal. Should we check others and detect inconsistencies?
- assert t isa MGenericType
var res = t.arguments[self.rank]
return res
end
if resolved_receiver isa MNullableType then resolved_receiver = resolved_receiver.mtype
if resolved_receiver isa MParameterType then
assert resolved_receiver.mclass == anchor.mclass
- resolved_receiver = anchor.as(MGenericType).arguments[resolved_receiver.rank]
+ resolved_receiver = anchor.arguments[resolved_receiver.rank]
if resolved_receiver isa MNullableType then resolved_receiver = resolved_receiver.mtype
end
assert resolved_receiver isa MClassType else print "{class_name}: {self}/{mtype}/{anchor}? {resolved_receiver}"
# Eh! The parameter is in the current class.
# So we return the corresponding argument, no mater what!
if resolved_receiver.mclass == self.mclass then
- assert resolved_receiver isa MGenericType
var res = resolved_receiver.arguments[self.rank]
#print "{class_name}: {self}/{mtype}/{anchor} -> direct {res}"
return res
bounds.add(objectclass.mclass_type.as_nullable)
else
# Inherit the bound
- bounds.add(mclass.mclassdefs.first.bound_mtype.as(MGenericType).arguments[i])
+ bounds.add(mclass.mclassdefs.first.bound_mtype.arguments[i])
end
end
end
end
for i in [0..mclassdef.parameter_names.length[ do
if mclassdef.parameter_names[i] == name then
- res = mclassdef.mclass.mclass_type.as(MGenericType).arguments[i]
+ res = mclassdef.mclass.mclass_type.arguments[i]
if ntype.n_kwnullable != null then res = res.as_nullable
return res
end
end
else if pname == "calloc_array" then
var recvtype = args.first.mtype.as(MClassType)
- var mtype: MType = recvtype.supertype_to(v.mainmodule, recvtype, v.mainmodule.get_primitive_class("ArrayCapable"))
- mtype = mtype.as(MGenericType).arguments.first
+ var mtype: MType
+ mtype = recvtype.supertype_to(v.mainmodule, recvtype, v.mainmodule.get_primitive_class("ArrayCapable"))
+ mtype = mtype.arguments.first
var val = new Array[Instance].filled_with(v.null_instance, args[1].to_i)
return new PrimitiveInstance[Array[Instance]](v.mainmodule.get_primitive_class("NativeArray").get_mtype([mtype]), val)
end
if i == null then return null
val.add(i)
end
- var mtype = v.unanchor_type(self.mtype.as(not null)).as(MGenericType)
+ var mtype = v.unanchor_type(self.mtype.as(not null)).as(MClassType)
var elttype = mtype.arguments.first
return v.array_instance(val, elttype)
end
redef class AArrayExpr
redef fun accept_rapid_type_vistor(v)
do
- var mtype = self.mtype.as(not null)
+ var mtype = self.mtype.as(MClassType)
v.add_type(mtype)
- var native = v.get_class("NativeArray").get_mtype([mtype.as(MGenericType).arguments.first])
+ var native = v.get_class("NativeArray").get_mtype([mtype.arguments.first])
v.add_type(native)
var prop = v.get_method(mtype, "with_native")
v.add_monomorphic_send(mtype, prop)
end
redef class AForExpr
- var coltype: nullable MGenericType
+ var coltype: nullable MClassType
private fun do_type_iterator(v: TypeVisitor, mtype: MType)
do
var colcla = v.try_get_mclass(self, "Collection")
if colcla != null and v.is_subtype(mtype, colcla.get_mtype([objcla.mclass_type.as_nullable])) then
var coltype = mtype.supertype_to(v.mmodule, v.anchor, colcla)
- assert coltype isa MGenericType
self.coltype = coltype
var variables = self.variables
if variables.length != 1 then
var mapcla = v.try_get_mclass(self, "Map")
if mapcla != null and v.is_subtype(mtype, mapcla.get_mtype([objcla.mclass_type.as_nullable, objcla.mclass_type.as_nullable])) then
var coltype = mtype.supertype_to(v.mmodule, v.anchor, mapcla)
- assert coltype isa MGenericType
self.coltype = coltype
var variables = self.variables
if variables.length != 2 then