Example #1
0
/*
 * Invent some absyn for the parameter list of a function.
 */
local AbSyn
ab0ImplicitExportArgs(TForm tf)
{
	/* How many parameters does this function have? */
	Length numargs = tfIsMulti(tf) ? tfMultiArgc(tf) : 1;


	/* Deal with single and multiple arguments separately */
	if (numargs > 1)
	{
		/* Multiple arguments: (Comma ...) */
		Length		i;
		AbSynList	lst = listNil(AbSyn);


		/* Create each argument */
		for (i = 0; i < numargs; i++)
		{
			AbSyn arg = ab1ImplicitExportArg(i);
			lst = listCons(AbSyn)(arg, lst);
		}


		/* Make sure that the list is in the right order */
		lst = listNReverse(AbSyn)(lst);


		/* Return the absyn for the parameter list */
		return abNewCommaL(sposNone, lst);
	}
	else
		return ab1ImplicitExportArg((Length)0);
}
Example #2
0
static StringList
uclConstructOptList(String name, StringList given)
{
	StringList res;
	String flag;
	String tmp;
	Bool sep;
	
	flag = cfgLookupString(name, uclOptions);

	tmp = strConcat(name, "-sep");
	sep = cfgLookupBoolean(tmp, uclOptions);
	strFree(tmp);
	
	res = listNil(String);
	while (given) {
		if (sep) {
			res = listCons(String)(flag, res);
			res = listCons(String)(car(given), res);  
		}
		else {
			tmp = strConcat(flag, car(given));
			res = listCons(String)(tmp, res);
		}
		given = cdr(given);
	}
	return listNReverse(String)(res);
}
Example #3
0
TPoss
tpossIntersect(TPoss S, TPoss T)
{
	TFormList LS, LT, l = 0;

	if (S == NULL || T == NULL)
		return NULL;

	/* If T is free of duplicates, then the result will also be. */
	for (LT = T->possl; LT; LT = cdr(LT)) {
		car(LT) = tfFollowOnly(car(LT));
		for (LS = S->possl; LS; LS = cdr(LS)) {
			car(LS) = tfFollowOnly(car(LS));
			if (tfSatisfies(car(LS), car(LT))) {
				l = listCons(TForm)(car(LT), l);
				break;
			}
			if (tfSatisfies(car(LT), car(LS))) {
				if (!listMember(TForm)(l, car(LS), tfEqual))
					l = listCons(TForm)(car(LS), l);
			}
		}
	}

	l = listNReverse(TForm)(l);
	return tpossFrTheList(l);
}
Example #4
0
File: fbox.c Project: dokterp/aldor
Foam
fboxMake(FoamBox fbox)
{
        Foam            newFoam;
        int             i=0;
        FoamList        l;
 
        if (fbox->l == 0) {
                if (fbox->initial)
                        return fbox->initial;
                else
                        return foamNewEmpty(fbox->tag, int0);
        }
 
        newFoam = foamNewEmpty(fbox->tag, fbox->argc + foamNaryStart(fbox->tag));
 
        if (fbox->initial)
                for(i=0; i<foamArgc(fbox->initial); i++)
                        foamArgv(newFoam)[i].code =
                                foamArgv(fbox->initial)[i].code;
        fbox->l = listNReverse(Foam)(fbox->l);
        for (l = fbox->l; l; l = cdr(l), i++)
                foamArgv(newFoam)[i].code = car(l);
 
        if (fbox->initial) foamFreeNode(fbox->initial);
        listFree(Foam)(fbox->l);
        stoFree(fbox);
        return newFoam;
}
Example #5
0
File: include.c Project: pdo/aldor
/* 
 * Return a processed source line list of the file contents.
 */
SrcLineList
includeFile(FileName fname)
{
	String	      fnameString;
	SrcLineList   r;

	inclSerialLineNo    = 0;
	fnameString         = strCopy(fnameUnparseStatic(fname));
	inclBuffer          = bufNew();
	includedFileCodes   = 0;
	localAssertList     = listCopy(String)(globalAssertList);

	fileState.curDir    = osCurDirName();
	fileState.fileCodes = 0;
	fileState.fileNames = 0;

	r = listNReverse(SrcLine)(
		inclFile(fnameString, false, true, &inclFileLineNo));

	strFree(fnameString);
	bufFree(inclBuffer);
	listFree(String)(localAssertList);
	listFree(Hash)(includedFileCodes);

	return r;
}
Example #6
0
File: include.c Project: pdo/aldor
/*
 * Return a processed source line list for the next line of the file.
 * The source line list may have several entries if the line is an
 * includer directive or requires a continuation.
 */
