static void ExprStmt_asm(KonohaContext *kctx, kStmt *stmt, int shift, int espidx) { kExpr *expr = (kExpr*)kStmt_getObjectNULL(kctx, stmt, KW_ExprPattern); if(IS_Expr(expr)) { EXPR_asm(kctx, stmt, espidx, expr, shift, espidx); } }
static void ReturnStmt_asm(KonohaContext *kctx, kStmt *stmt, int shift, int espidx) { kExpr *expr = (kExpr*)kStmt_getObjectNULL(kctx, stmt, KW_ExprPattern); if(expr != NULL && IS_Expr(expr) && expr->ty != TY_void) { EXPR_asm(kctx, stmt, K_RTNIDX, expr, shift, espidx); } ASM_JMP(kctx, ctxcode->lbEND); // RET }
static void DumpVisitor_visitReturnStmt(KonohaContext *kctx, IRBuilder *self, kStmt *stmt) { emit_string("Return", "", "", DUMPER(self)->indent); kExpr* expr = Stmt_getFirstExpr(kctx, stmt); if(expr != NULL && IS_Expr(expr)) { handleExpr(kctx, self, expr); } }
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))); }