Exemplo n.º 1
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();

}
Exemplo n.º 2
0
int
cmdArguments(int argi0, int argc, String *argv)
{
	int		opt, i, j;
	String		arg;
	StringList	sl;
 
	/*
	 * Initialize default values.
	 */
	cmdFileCount = argc - 1;
	cmdIncDirs   = cmdLibDirs = cmdLibKeys = 0;
	_dont_assert = true;	/* Disable assertions by default. */
 
	/*
	 * Handle the options.
	 */
	for (i = argi0, j = 0; ; ) {
		opt = cmdGetOption(argc, argv, &i, &j, &arg);
		if (!opt) break;
		if (cmdIsArgOption(opt) && !arg)
			cmdUseError(ALDOR_F_CmdBadOption, argv[i-1]);
		cmdHandleOption(opt, arg);
	}
 
	/*
	 * After some sequence of -O and -Q do we still want cc -O ?
	 */
	ccSetOptimize(optIsCcFNonStdWanted(),optIsCcOptimizeWanted());
 
	/*
	 * Push directories etc in correct order.
	 */
	for (sl = cmdIncDirs; sl; sl = cdr(sl))
		fileAddIncludeDirectory(car(sl));
	for (sl = cmdLibDirs; sl; sl = cdr(sl))
		fileAddLibraryDirectory(car(sl));
	for (sl = cmdLibKeys; sl; sl = cdr(sl)) {
		String	id, key, s;
		int	rc;
		s = scmdScanLibraryOption(car(sl), &id, &key);
		rc = s ? scmdHandleLibrary(id, key) : -1;
		if (rc < 0) cmdUseError(ALDOR_F_CmdBadOption, "-l");
	}
	listFree(String)(cmdIncDirs);
	listFree(String)(cmdLibDirs);
	listFree(String)(cmdLibKeys);
 
	/*
	 * Determine number of arguments consumed.
	 */
	if (i + cmdFileCount > argc) cmdFileCount = argc - i;

	return i;
}
Exemplo n.º 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"));
	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();

}