Remove PrototypeChainAttributeContains and ObjectIsKindOf
These two instructions can and should be implemented in Inko itself. Since GetPrototype
returns Nil
when no prototype is present, a new instruction is required: ObjectHasPrototype
, which returns True
/ False
based on the presence of a prototype. kind_of?
and instance_of?
can then be merged into instance_of?
, which will work with both objects and traits. This then means we can implement it (roughly) as follows:
def instance_of?(compare, compare_with) -> Boolean {
prototype?(compare).if_false {
return False
}
let proto = prototype(compare)
proto == compare_with
.if_true {
return True
}
let implemented_traits = _INKOC.get_attribute(compare, '@_implemented_traits')
_INKOC.get_attribute(implemented_traits, compare_with).if_true {
return True
}
instance_of?(proto, compare_with)
}
Edited by Yorick Peterse