Пример #1
0
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();                
}
Пример #2
0
void
compExitHandler(int status)
{
	exitSetHandler((ExitFun) 0);
	if (status == EXIT_FAILURE)
		emitCleanup(cmdFileCount + 1, compFinfov);
	comsgFini();
	if (cmdTrapFlag) abort();
}
Пример #3
0
/*
 * 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();

}
Пример #4
0
void
finiFile()
{
	scobindFiniFile();
	stabFiniFile();
	comsgFini();
	macexFiniFile();

	cmdDebugReset();
}
Пример #5
0
void
compGLoopInit(int argc, char **argv, FILE *fout, FileName *pfn,
              EmitInfo *pfinfo)
{
	int		iargc;
	Bool		tmpHistory;
	FILE		* fin;
        FileName        fname;

	compInit();

	iargc     = cmdArguments(1, argc, argv);
	argc	 -= iargc;
	argv	 += iargc;
	emitDoneOptions(argc, argv);

	*pfn  = fnameStdin();
	*pfinfo  = emitInfoNew(*pfn);

	compFileInit(*pfinfo);
	comsgFini();
	fintInit();

	/* Helpful start-up banner ... */
	fprintf(osStdout,"%s\n",comsgString(ALDOR_M_GloopBanner));
	if (comsgOkRelease()) {
		fprintf(osStdout, "%s: %s(%s) version %d.%d.%d",
			"Release",
			verName, "C", /* C-language version */
			verMajorVersion,
			verMinorVersion,
			verMinorFreeze);
		if (*verPatchLevel)
			fprintf(osStdout, "(%s)", verPatchLevel);
		fprintf(osStdout, " for %s %s\n", CONFIG, DEBUG_CONFIG);
	}
	(void)fputs("Type \"#int help\" for more details.\n",osStdout);

	if (osFileIsThere(cmdInitFile)) {
		fname = fnameParse(cmdInitFile);
		fin = fileMustOpen(fname, osIoRdMode);
		fnameFree(fname);
		intStepNo = -1;
		tmpHistory = fintHistory;
		fintHistory = false;
		fprintf(fout, "Reading %s...\n", cmdInitFile);
		compGLoopEval(fin, fout, *pfinfo);
                fclose(fin);
	}
	else {
		intStepNo = 0;
		tmpHistory = fintHistory;
	}
	fintHistory = tmpHistory;
}
Пример #6
0
void
compFileFini(EmitInfo finfo)
{
	comsgFini();
	sposFini();
	if (compDoGcFile) stoGc();
	phEndAll();
	ablogFini();
	scobindFiniFile();
	stabFiniFile();
	macexFiniFile();
}
Пример #7
0
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;
}
Пример #8
0
/*
 * 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();

}