Ejemplo n.º 1
0
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;

}
Ejemplo n.º 2
0
static void DumpVisitor_init(KonohaContext *kctx, struct IRBuilder *builder, kMethod *mtd)
{
	unsigned i;
	KGrowingBuffer wb;
	KLIB Kwb_init(&(kctx->stack->cwb), &wb);
	kParam *pa = Method_param(mtd);
	KLIB Kwb_printf(kctx, &wb, "METHOD %s%s(", T_mn(mtd->mn));
	for (i = 0; i < pa->psize; i++) {
		if(i != 0) {
			KLIB Kwb_write(kctx, &wb, ", ", 2);
		}
		KLIB Kwb_printf(kctx, &wb, "%s %s", TY_t(pa->paramtypeItems[i].ty), SYM_t(pa->paramtypeItems[i].fn));
	}
	emit_string(KLIB Kwb_top(kctx, &wb, 1), "", ") {", 0);
	builder->local_fields = (void *) KMalloc_UNTRACE(sizeof(int));
	DUMPER(builder)->indent = 0;
}
Ejemplo n.º 3
0
static void kMethod_WriteToBuffer(KonohaContext *kctx, kMethod *mtd, KGrowingBuffer *wb)
{
    kParam *pa = Method_param(mtd);
    Method_WriteAttributeToBuffer(kctx, mtd, wb);
    KLIB Kwb_printf(kctx, wb, "%s %s.%s%s", TY_t(pa->rtype), TY_t(mtd->typeId), MethodName_t(mtd->mn));
    {
        size_t i;
        KLIB Kwb_Write(kctx, wb, "(", 1);
        for(i = 0; i < pa->psize; i++) {
            if(i > 0) {
                KLIB Kwb_Write(kctx, wb, ", ", 2);
            }
            if(FN_isCOERCION(pa->paramtypeItems[i].fn)) {
                KLIB Kwb_printf(kctx, wb, "@Coercion ");
            }
            KLIB Kwb_printf(kctx, wb, "%s %s", TY_t(pa->paramtypeItems[i].ty), SYM_t(pa->paramtypeItems[i].fn));
        }
        KLIB Kwb_Write(kctx, wb, ")", 1);
    }
}