SrcLineList
includeLine(FileName fn, FILE *fin, int *plineno, InclIsContinuedFun iscont)
{
	SrcLineList   r;

	inclBuffer          = bufNew();
	localAssertList     = globalAssertList;

	fileState.curDir    = osCurDirName();
	fileState.curFile   = strCopy(fnameUnparseStatic(fn));
	fileState.curFname  = fn;
	fileState.infile    = fin;
	fileState.fileCodes = 0;
	fileState.fileNames = 0;
	fileState.lineNumber= *plineno;

	ifState = NoIf;

	r = 0;
	inclLine(&r, iscont);
	r = listNReverse(SrcLine)(r);

	/* Leave the assert list and included files for the next call. */
	globalAssertList = localAssertList;

	bufFree(inclBuffer);
	/* strFree(fileState.curFile);	!!This is held on to by the srclines.*/
	listFree(Hash)  (fileState.fileCodes);
	listFree(String)(fileState.fileNames);

	*plineno       = fileState.lineNumber;
	inclFileLineNo = fileState.lineNumber;

	return r;
}
Example #7
0
File: abquick.c Project: pdo/aldor
AbSynList
abqParseLines(StringList lines)
{
	AbSynList result = listNil(AbSyn);
	while (lines != listNil(String)) {
		result = listCons(AbSyn)(abqParse(car(lines)), result);
		lines = listFreeCons(String)(lines);
	}
	return listNReverse(AbSyn)(result);
}
Example #8
0
SymeList
symeListAddCondition(SymeList symes0, Sefo cond, Bool pos)
{
	SymeList	symes, nsymes = listNil(Syme);

	for (symes = symes0; symes; symes = cdr(symes)) {
		Syme nsyme = symeCopy(car(symes));
		symeAddCondition(nsyme, cond, pos);
		nsymes = listCons(Syme)(nsyme, nsymes);
	}

	return listNReverse(Syme)(nsymes);
}
Example #9
0
local Foam
gen0GenerSelect(int startLabel)
{
        Foam    select = foamNewEmpty(FOAM_Select, gen0State->yieldCount+2);
        int     i;

        select->foamSelect.op = yieldPlaceVar;
        gen0State->yieldLabels = listNReverse(AInt)(gen0State->yieldLabels);
        select->foamSelect.argv[0] = startLabel;
        for(i=1;
            i <= gen0State->yieldCount;
            i++, gen0State->yieldLabels = cdr(gen0State->yieldLabels))
                select->foamSelect.argv[i] = car(gen0State->yieldLabels);
        return select;
}
Example #10
0
SymeList
arGetLibrarySymes(Archive ar)
{
	ArEntryList	alist;
	SymeList	symes = listNil(Syme);

	if (!ar) return symes;

	for (alist = ar->members; alist; alist = cdr(alist)) {
		Syme	lib = libLibrarySyme(arEntryLib(ar, car(alist)));
		listPush(Syme, lib, symes);
	}

	return listNReverse(Syme)(symes);
}
Example #11
0
File: abquick.c Project: pdo/aldor
AbSyn
abqParseLinesAsSeq(StringList lines)
{
	SrcLineList sll = listNil(SrcLine);

	while (lines != listNil(String))
	{
		char *p = car(lines);
		lines = cdr(lines);
		int indent;
		while (*p == ' ') { p++; indent++; }
		String tmp = strConcat(p, "\n");
		SrcLine line = slineNew(sposNone, indent, tmp);
		strFree(tmp);
		sll = listCons(SrcLine)(line, sll);
	}

	return abqParseSrcLines(listNReverse(SrcLine)(sll));
}
Example #12
0
local void
arRdTable(Archive ar)
{
	ArEntryList	members = listNil(ArEntry);
	String		name;
	arDEBUG(dbOut, "arRdTable:\n");

	for (name = arFirst(ar); !arEndp(ar); name = arNext(ar)) {
		if (arItemIsIntermed(name)) {
			Offset		pos = arPosition(ar);
			ArEntry		arent = arAllocEntry(name, ar, pos);
			members = listCons(ArEntry)(arent, members);
			ar->hasIntermed = true;
			arDEBUG(dbOut, "    %s(%ld)\n", name, pos);
		}
	}

	ar->members = listNReverse(ArEntry)(members);
}
Example #13
0
TPoss
tpossIntersect(TPoss tp1, TPoss tp2)
{
	TFormList l = 0;
	TFormList l1;

	if (tp1 == NULL || tp2 == NULL)
		return NULL;

	l1 = tp1->possl;

	for (; l1; l1 = cdr(l1)) {
		car(l1) = tfFollowOnly(car(l1));
		if (tpossHas(tp2, car(l1)))
			l = listCons(TForm)(car(l1), l);
	}

	l = listNReverse(TForm)(l);
	return tpossFrTheList(l);
}
Example #14
0
TPoss
tpossSatisfiesType(TPoss S, TForm T)
{
	TFormList LS, l = 0;

	if (S == NULL)
		return NULL;

	T = tfFollowOnly(T);

	if (tfIsUnknown(T) || tpossIsPending(S, T))
		return tpossRefer(S);

	for (LS = S->possl; LS; LS = cdr(LS))
		if (tfSatisfies(car(LS), T))
			l = listCons(TForm)(car(LS), l);

	l = listNReverse(TForm)(l);
	return tpossFrTheList(l);
}
Example #15
0
TPoss
tpossSatisfies(TPoss S, TPoss T)
{
	TFormList LS, LT, l = 0;

	if (S == NULL || T == NULL) 
		return NULL;

	/* If T is free of duplicates, then the result will also be. */
	for (LT = T->possl; LT; LT = cdr(LT)) {
		car(LT) = tfFollowOnly(car(LT));
		for (LS = S->possl; LS; LS = cdr(LS)) {
			TForm	s = car(LS), t = car(LT);
			if (tfSatBit(tfSatBupMask(), s, t))
				l = listCons(TForm)(tpossJoin(s, t), l);
		}
	}

	l = listNReverse(TForm)(l);
	return tpossFrTheList(l);
}
Example #16
0
TPoss
tpossUnion(TPoss tp1, TPoss tp2)
{
	TFormList l1;
	TFormList l; 

	if (tp1 == NULL)
		return tp2;
	else if (tp2 == NULL)
		return tp1;

	l1 = tp1->possl;
	l = listReverse(TForm)(tp2->possl);	/* Reversed copy */

	for (; l1; l1 = cdr(l1)) {
		car(l1) = tfFollowOnly(car(l1));
		if (!tpossHas(tp2, car(l1)))
			l = listCons(TForm)(car(l1), l);
	}

	l = listNReverse(TForm)(l);
	return tpossFrTheList(l);
}
Example #17
0
SymeList
arGetSymes(Archive ar)
{
	ArEntryList	alist;
	SymeList	symes;

	if (!ar) return 0;

	if (ar->symes)
		return ar->symes;

	arFilter(ar);

	for (alist = ar->members; alist; alist = cdr(alist)) {
		ArEntry		arent = car(alist);
		if (!arent->mark) continue;
		symes = listReverse(Syme)(libGetSymes(arEntryLib(ar, arent)));
		ar->symes = listNConcat(Syme)(symes, ar->symes);
	}

	ar->symes = listNReverse(Syme)(ar->symes);
	return ar->symes;
}
Example #18
0
/*
 * Construct the parameter list for the function
 */
