Foam compPhaseLoadFoam(EmitInfo finfo) { SymeList symes = 0; Foam foam; FileName fn = emitSrcFile(finfo); int ftype = ftypeNo(fnameType(fn)); phStart(PH_Load); foam = 0; if (ftype == FTYPENO_INTERMED) { Lib lib = libRead(fn); emitSetFileIdName(libGetFileId(lib)); if (emitIsOutputNeeded(finfo, FTYPENO_SYMEEXPR)) { symes = libGetSymes(lib); stabPutMeanings(stabFile(), symes); } foam = libGetFoam(lib); /*!! libClose(lib); */ } if (ftype == FTYPENO_FOAMEXPR) { FILE *fin; fin = fileRdOpen(fn); foam = foamRdSExpr(fin, &fn, NULL); fclose(fin); } phEnd((PhPrFun) foamPrint, (PhPrFun) 0, (Pointer) foam); return foam; }
void testFile(void) { FileName testFile; FILE *fout; printf("fileSetHandler:\n"); fileSetHandler(fileSetHandler((FileErrorFun) 0)); printf("pathInit:\n"); pathInit(); printf("fileRdFind: yabba -- "); testFile = fileRdFind(binSearchPath(), "yabba", ""); if (testFile) printf("dir \"%s\", name \"%s\", type \"%s\"\n", fnameDir(testFile), fnameName(testFile), fnameType(testFile)); else printf("Not found\n"); printf("fileRdFind: cat -- "); testFile = fileRdFind(binSearchPath(), "cat", osExecFileType); if (testFile) { printf("dir \"%s\", name \"%s\", type \"%s\"\n", fnameDir(testFile), fnameName(testFile), fnameType(testFile)); printf("fileRdOpen: "); fout = fileRdOpen(testFile); printf("Opened \"%s\"\n",fnameName(testFile)); fclose(fout); } else printf("Not found\n"); printf("DONE.\n"); fnameFree(testFile); /* fileRemove(testFile); */ }
AbSyn compFileFront(EmitInfo finfo, Stab stab, FILE *fin, int *plno) { FileName fn = emitSrcFile(finfo); AbSyn ab; FTypeNo ft = ftypeNo(fnameType(fn)); if (ft == FTYPENO_OLDABSYN) { comsgWarning(NULL, ALDOR_W_OldTypeAbsyn, cmdName); } if ((ft == FTYPENO_ABSYN) || (ft == FTYPENO_OLDABSYN)) { ab = compPhaseLoadAbSyn(finfo); } else { SrcLineList sll; TokenList tl; sll = compPhaseInclude(finfo, fin, plno); fintGetInitCompTime(); if (!compIsMoreAfterInclude(finfo)) { inclFree(sll); return 0; } tl = compPhaseScan (finfo, sll); tl = compPhaseSysCmd (finfo, tl); tl = compPhaseLinear (finfo, tl); ab = compPhaseParse (finfo, tl); inclFree(sll); listFreeDeeply(Token)(tl,tokFree); if (comsgErrorCount()) return ab; } ab = compPhaseAbNorm (finfo, ab, false); ab = compPhaseMacEx (finfo, ab); if (comsgErrorCount()) return ab; ab = compPhaseAbNorm (finfo, ab, true); ab = compPhaseAbCheck(finfo, ab); /* creates the .ax file */ if (!compIsMoreAfterSyntax(finfo)) return ab; compPhaseScoBind(finfo, stab, ab); if (comsgErrorCount()) { if (fintMode == FINT_LOOP) scoSetUndoState(); return ab; } compPhaseTInfer (finfo, stab, ab); if (comsgErrorCount()) { if (fintMode == FINT_LOOP) scoSetUndoState(); return ab; } return ab; }
/* * Compile files controlled by the argument vector and * return the total error count. */ int compFilesLoop(int argc, char **argv) { int i, iargc, totErrors, nErrors; FileName fn; Bool isSolo; compInit(); iargc = cmdArguments(1, argc, argv); argc -= iargc; argv += iargc; if (argc == 0) { if (comsgOkBreakLoop()) bloopMsgFPrintf(osStdout, ALDOR_W_NoFiles, cmdName); comsgWarning(NULL, ALDOR_W_NoFiles, cmdName); } emitDoneOptions(argc, argv); ccGetReady(); isSolo = (cmdFileCount == 1); compFinfov = (EmitInfo *) stoAlloc((unsigned) OB_Other, (cmdFileCount+1) * sizeof(EmitInfo)); for (i = 0; i <= cmdFileCount; i += 1) compFinfov[i] = 0; totErrors = 0; for (i = 0; i < cmdFileCount; i++) { fn = fnameParse(argv[i]); compFinfov[i] = emitInfoNew(fn); nErrors = 0; if (!fileIsReadable(fn)) { if (comsgOkBreakLoop()) bloopMsgFPrintf(osStdout, ALDOR_F_CantOpen, argv[i]); comsgFatal(NULL, ALDOR_F_CantOpen, argv[i]); } switch (ftypeNo(fnameType(fn))) { #if 0 case FTYPENO_C: nErrors = compCFile(compFinfov[i]); break; #endif case FTYPENO_OBJECT: case FTYPENO_AR_OBJ: case FTYPENO_AR_INT: break; case FTYPENO_FOAMEXPR: case FTYPENO_INTERMED: if (!isSolo) fprintf(osStdout, "\n%s:\n", argv[i]); nErrors = compSavedFile(compFinfov[i]); break; default: if (!ftypeEqual(fnameType(fn), "")) { if (comsgOkBreakLoop()) bloopMsgFPrintf(osStdout, ALDOR_F_BadFType, argv[i], fnameType(fn), FTYPE_SRC); comsgFatal(NULL, ALDOR_F_BadFType, argv[i], fnameType(fn), FTYPE_SRC); } /* Fall through. */ case FTYPENO_NONE: case FTYPENO_SRC: case FTYPENO_INCLUDED: case FTYPENO_ABSYN: case FTYPENO_OLDABSYN: if (!isSolo) fprintf(osStdout, "\n%s:\n", argv[i]); nErrors = compSourceFile(compFinfov[i]); break; } totErrors += nErrors; fnameFree(fn); } if (cmdFileCount > 0 && totErrors == 0) { compFinfov[cmdFileCount] = emitInfoNewAXLmain(); compAXLmainFile(compFinfov[cmdFileCount]); emitLink(cmdFileCount + 1, compFinfov); argc -= cmdFileCount; argv += cmdFileCount; emitInterp(argc, argv); emitRun (argc, argv); } if (totErrors > 0) emitAllDone(); for (i = 0; i < cmdFileCount + 1; i++) emitInfoFree(compFinfov[i]); stoFree((Pointer) compFinfov); compFinfov = 0; if (!isSolo) phGrandTotals(cmdVerboseFlag); compFini(); return totErrors; }
local Bool arItemIsIntermed(String item) { return ftypeEqual(fnameType(fnameParseStatic(item)), FTYPE_INTERMED); }
Bool ftypeHas(FileName fn, FTypeNo fno) { return ftypeEqual(fnameType(fn), ftypeString(fno)); }