Пример #1
0
local Foam
gen0GenerStepFun(AbSyn body, TForm tf)
{
	GenFoamState	saved;
	Foam		foam, clos, tmp;
        FoamTag         yieldType;
	AInt		startLabel;
	AInt		fmtSlot;
        clos = foamNewClos(foamNewEnv(-1), foamNewConst(gen0NumProgs));
        foam = gen0ProgInitEmpty(stepperFName(), body);

        saved = gen0ProgSaveState(PT_Gener);

        startLabel = gen0State->labelNo++;
        gen0State->yieldPlace = gen0State->labelNo++;

	tf = tfDefineeType(tf);
        yieldType = gen0Type(tf, &fmtSlot);

        gen0State->yieldValueVar = gen0TempLocal0(yieldType, fmtSlot);
	
	tmp = foamNewNOp();
	gen0AddStmt(tmp, NULL);	/* filled by gen0GenerSelect */
	gen0AddStmt(foamNewLabel(startLabel), NULL);
	gen0AddStmt(foamNewSet(yieldDoneVar, foamNewBool(int0)), NULL);
        genFoamStmt(body);
	gen0AddStmt(foamNewSet(yieldDoneVar, foamNewBool(1)), NULL);
	gen0AddStmt(foamNewReturn(foamNew(FOAM_Values, int0)), NULL);
	gen0AddStmt(foamNewLabel(gen0State->yieldPlace), NULL);
	gen0AddStmt(foamNewSet(yieldValVar, gen0State->yieldValueVar), NULL);
	gen0AddStmt(foamNewReturn(foamNew(FOAM_Values, int0)), NULL);

	gen0UseStackedFormat(int0);
	gen0ProgPushFormat(emptyFormatSlot);
	gen0ProgPushFormat(emptyFormatSlot);
	gen0ProgFiniEmpty(foam, FOAM_NOp, int0);

	/* fill in the select statement */
	foam->foamProg.body->foamSeq.argv[0] = gen0GenerSelect(startLabel);
	foamFree(tmp);
        gen0AddLexLevels(foam, 2);

        foam->foamProg.infoBits = IB_SIDE | IB_INLINEME;
        foamOptInfo(foam) = inlInfoNew(gen0State->stab, foam, NULL, true);

	gen0ProgRestoreState(saved);
        return clos;
}
Пример #2
0
Bool
tpossHasMapType(TPoss tp)
{
	TPossIterator	tit;

	if (tp == NULL)
		return false;

	for (tpossITER(tit, tp); tpossMORE(tit); tpossSTEP(tit)) {
		TForm tf = tpossELT(tit);
		tf = tfDefineeType(tf);
		if (tfIsAnyMap(tf) || tfIsMapSyntax(tf))
			return true;
	}
	return false;
}
Пример #3
0
local TForm
tcFollowArg(TConst tc, Length i)
{
	return tcArgv(tc)[i] = tfDefineeType(tcArgv(tc)[i]);
}