local FoamList
gen0ImplicitExportArgs(TForm tf)
{
	Foam		par;
	FoamList	lst = listNil(Foam);
	Length		i, numargs;


	/* How many parameters does this function have? */
	numargs = tfIsMulti(tf) ? tfMultiArgc(tf) : 1;


	/* Deal with single and multiple arguments separately */
	if (numargs > 1)
	{
		/* Process each argument */
		for (i = 0;i < numargs;i++)
		{
			/* Get the next argument */
			TForm	t = tfMultiArgN(tf, i);

			par = gen1ImplicitExportArg(t, (Length)i);
			lst = listCons(Foam)(par, lst);
		}
	}
	else if (numargs == 1)
	{
		/* A single argument */
		par = gen1ImplicitExportArg(tf, (Length)0);
		lst = listCons(Foam)(par, lst);
	}


	/* Reverse the list and return it */
	lst = listNReverse(Foam)(lst);
	return lst;
}
Example #19
0
static StringList
uclExpandLibs(StringList path0, StringList libs, String ext)
{
	StringList res = listNil(String);
	
	while (libs != listNil(String)) {
		String basename = car(libs);
		StringList path = path0;
                basename = strConcat("lib", basename);
		while (path != listNil(String)) {
			FileName name = fnameNew(car(path), basename, ext);
			if (fileIsOpenable(name, osIoRdMode)) {
				res = listCons(String)(fnameUnparse(name), res);
				break;
			}
			path = cdr(path);
		}
		if (path == listNil(String))
			printf("Warning: %s not found\n", basename);
                strFree(basename);
		libs = cdr(libs);
	}
	return listNReverse(String)(res);
}