// @SmartReturn Object Object.as(Object target) static KMETHOD Object_as(KonohaContext *kctx, KonohaStack *sfp) { KonohaClass *selfClass = O_ct(sfp[0].asObject), *targetClass = KGetReturnType(sfp); kObject *returnValue; if(selfClass == targetClass || selfClass->isSubType(kctx, selfClass, targetClass)) { returnValue = sfp[0].asObject; } else { returnValue = KLIB Knull(kctx, targetClass); } sfp[K_RTNIDX].unboxValue = O_unbox(returnValue); KReturn(returnValue); }
static kbool_t kMethod_CheckMethodCallStack(KonohaContext *kctx, KonohaStack *sfp, kMethod *mtd, int argc) { int i; kParam *param = Method_param(mtd); for(i = 1; i <= argc; i++) { KonohaClass *paramClass = O_ct(sfp[i].asObject); ktype_t ptype = param->paramtypeItems[i-1].ty; if(ptype != paramClass->typeId) { return false; } if(CT_isUnbox(paramClass)) { sfp[i].unboxValue = O_unbox(sfp[i].asObject); } } return true; }