static void knh_write_Method(CTX ctx, knh_OutputStream_t *w, const knh_ClassTBL_t *ct, knh_Method_t *o) { knh_write_TAB(ctx, w); if(Method_isAbstract(o)) { knh_write_ascii(ctx, w, "@Abstract "); } knh_write_type(ctx, w, knh_type_tocid(ctx, knh_ParamArray_rtype(DP(o)->mp), ct->cid)); knh_putc(ctx, w, ' '); if(Method_isStatic(o)) { knh_write_ascii(ctx, w, S_tochar(ct->sname)); knh_putc(ctx, w, '.'); } knh_write_mn(ctx, w, SP(o)->mn); knh_putc(ctx, w, '('); size_t i; for(i = 0; i < knh_Method_psize(o); i++) { knh_param_t *p = knh_ParamArray_get(DP(o)->mp, i); if(i > 0) { knh_write_delim(ctx, w); } knh_write_type(ctx, w, knh_type_tocid(ctx, p->type, ct->cid)); knh_putc(ctx, w, ' '); knh_write_ascii(ctx, w, FN__(p->fn)); } if(ParamArray_isVARGs(DP(o)->mp)) { knh_write_delim(ctx, w); knh_write_dots(ctx, w); } knh_putc(ctx, w, ')'); knh_write_EOL(ctx, w); }
static void CALL_asm(KonohaContext *kctx, kStmt *stmt, int a, kExpr *expr, int shift, int espidx) { kMethod *mtd = expr->cons->methodItems[0]; DBG_ASSERT(IS_Method(mtd)); int i, s = Method_isStatic(mtd) ? 2 : 1, thisidx = espidx + K_CALLDELTA; #ifdef _CLASSICVM if (CLASSICVM_CALL_asm(kctx, mtd, expr, shift, espidx)) { return; } #endif for(i = s; i < kArray_size(expr->cons); i++) { kExpr *exprN = kExpr_at(expr, i); DBG_ASSERT(IS_Expr(exprN)); EXPR_asm(kctx, stmt, thisidx + i - 1, exprN, shift, thisidx + i - 1); } int argc = kArray_size(expr->cons) - 2; // if (mtd->mn == MN_new && mtd->invokeMethodFunc == MethodFunc_abstract) { // /* do nothing */ // } else // if(Method_isFinal(mtd) || !Method_isVirtual(mtd)) { // if(mtd->invokeMethodFunc != MethodFunc_runVirtualMachine) { // ASM(SCALL, ctxcode->uline, SFP_(thisidx), ESP_(espidx, argc), mtd, KLIB Knull(kctx, CT_(expr->ty))); // } // else { // ASM(VCALL, ctxcode->uline, SFP_(thisidx), ESP_(espidx, argc), mtd, KLIB Knull(kctx, CT_(expr->ty))); // } // } // else { if(Method_isFinal(mtd) || !Method_isVirtual(mtd)) { ASM(NSET, NC_(thisidx-1), (intptr_t)mtd, CT_Method); } else { ASM(LOOKUP, SFP_(thisidx), Stmt_nameSpace(stmt), mtd); } ASM(CALL, ctxcode->uline, SFP_(thisidx), ESP_(espidx, argc), KLIB Knull(kctx, CT_(expr->ty))); }