Ejemplo n.º 1
0
local void
testSymeAddCondition()
{
	String B_imp = "import from Boolean";
	String C_txt = "C: Category == with";
	String D1_txt = "D1: with == add";
	String D2_txt = "D2: with == add";
	StringList lines = listList(String)(4, B_imp, C_txt, D1_txt, D2_txt);
	AbSynList code = listCons(AbSyn)(stdtypes(), abqParseLines(lines));
	
	AbSyn absyn = abNewSequenceL(sposNone, code);

	initFile();
	Stab stab = stabFile();
	
	abPutUse(absyn, AB_Use_NoValue);
	scopeBind(stab, absyn);
	typeInfer(stab, absyn);
	
	AbSyn D1 = abFrSyme(uniqueMeaning(stabFile(), "D1"));
	AbSyn D2 = abFrSyme(uniqueMeaning(stabFile(), "D2"));
	AbSyn C = abFrSyme(uniqueMeaning(stabFile(), "C"));
	Syme syme1 = symeNewExport(symInternConst("syme2"), tfNewAbSyn(TF_General, id("D")), car(stab));
	symeAddCondition(syme1, sefo(has(D1, C)), true);
	testIntEqual("test1", 1, listLength(Sefo)(symeCondition(syme1)));

	Syme syme2 = symeNewExport(symInternConst("syme1"),tfNewAbSyn(TF_General, id("D")), car(stab));
	symeAddCondition(syme2, sefo(and(has(D1, C),
					 has(D2, C))), true);
	
	testIntEqual("test2", 2, listLength(Sefo)(symeCondition(syme2)));

	finiFile();
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
0
Syme
symeAddCondition(Syme syme, Sefo cond, Bool pos)
{
	SefoList	l = symeCondition(syme);

	assert(tiTopFns()->tiCanSefo(cond));

	if (abTag(cond) == AB_Test)
		cond = cond->abTest.cond;

	if (abTag(cond) == AB_And) {
		Length	i = abArgc(cond);
		while (i > 0) {
			symeAddCondition(syme, abArgv(cond)[--i], pos);
		}
	}
	else {
		l = listCons(Sefo)(cond, l);
		symeSetCondition(syme, l);
	}
	return syme;
}