/* * Usage: showexports libName type-expression * Example: showexports libaldor.al 'List(Integer)' */ int main(int argc, char *argv[]) { osInit(); sxiInit(); keyInit(); ssymInit(); dbInit(); stabInitGlobal(); tfInit(); foamInit(); optInit(); tinferInit(); pathInit(); sposInit(); ablogInit(); comsgInit(); macexInitFile(); comsgInit(); scobindInitFile(); stabInitFile(); fileAddLibraryDirectory("."); String archive = argv[1]; String expression = argv[2]; scmdHandleLibrary("LIB", archive); AbSyn ab = shexpParse(expression); Stab stab = stabFile(); Syme syme = stabGetArchive(symInternConst("LIB")); AbSyn arAbSyn = abNewId(sposNone, symInternConst("LIB")); stabImportTForm(stab, tiGetTForm(stab, arAbSyn)); abPutUse(ab, AB_Use_Value); scopeBind(stab, ab); typeInfer(stab, ab); TForm tf = tiGetTForm(stab, ab); SymeList list = tfStabGetDomImports(stab, tf); for (; list != listNil(Syme); list = cdr(list)) { Syme syme = car(list); aprintf("%s %d %d %s\n", symeString(syme), symeDefnNum(syme), symeConstNum(syme), tfPretty(symeType(syme))); } scobindFiniFile(); stabFiniFile(); comsgFini(); macexFiniFile(); }
void compGLoopEval(FILE * fin, FILE * fout, EmitInfo finfo) { Stab stab = stabFile(); AbSyn ab; Foam foam; static int lineno = 0; comsgInit(); while (!osFEof(fin)) { Bool ok; intStepNo += 1; comsgFini(); comsgInit(); car(stab)->isChecked = false; if (SetJmp(compFintJmpBuf)) if (osFEof(fin)) break; comsgPromptPrint(fin, fout, fintHistory ? "%%%d := " : "%%%d >> ", intStepNo); osSetBreakHandler(compFintBreakHandler0); ab = compFileFront(finfo, stab, fin, &lineno); breakSetRoot(ab); if (!compIsMoreAfterFront(finfo) || abIsEmptySequence(ab)) continue; ab = (AbSyn) fintWrap(ab, intStepNo); foam = compFileMiddle(finfo, stab, ab); if (!foam) continue; ok = fint(foam); if (!ok) fprintf(fout, "Unhandled Exception!\n"); foamFree(foam); if (fintVerbose && ok) fintPrintType(fout, ab); fintDisplayTimings(); } comsgFini(); }
void initFile() { macexInitFile(); comsgInit(); scobindInitFile(); stabInitFile(); }
void compFileInit(EmitInfo finfo) { phStartAll(cmdVerboseFlag); macexInitFile(); scobindInitFile(); stabInitFile(); ablogInit(); sposInit(); comsgInit(); arFileInit(emitFileName(finfo, FTYPENO_INTERMED), emitGetFileIdName(finfo)); }
void init() { osInit(); sxiInit(); keyInit(); ssymInit(); dbInit(); stabInitGlobal(); tfInit(); foamInit(); optInit(); tinferInit(); sposInit(); ablogInit(); comsgInit(); }
int compInteractiveLoop(int argc, char **argv, FILE *fin, FILE *fout) { int iargc, totErrors, lineno; FileName fn; EmitInfo finfo; AbSyn ab; Stab stab; Foam foam; Bool readingInitFile = true, tmpHistory; Bool endOfInput = false; FILE *fin0 = fin; compInit(); iargc = cmdArguments(1, argc, argv); argc -= iargc; argv += iargc; emitDoneOptions(argc, argv); if (osFileIsThere(cmdInitFile)) { FileName fname; fname = fnameParse(cmdInitFile); fin = fileMustOpen(fname, osIoRdMode); fnameFree(fname); intStepNo = 0; tmpHistory = fintHistory; fintHistory = false; fprintf(fout, "Reading %s...\n", cmdInitFile); } else { intStepNo = 1; readingInitFile = false; tmpHistory = fintHistory; } fn = fnameStdin(); finfo = emitInfoNew(fn); lineno = 0; compFileInit(finfo); stab = stabFile(); comsgFini(); fintInit(); for (; !endOfInput; intStepNo++) { comsgInit(); breakSetRoot(NULL); car(stab)->isChecked = false; if (SetJmp(compFintJmpBuf)) { if (feof(fin)) break; } comsgPromptPrint(fin, fout, fintHistory ? "%%%d := " : "%%%d >> ", intStepNo); osSetBreakHandler(compFintBreakHandler0); ab = compFileFront(finfo, stab, fin, &lineno); breakSetRoot(ab); if (compIsMoreAfterFront(finfo) && !abIsEmptySequence(ab)) { ab = (AbSyn) fintWrap(ab, intStepNo); foam = compFileMiddle(finfo, stab, ab); if (foam) { Bool ok = fint(foam); if (ok && fintVerbose) fintPrintType(fout, ab); foamFree(foam); fintDisplayTimings(); } } comsgFini(); /* abFree(ab); !! ab is seeping into types. */ if (feof(fin)) { if (readingInitFile) { fclose(fin); fin = fin0; lineno = 0; readingInitFile = false; fintHistory = tmpHistory; intStepNo = 0; comsgFini(); } else endOfInput = true; } } totErrors = comsgErrorCount(); fintFini(); compFileFini(finfo); emitAllDone(); emitInfoFree(finfo); fnameFree(fn); compFini(); return totErrors; }
/* * Usage: showexports libName type-expression * Example: showexports libaldor.al 'List(Integer)' */ int main(int argc, char *argv[]) { osInit(); sxiInit(); keyInit(); ssymInit(); dbInit(); stabInitGlobal(); tfInit(); foamInit(); optInit(); tinferInit(); pathInit(); sposInit(); ablogInit(); comsgInit(); macexInitFile(); comsgInit(); scobindInitFile(); stabInitFile(); fileAddLibraryDirectory("."); String archive = argv[1]; String expression = argv[2]; scmdHandleLibrary("LIB", archive); AbSyn ab = shexpParse(expression); Stab stab = stabFile(); Syme syme = stabGetArchive(symInternConst("LIB")); AbSyn arAbSyn = abNewId(sposNone, symInternConst("LIB")); AbSyn boolean = abNewId(sposNone, symInternConst("Boolean")); stabImportTForm(stab, tiGetTForm(stab, arAbSyn)); stabImportTForm(stab, tiGetTForm(stab, boolean)); abPutUse(ab, AB_Use_Value); scopeBind(stab, ab); typeInfer(stab, ab); TForm tf = tiGetTForm(stab, ab); aprintf("Type: %s Cat: %d\n", tfPretty(tf), tfSatCat(tf)); if (tfSatDom(tf)) { SymeList list = tfGetCatExports(tf); aprintf("Category\n"); for (; list != listNil(Syme); list = cdr(list)) { Syme syme = car(list); aprintf("%5s %3d %s %pAbSynList\n", symeString(syme), symeHasDefault(syme), tfPretty(symeType(syme)), symeCondition(syme)); } } else { aprintf(">>> Exports\n"); SymeList list = tfStabGetDomImports(stab, tf); for (; list != listNil(Syme); list = cdr(list)) { Syme syme = car(list); aprintf("%s %d %d %s\n", symeString(syme), symeDefnNum(syme), symeConstNum(syme), tfPretty(symeType(syme))); } TQualList tqList; aprintf(">>> Cascades\n"); tqList = tfGetDomCascades(tf); for (; tqList != listNil(TQual); tqList = cdr(tqList)) { TQual tq = car(tqList); aprintf("--> %s\n", tfPretty(tqBase(tq))); } } scobindFiniFile(); stabFiniFile(); comsgFini(); macexFiniFile(); }