/********************************* * * * peShowMacro * * * *********************************/ void peShowMacro(PE_MACRO *macro) { assert(macro); appendBuff(macro->ident); #if 0 Not implemented yet if (macro->type_sig) { appendBuff(": "); showPETypeSig(macro->type_sig); } #endif }
/********************************* * * * ge_ProcessQuery * * * *********************************/ static void ge_ProcessQuery(PE_QUERY query) { switch (query.tag) { case STRNG : st_PrintEntryInfo(st_NameToKey(query.info.query)); break; case ABOUT : clearBuff(); appendBuff(CHARITY_CONT_PROMPT "Charity Interpreter version "CHARITY_VERSION " was written by \n" CHARITY_CONT_PROMPT " Charles Tuckey, \n" CHARITY_CONT_PROMPT " Peter Vesely and \n" CHARITY_CONT_PROMPT " Barry Yee \n" CHARITY_CONT_PROMPT "from May to November, 1995.\n"); outputBuff(stdout); break; case SHOWCOMB : st_PrintEntryInfo(st_NameToKey(query.info.showcomb)); if (isFunction(query.info.showcomb)) { printMsg(MSG, "COMBINATOR DEFN for %s", query.info.showcomb); CodeTableShowComb(query.info.showcomb); } else if (isDatatype(query.info.showcomb)) { st_ShowDatatypeCombinators(st_NameToKey(query.info.showcomb)); } else ; /* do nothing */ break; case DUMPTABLE: st_DumpTable(); break; case REPLACE: if (gb_ReplaceFunctions) printMsg(MSG, "Functions replaced silently."); else printMsg(MSG, "User prompted to replace functions."); printMsg(MSG, "User prompted to replace datatypes."); break; case INCLUDEDIRS: printMsg(MSG,"Search path is %L.",(LIST *)g_strList_IncludeDirs); break; case SHOWMEM: MemDisplayState(); break; case QUERY: ge_ShowHelp(QUERY); break; default: printMsg(FATAL_MSG, "ge_ProcessQuery - Invalid tag (%d)", query.tag); } }
void *bc_malloc (size_t size) { void *data = malloc (size); if (!data) return NULL; if (!appendBuff (data)) { free (data); return NULL; } head.num++; return data; }
/************************** * * * printMsg * * * **************************/ void printMsg(MSG_TYPE msgType, char *msg, ...) { va_list ap; char *p, *strVal, convStr[MAX_MSG_LENGTH], text[MAX_MSG_LENGTH]; int i=0, intVal; CT_EXPR *coreTermLogicExpr; ST_TYPE_SIG *typeSigVal; ST_TYPE *st_type; LIST *list; CT_VAR_BASE *ctVarBase; clearBuff(); switch (msgType) { case MSG : case PROMPT_MSG : break; case FATAL_MSG : appendBuff("*** FATAL ERROR: "); break; case ERROR_MSG : appendBuff("*** ERROR: "); break; case DEBUG_MSG : appendBuff("-->DEBUG: "); break; case DELAYEDERROR_MSG : appendBuff("*** ERROR: "); delayedErrorCount++; break; case WARN_MSG : appendBuff("WARNING: "); break; default : printMsg(FATAL_MSG, "printMesg - Invalid value for MSG_TYPE"); } va_start(ap, msg); for (p=msg; *p; p++) { if (*p != '%') text[i++] = *p; else { text[i] = 0; i=0; appendBuff(text); switch (*++p) { case '%' : appendBuff("%"); break; case 'd' : intVal = va_arg(ap, int); sprintf(convStr,"%d",intVal); appendBuff(convStr); break; case 'r' : coreTermLogicExpr = va_arg(ap, CT_EXPR*); _showCT_expr(coreTermLogicExpr, 0); break; case 's' : strVal = va_arg(ap, char*); appendBuff(strVal); break; case 't' : typeSigVal = va_arg(ap, ST_TYPE_SIG*); st_ShowSig(typeSigVal); break; case 'L' : /* lists */ list = va_arg(ap, LIST*); showList(list, BFALSE); break; case 'T' : st_type = va_arg(ap, ST_TYPE *); st_ShowType(st_type); break; case 'S' : /* running out of choices */ typeSigVal = va_arg(ap, ST_TYPE_SIG*); st_ShowTypeSig(typeSigVal); break; case 'U' : /* this is to strip out context variables */ typeSigVal = va_arg(ap, ST_TYPE_SIG*); st_ShowTypeSigLessContext(typeSigVal); break; case 'V' : ctVarBase = va_arg(ap, CT_VAR_BASE*); ctShowVarBase(ctVarBase); break; default : printMsg(FATAL_MSG, "Invalid format specifier: %s", p); } /* hctiws */ } /* esle */ } /* rof */ text[i] = 0; appendBuff(text); switch (msgType) { case MSG : case WARN_MSG : case DEBUG_MSG : case DELAYEDERROR_MSG : appendBuff("\n"); outputBuff(stdout); break; case PROMPT_MSG : outputBuff(stdout); break; case FATAL_MSG : appendBuff("\n"); outputBuff(stdout); exit(-1); break; case ERROR_MSG : appendBuff("\n"); outputBuff(stdout); longjmp(topLevelEnv, 1); break; default : appendBuff("\n"); outputBuff(stdout); printMsg(FATAL_MSG, "printMesg - Invalid value for MSG_TYPE"); } } /* end printMsg */
/********************************* * * * showString * * * *********************************/ void showString(char *str) { appendBuff(str); }