コード例 #1
0
ファイル: compiler_llstream.c プロジェクト: jlp765/csources
N_NIMCALL(NI, llreadfromstdin_177528)(Tllstream177204* s, void* buf, NI buflen) {
	NI result;
	NimStringDesc* LOC1;
	NimStringDesc* line;
	NI triples;
	result = 0;
	LOC1 = 0;
	LOC1 = (*s).s; (*s).s = copyStringRC1(((NimStringDesc*) &TMP1107));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	(*s).rd = ((NI) 0);
	line = rawNewString(((NI) 120));
	triples = ((NI) 0);
	{
		while (1) {
			NimStringDesc* LOC4;
			NIM_BOOL LOC10;
			NI LOC11;
			LOC4 = 0;
			{
				if (!(((*s).s ? (*s).s->Sup.len : 0) == ((NI) 0))) goto LA7;
				LOC4 = copyString(((NimStringDesc*) &TMP1109));
			}
			goto LA5;
			LA7: ;
			{
				LOC4 = copyString(((NimStringDesc*) &TMP1110));
			}
			LA5: ;
			LOC10 = 0;
			LOC10 = readlinefromstdin_177319(LOC4, (&line));
			if (!LOC10) goto LA3;
			(*s).s = resizeString((*s).s, line->Sup.len + 0);
appendString((*s).s, line);
			(*s).s = resizeString((*s).s, 1);
appendString((*s).s, ((NimStringDesc*) &TMP1108));
			LOC11 = 0;
			LOC11 = counttriples_177483(line);
			triples += LOC11;
			{
				NIM_BOOL LOC14;
				LOC14 = 0;
				LOC14 = continueline_177460(line, (((NI) ((NI)(triples & ((NI) 1)))) == ((NI) 1)));
				if (!!(LOC14)) goto LA15;
				goto LA2;
			}
			LA15: ;
		} LA3: ;
	} LA2: ;
	(*s).lineoffset += ((NI) 1);
	result = ((buflen <= (NI)(((*s).s ? (*s).s->Sup.len : 0) - (*s).rd)) ? buflen : (NI)(((*s).s ? (*s).s->Sup.len : 0) - (*s).rd));
	{
		if (!(((NI) 0) < result)) goto LA19;
		memcpy(buf, ((void*) ((&(*s).s->data[(*s).rd]))), ((NI) (result)));
		(*s).rd += result;
	}
	LA19: ;
	return result;
}
コード例 #2
0
N_NIMCALL(NI, llreadfromstdin_177528)(Tllstream177204* s, void* buf, NI buflen) {
	NI result;
	NimStringDesc* LOC1;
	NimStringDesc* line;
	NI triples;
	NI TMP2101;
	NI TMP2102;
	nimfr("llReadFromStdin", "llstream.nim")
	result = 0;
	nimln(103, "llstream.nim");
	LOC1 = 0;
	LOC1 = (*s).s; (*s).s = copyStringRC1(((NimStringDesc*) &TMP2087));
	if (LOC1) nimGCunrefNoCycle(LOC1);
	nimln(104, "llstream.nim");
	(*s).rd = ((NI) 0);
	nimln(105, "llstream.nim");
	line = rawNewString(((NI) 120));
	nimln(106, "llstream.nim");
	triples = ((NI) 0);
	{
		nimln(107, "llstream.nim");
		while (1) {
			NimStringDesc* LOC4;
			NIM_BOOL LOC10;
			NI LOC11;
			NI TMP2100;
			LOC4 = 0;
			{
				if (!(((*s).s ? (*s).s->Sup.len : 0) == ((NI) 0))) goto LA7;
				LOC4 = copyString(((NimStringDesc*) &TMP2098));
			}
			goto LA5;
			LA7: ;
			{
				LOC4 = copyString(((NimStringDesc*) &TMP2099));
			}
			LA5: ;
			LOC10 = 0;
			LOC10 = readlinefromstdin_177319(LOC4, (&line));
			if (!LOC10) goto LA3;
			nimln(108, "llstream.nim");
			(*s).s = resizeString((*s).s, line->Sup.len + 0);
appendString((*s).s, line);
			nimln(109, "llstream.nim");
			(*s).s = resizeString((*s).s, 1);
appendString((*s).s, ((NimStringDesc*) &TMP2088));
			nimln(110, "llstream.nim");
			LOC11 = 0;
			LOC11 = counttriples_177483(line);
			TMP2100 = addInt(triples, LOC11);
			triples = (NI)(TMP2100);
			nimln(111, "llstream.nim");
			{
				NIM_BOOL LOC14;
				LOC14 = 0;
				LOC14 = continueline_177460(line, (((NI) ((NI)(triples & ((NI) 1)))) == ((NI) 1)));
				if (!!(LOC14)) goto LA15;
				goto LA2;
			}
			LA15: ;
		} LA3: ;
	} LA2: ;
	nimln(112, "llstream.nim");
	TMP2101 = addInt((*s).lineoffset, ((NI) 1));
	(*s).lineoffset = (NI)(TMP2101);
	nimln(113, "llstream.nim");
	TMP2102 = subInt(((*s).s ? (*s).s->Sup.len : 0), (*s).rd);
	result = ((buflen <= (NI)(TMP2102)) ? buflen : (NI)(TMP2102));
	nimln(114, "llstream.nim");
	{
		NI TMP2103;
		if (!(((NI) 0) < result)) goto LA19;
		nimln(115, "llstream.nim");
		if ((NU)((*s).rd) > (NU)((*s).s->Sup.len)) raiseIndexError();
		memcpy(buf, ((void*) ((&(*s).s->data[(*s).rd]))), ((NI)chckRange(result, ((NI) 0), ((NI) 2147483647))));
		nimln(116, "llstream.nim");
		TMP2103 = addInt((*s).rd, result);
		(*s).rd = (NI)(TMP2103);
	}
	LA19: ;
	popFrame();
	return result;
}