nitc :: MClass :: compute_ftype
If not defined in the intro of this class will look in super-classes
FIXME this only supports type definition at intro, extend to superclasses by redef
# Type in C of the extern class
# If not defined in the intro of this class will look in super-classes
# FIXME this only supports type definition at intro, extend to superclasses by redef
private fun compute_ftype(v: ExternClassesTypingPhaseModel): nullable ForeignType
do
if ftype_computed then return ftype_cache
if kind != extern_kind then return null
# base case
if name == "Pointer" then
ftype_cache = new ForeignType
ftype_computed = true
return ftype_cache
end
var ftype = intro.ftype
if ftype == null then
var ftype_b: nullable ForeignType = null # FIXME hack to circumvent bug where ftype is typed null
# look in super classes
for s in in_hierarchy(intro_mmodule).direct_greaters do
var super_ftype = s.compute_ftype(v)
if super_ftype != null then
if ftype_b == null then
ftype_b = super_ftype
continue
else
# detect conflict
if super_ftype != ftype_b then
v.toolcontext.error(null, "FFI Error: extern type conflict in `{self}`.")
return null
end
end
end
end
ftype = ftype_b
end
ftype_cache = ftype
ftype_computed = true
return ftype
end
src/ffi/extern_classes.nit:93,2--135,4