static void KBuffer_WriteValue(KonohaContext *kctx, KBuffer *wb, KClass *c, KonohaStack *sfp) { if(KClass_Is(UnboxType, c)) { c->p(kctx, sfp, 0, wb); } else { KLIB kObject_WriteToBuffer(kctx, sfp[0].asObject, false/*delim*/, wb, NULL, 0); } }
static void DumpOpArgument(KonohaContext *kctx, KBuffer *wb, KVirtualCodeType type, KVirtualCode *c, size_t i, KVirtualCode *vcode_start) { switch(type) { case VMT_VOID: break; case VMT_ADDR: KLIB KBuffer_printf(kctx, wb, " L%d", (int)((KVirtualCode *)c->p[i] - vcode_start)); break; case VMT_UL: { kfileline_t uline = (kfileline_t)c->data[i]; KLIB KBuffer_printf(kctx, wb, " (%s:%d)", PLATAPI shortFilePath(KFileLine_textFileName(uline)), (khalfword_t)uline); break; } case VMT_R: { KLIB KBuffer_printf(kctx, wb, " sfp[%d,r=%d]", (int)c->data[i]/2, (int)c->data[i]); break; } case VMT_FX: { khalfword_t index = (khalfword_t)c->data[i]; khalfword_t xindex = (khalfword_t)(c->data[i] >> (sizeof(khalfword_t)*8)); KLIB KBuffer_printf(kctx, wb, " sfp[%d,r=%d][%d]", (int)index/2, (int)index, (int)xindex); break; } case VMT_U: KLIB KBuffer_printf(kctx, wb, " i%ld", (long)c->data[i]); break; case VMT_C: case VMT_TY: KLIB KBuffer_printf(kctx, wb, "(%s)", KClass_text(c->ct[i])); break; case VMT_F: KLIB KBuffer_printf(kctx, wb, " function(%p)", c->p[i]); break; case VMT_Object: { kObject *o = c->o[i]; if(IS_Method(o)) { kMethod *mtd = (kMethod *)o; KLIB KBuffer_printf(kctx, wb, " %s.%s%s", KType_text(mtd->typeId), KMethodName_Fmt2(mtd->mn)); } else { KLIB KBuffer_printf(kctx, wb, " (%s)", KClass_text(kObject_class(o))); KLIB kObject_WriteToBuffer(kctx, o, 0, wb, NULL, 0); } break; } case VMT_HCACHE: break; }/*switch*/ }
static void kResultSet_format(KonohaContext *kctx, KonohaValue *v, int pos, KBuffer *wb) { kResultSet *rs = (kResultSet *) v[0].asObject; KLIB KBuffer_printf(kctx, wb, "{"); size_t i; for(i = 0; i < (rs)->column_size; i++) { if(i > 0) { KLIB KBuffer_printf(kctx, wb, ","); } KLIB KBuffer_printf(kctx, wb, "(%d): ", i); ktypeattr_t type = rs->column[i].type; krbp_t *val = &rs->column[i].val; if(KType_Is(UnboxType, type)) { KonohaValue sp[1]; KStackSetUnboxValue(sp[0].unboxValue, val[0].unboxValue); KClass_(type)->format(kctx, sp, 0, wb); } else { KLIB kObject_WriteToBuffer(kctx, val[0].asObject, false/*delim*/, wb, NULL, 0); } } KLIB KBuffer_printf(kctx, wb, "}"); }