static void knh_showWelcome(CTX ctx, kOutputStream *w) { const knh_sysinfo_t *sysinfo = knh_getsysinfo(); knh_printf(ctx, w, "%s%s %s(%s) %s (rev:%d, %s %s)%s\n", TERM_BBOLD(ctx), sysinfo->konoha_type, sysinfo->konoha_version, sysinfo->konoha_codename, K_DISTTYPE, ((kintptr_t)K_REVISION), __DATE__, __TIME__, TERM_EBOLD(ctx)); //knh_printf(ctx, w, "[%s] on %s (%d, %s)\n", CC_TYPE, sysinfo->kern_ostype, sysinfo->konoha_systembits, knh_getSystemEncoding()); knh_printf(ctx, w, "options: %sused_memory:%d kb\n", sysinfo->konoha_options, (kintptr_t)(ctx->stat->usedMemorySize / 1024)); }
void THROW_ParamTypeError(CTX ctx, ksfp_t *sfp, size_t n, kmethodn_t mn, kclass_t reqt, kclass_t cid) { CWB_t cwbbuf, *cwb = CWB_open(ctx, &cwbbuf); char msg[256], mname[256]; knh_printf(ctx, cwb->w, "Script!!: Type Error: %T.%M(#%d)", cid, mn, (int)n); knh_snprintf(msg, sizeof(msg), "%s", CWB_totext(ctx, cwb)); CWB_close(ctx, cwb); knh_printf(ctx, cwb->w, "%C.%M", cid, mn); knh_snprintf(mname, sizeof(mname), "%s", CWB_totext(ctx, cwb)); CWB_close(ctx, cwb); KNH_NTHROW2(ctx, sfp, msg, "konoha:type", K_FAILED, KNH_LDATA(LOG_msg(msg), LOG_s("method", mname), LOG_i("argument", n), LOG_t("requested_type", reqt), LOG_t("given_type", cid))); }
void THROW_NoSuchMethod(CTX ctx, ksfp_t *sfp, kclass_t cid, kmethodn_t mn) { CWB_t cwbbuf, *cwb = CWB_open(ctx, &cwbbuf); char msg[256], mname[256]; knh_printf(ctx, cwb->w, "Script!!: No Such Method: %T.%M", cid, mn); knh_snprintf(msg, sizeof(msg), "%s", CWB_totext(ctx, cwb)); CWB_close(ctx, cwb); knh_printf(ctx, cwb->w, "%C.%M", cid, mn); knh_snprintf(mname, sizeof(mname), "%s", CWB_totext(ctx, cwb)); CWB_close(ctx, cwb); KNH_NTHROW2(ctx, sfp, msg, "konoha:type", K_FAILED, KNH_LDATA(LOG_msg(msg), LOG_s("method", mname))); }
void knh_vperror(Ctx *ctx, knh_uri_t uri, int line, int pe, const char *fmt, va_list ap) { DBG_ASSERT(pe <= LOG_DEBUG); if(knh_Gamma_isQuiet(ctx->gma)) { return; } // if(pe < KERR_DWARN) { // DP(ctx->gma)->statError += 1; // } // else if(pe < KERR_TINFO) { // DP(ctx->gma)->statBadManner += 1; // } if(knh_Context_isInteractive(ctx)) { goto L_PRINT; } if(pe > KERR_EWARN && !knh_Context_isCompiling(ctx)) { return; } L_PRINT:; if(line > 0) { knh_OutputStream_t *w = KNH_STDERR; knh_printf(ctx, w, " - [%s:%d]:%s ", FILENAME__(uri), (knh_intptr_t)line, KERR_tochar(pe)); knh_vprintf(ctx, w, fmt, ap); knh_write_EOL(ctx, w); } else { knh_vsyslog(ctx, pe, fmt, ap); } }
void knh_makeEvidence(Ctx *ctx, const char *ns, const char *event, int p, const char *fmt, ...) { if(p > LOG_WARNING && !knh_isSystemVerbose()) return; va_list ap; va_start(ap , fmt); if(fmt[0] == '*') { char newfmt[512]; knh_snprintf(newfmt, sizeof(newfmt), K_EVENT_FORMAT "%s", ns, event, fmt+1); ctx->share->ebiSPI->vsyslog(p, newfmt, ap); } else { DBG_ASSERT(ctx->bufa != NULL); knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf); knh_printf(ctx, cwb->w, K_EVENT_FORMAT, ns, event); if(ctx->gma != NULL && SP(ctx->gma)->line != 0) { knh_write_uline(ctx, cwb->w, SP(ctx->gma)->uri, SP(ctx->gma)->line); } knh_vprintf(ctx, cwb->w, fmt, ap); ctx->share->ebiSPI->syslog(p, knh_cwb_tochar(ctx, cwb)); knh_cwb_clear(cwb, 0); } va_end(ap); if(p == LOG_EMERG || p == LOG_CRIT) { #if defined(K_USING_DEBUG) DBG_ABORT(); #endif knh_exit(ctx, 0); } }
static void knh_StmtMETA_dump(Ctx *ctx, Stmt *o, OutputStream *w, String *m) { if(!IS_DictMap(DP(o)->metaDictMap)) return ; int i = 0, size = (DP(o)->metaDictMap)->size; for(i = 0; i < size; i++) { String *k = (String*)knh_DictMap_keyAt(DP(o)->metaDictMap, i); String *v = (String*)knh_DictMap_valueAt(DP(o)->metaDictMap, i); if(k == v) { knh_printf(ctx, w, "@%s ", knh_String_tochar(k)); } else { knh_printf(ctx, w, "@%s(%O) ", knh_String_tochar(k), v); } } if(size > 0) { knh_println(ctx, w, STEXT("")); } }
static void dump_int(CTX, kOutputStream *w, const char *name, intptr_t data, int isALL) { if(data == -1) { if(!isALL) return; if(_ctx == NULL) { fprintf(stderr, "%s: UNDEFINED\n", name); } else { knh_printf(_ctx, w, "%s: UNDEFINED\n", name); } } else { if(_ctx == NULL) { fprintf(stderr, "%s: %ld\n", name, (long)data); } else { knh_printf(_ctx, w, "%s: %d\n", name, data); } } }
static void dump_string(CTX, kOutputStream *w, const char *name, const char *data, int isALL) { if(data == NULL) { if(!isALL) return; data = ""; } if(_ctx == NULL) { fprintf(stderr, "%s: %s\n", name, data); } else { knh_printf(_ctx, w, "%s: %s\n", name, data); } }
void knh_Stmt__dump(Ctx *ctx, Stmt *o, OutputStream *w, String *m) { L_RESTART: ; if(IS_DictMap(DP(o)->metaDictMap)) { knh_StmtMETA_dump(ctx, o, w, m); } knh_printf(ctx, w, "%s\t", knh_stmt_tochar(SP(o)->stt)); knh_Stmt__s(ctx, o, w, m); if(IS_NOTNULL(DP(o)->next)) { knh_putc(ctx, w, '\n'); o = DP(o)->next; goto L_RESTART; } }
static void ClassCONST_man(CTX ctx, knh_OutputStream_t *w, const knh_ClassTBL_t *ct, knh_NameSpace_t *ns) { knh_DictMap_t *tcmap = ct->constDictCaseMapNULL; size_t i, size = knh_DictMap_size(tcmap); int hasCaption = 0; for(i = 0; i < size; i++) { if(!hasCaption) { knh_write_ctext(ctx, w, _("CONST")); hasCaption = 1; } knh_printf(ctx, w, "\t%s.%s: %O\n", S_tochar(ct->sname), S_tochar(knh_DictMap_keyAt(tcmap, i)), knh_DictMap_valueAt(tcmap, i)); } if(hasCaption == 1) { knh_write_EOL(ctx, w); } }
void knh_vperror(Ctx *ctx, knh_uri_t uri, int line, int pe, char *fmt, va_list ap) { KNH_ASSERT(pe <= KERR_INFO); if(knh_Context_isInteractive(ctx)) { goto L_PRINT; } if(pe > KERR_EWARN && !knh_Context_isCompiling(ctx)) { return; } L_PRINT:; { OutputStream *w = KNH_STDERR; knh_printf(ctx, w, " - [%s:%d]:%s ", knh_safefile(URIDN(uri)), (knh_intptr_t)line, KERR_MSG[pe]); knh_vprintf(ctx, w, fmt, ap); knh_write_EOL(ctx, w); ((Context*)ctx)->hasError = 1; } }
static void knh_vsyslog(Ctx *ctx, int p, const char *fmt, va_list ap) { if(p > LOG_WARNING && !knh_isSystemVerbose()) return; #ifdef KONOHA_ON_LKM //TODO_IDE(); vprintk(fmt, ap); #else if(ctx == NULL) { fprintf(stderr, "konoha[%s] ", LOG__(p)); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); } else { knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf); knh_printf(ctx, cwb->w, "konoha[%s] ", LOG__(p)); knh_vprintf(ctx, cwb->w, fmt, ap); fprintf(stderr, "%s\n", knh_cwb_tochar(ctx, cwb)); knh_cwb_clear(cwb, 0); } #endif }