示例#1
0
N_NIMCALL(tident166019*, getident_166250)(NCSTRING identifier, NI length, NI h) {
	tident166019* result;
	NI idx;
	tident166019* last;
	NI id;
	NI i_166429;
	NI HEX3Atmp_166448;
	NI TMP977;
	NI res_166450;
	nimfr("getIdent", "idents.nim")
	result = 0;
	nimln(69, "idents.nim");
	nimln(69, "idents.nim");
	idx = (NI)(h & 8191);
	nimln(70, "idents.nim");
	result = buckets_166033[(idx)- 0];
	nimln(71, "idents.nim");
	last = NIM_NIL;
	nimln(72, "idents.nim");
	id = 0;
	nimln(73, "idents.nim");
	while (1) {
		nimln(73, "idents.nim");
		nimln(73, "idents.nim");
		if (!!((result == NIM_NIL))) goto LA1;
		nimln(74, "idents.nim");
		{
			NI LOC4;
			nimln(74, "idents.nim");
			nimln(74, "idents.nim");
			LOC4 = 0;
			LOC4 = cmpexact_166186((*result).S->data, identifier, length);
			if (!(LOC4 == 0)) goto LA5;
			nimln(75, "idents.nim");
			{
				nimln(75, "idents.nim");
				nimln(75, "idents.nim");
				if (!!((last == NIM_NIL))) goto LA9;
				nimln(77, "idents.nim");
				asgnRefNoCycle((void**) &(*last).Next, (*result).Next);
				nimln(78, "idents.nim");
				asgnRefNoCycle((void**) &(*result).Next, buckets_166033[(idx)- 0]);
				nimln(79, "idents.nim");
				asgnRefNoCycle((void**) &buckets_166033[(idx)- 0], result);
			}
			LA9: ;
			nimln(80, "idents.nim");
			goto BeforeRet;
		}
		goto LA2;
		LA5: ;
		{
			NI LOC12;
			nimln(81, "idents.nim");
			nimln(81, "idents.nim");
			LOC12 = 0;
			LOC12 = cmpignorestyle_166036((*result).S->data, identifier, length);
			if (!(LOC12 == 0)) goto LA13;
			nimln(82, "idents.nim");
			{
				NIM_BOOL LOC17;
				nimln(82, "idents.nim");
				nimln(82, "idents.nim");
				LOC17 = 0;
				nimln(82, "idents.nim");
				LOC17 = (id == 0);
				if (LOC17) goto LA18;
				nimln(82, "idents.nim");
				LOC17 = (id == (*result).Sup.Id);
				LA18: ;
				if (!!(LOC17)) goto LA19;
				nimln(82, "idents.nim");
				failedassertimpl_79821(((NimStringDesc*) &TMP974));
			}
			LA19: ;
			nimln(83, "idents.nim");
			id = (*result).Sup.Id;
		}
		goto LA2;
		LA13: ;
		LA2: ;
		nimln(84, "idents.nim");
		last = result;
		nimln(85, "idents.nim");
		result = (*result).Next;
	} LA1: ;
	nimln(86, "idents.nim");
	result = (tident166019*) newObj((&NTI166017), sizeof(tident166019));
	(*result).Sup.Sup.m_type = (&NTI166019);
	nimln(87, "idents.nim");
	(*result).H = h;
	nimln(88, "idents.nim");
	nimln(88, "idents.nim");
	asgnRefNoCycle((void**) &(*result).S, mnewString(length));
	i_166429 = 0;
	HEX3Atmp_166448 = 0;
	nimln(89, "idents.nim");
	nimln(89, "idents.nim");
	TMP977 = subInt(length, 1);
	HEX3Atmp_166448 = (NI32)(TMP977);
	nimln(1450, "system.nim");
	res_166450 = 0;
	nimln(1451, "system.nim");
	while (1) {
		nimln(1451, "system.nim");
		if (!(res_166450 <= HEX3Atmp_166448)) goto LA21;
		nimln(1450, "system.nim");
		i_166429 = res_166450;
		nimln(89, "idents.nim");
		if ((NU)(i_166429) > (NU)((*result).S->Sup.len)) raiseIndexError();
		(*result).S->data[i_166429] = identifier[i_166429];
		nimln(1453, "system.nim");
		res_166450 = addInt(res_166450, 1);
	} LA21: ;
	nimln(90, "idents.nim");
	asgnRefNoCycle((void**) &(*result).Next, buckets_166033[(idx)- 0]);
	nimln(91, "idents.nim");
	asgnRefNoCycle((void**) &buckets_166033[(idx)- 0], result);
	nimln(92, "idents.nim");
	{
		nimln(92, "idents.nim");
		if (!(id == 0)) goto LA24;
		nimln(93, "idents.nim");
		wordcounter_166248 = addInt(wordcounter_166248, 1);
		nimln(94, "idents.nim");
		nimln(94, "idents.nim");
		if (wordcounter_166248 == (-2147483647 -1)) raiseOverflow();
		(*result).Sup.Id = ((NI32)-(wordcounter_166248));
	}
	goto LA22;
	LA24: ;
	{
		nimln(96, "idents.nim");
		(*result).Sup.Id = id;
	}
	LA22: ;
	BeforeRet: ;
	popFrame();
	return result;
}
示例#2
0
N_NIMCALL(Tident_4umxGerWTHGPwUms7Yqu3g*, getident_62GxCdwHvMBvMwCLnw1wyg)(IdentcacheHEX3Aobjecttype_TzLHS09bRH9a0TYLs39cqcNaw* self0, NCSTRING identifier0, NI length0, NI h0) {
	Tident_4umxGerWTHGPwUms7Yqu3g* result0;
	NI idx0;
	Tident_4umxGerWTHGPwUms7Yqu3g* last0;
	NI id0;
{	result0 = (Tident_4umxGerWTHGPwUms7Yqu3g*)0;
	idx0 = (NI)(h0 & ((NI) 8191));
	result0 = (*self0).buckets[(idx0)- 0];
	last0 = NIM_NIL;
	id0 = ((NI) 0);
	{
		while (1) {
			if (!!((result0 == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = (NI)0;
				LOC5 = cmpexact_119akYztO9b7SG3fyF8j9bFgQ((*result0).s->data, identifier0, length0);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				{
					if (!!((last0 == NIM_NIL))) goto LA10;
					asgnRefNoCycle((void**) (&(*last0).next), (*result0).next);
					asgnRefNoCycle((void**) (&(*result0).next), (*self0).buckets[(idx0)- 0]);
					asgnRefNoCycle((void**) (&(*self0).buckets[(idx0)- 0]), result0);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = (NI)0;
				LOC13 = cmpignorestyle_119akYztO9b7SG3fyF8j9bFgQ_2((*result0).s->data, identifier0, length0);
				if (!(LOC13 == ((NI) 0))) goto LA14;
				id0 = (*result0).Sup.id;
			}
			goto LA3;
			LA14: ;
			LA3: ;
			last0 = result0;
			result0 = (*result0).next;
		} LA2: ;
	}
	result0 = (Tident_4umxGerWTHGPwUms7Yqu3g*) newObj((&NTI_1nh2T19a2BrGbBBQRS39bxRw), sizeof(Tident_4umxGerWTHGPwUms7Yqu3g));
	(*result0).Sup.Sup.m_type = (&NTI_4umxGerWTHGPwUms7Yqu3g);
	(*result0).h = h0;
	asgnRefNoCycle((void**) (&(*result0).s), mnewString(((NI) (length0))));
	{
		NI i_yLK0qWeSfXTJHMxV3Pw2kw;
		NI HEX3Atmp_6vu0tHH2HyLyTrLOiTwGMg;
		NI res_qrJ1psGNQBBXzQMviMk7NA;
		i_yLK0qWeSfXTJHMxV3Pw2kw = (NI)0;
		HEX3Atmp_6vu0tHH2HyLyTrLOiTwGMg = (NI)0;
		HEX3Atmp_6vu0tHH2HyLyTrLOiTwGMg = (NI)(length0 - ((NI) 1));
		res_qrJ1psGNQBBXzQMviMk7NA = ((NI) 0);
		{
			while (1) {
				if (!(res_qrJ1psGNQBBXzQMviMk7NA <= HEX3Atmp_6vu0tHH2HyLyTrLOiTwGMg)) goto LA18;
				i_yLK0qWeSfXTJHMxV3Pw2kw = res_qrJ1psGNQBBXzQMviMk7NA;
				(*result0).s->data[i_yLK0qWeSfXTJHMxV3Pw2kw] = identifier0[i_yLK0qWeSfXTJHMxV3Pw2kw];
				res_qrJ1psGNQBBXzQMviMk7NA += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result0).next), (*self0).buckets[(idx0)- 0]);
	asgnRefNoCycle((void**) (&(*self0).buckets[(idx0)- 0]), result0);
	{
		if (!(id0 == ((NI) 0))) goto LA21;
		(*self0).wordcounter += ((NI) 1);
		(*result0).Sup.id = ((NI32)-((*self0).wordcounter));
	}
	goto LA19;
	LA21: ;
	{
		(*result0).Sup.id = id0;
	}
	LA19: ;
	}BeforeRet: ;
	return result0;
}
    /**
     * Process a message that may be meant for the proximity system
     * \returns true if object was deleted
     */
    OpaqueMessageReturnValue internalProcessOpaqueProximityMessage(
                                               const ObjectReference*object,
                                               const RoutableMessageHeader& hdr,
                                               const void *serializedMessageBody,
                                               size_t serializedMessageBodySize,
                                               bool trusted) {
        try {
            RoutableMessage msg(hdr,serializedMessageBody,serializedMessageBodySize);
            MessageBundle sendState=DELIVER_TO_UNKNOWN;
            bool deliverAllMessages=true;
            int len=msg.body().message_size();
            OpaqueMessageReturnValue obj_is_deleted=OBJECT_NOT_DESTROYED;
            bool disconnection=false;
            bool registration=false;
            for (int i=0;i<len;++i) {
                if (trusted||(hdr.has_source_object()&&hdr.source_object()==ObjectReference::spaceServiceID()&&hdr.source_port()==mRegistrationPort)) {
                    if(msg.body().message_names(i)=="DelObj") {
                        disconnection=true;
                        obj_is_deleted=OBJECT_DELETED;
                    }
                    if(msg.body().message_names(i)=="RetObj") {
                        registration=true;
                        Sirikata::Protocol::RetObj ro;
                        ro.ParseFromString(msg.body().message_arguments(i));
                        newObj(ro,msg.body().message_arguments(i).data(),msg.body().message_arguments(i).size());
                    }
                }
                if (!forwardThisName(disconnection,msg.body().message_names(i))) {
                    if (len==1) return obj_is_deleted;
                    deliverAllMessages=false;
                }else {
                    if (msg.body().message_names(i)==proxCallbackName()) {
                        if (sendState==DELIVER_TO_UNKNOWN||sendState==DELIVER_TO_OBJECT)
                            sendState=DELIVER_TO_OBJECT;
                        else 
                            sendState=DELIVER_TO_BOTH;
                    }else{
                        if (sendState==DELIVER_TO_UNKNOWN||sendState==DELIVER_TO_PROX)
                            sendState=DELIVER_TO_PROX;
                        else 
                            sendState=DELIVER_TO_BOTH;
                    }
                }
            }
            if (sendState==DELIVER_TO_UNKNOWN)
                return obj_is_deleted;//no messages considered worth forwarding to the proximity system
            if (sendState==DELIVER_TO_BOTH) {
                SILOG(prox,info,"Message with recipients both proximity and object bundled into the same message: not delivering.");
                return obj_is_deleted;
            }
/* NOT SURE THIS IS NECESSARY -- do these messages already have addresses on them?*/
            DidAlterMessage alteration;
            if (sendState==DELIVER_TO_PROX) 
                alteration=addressMessage(msg,object,NULL);
            else
                alteration=addressMessage(msg,NULL,object);
            if (deliverAllMessages&&sendState==DELIVER_TO_PROX) {
                sendMessage(*object,msg,serializedMessageBody,serializedMessageBodySize);
            } else if (deliverAllMessages&&sendState==DELIVER_TO_OBJECT) {
                deliverMessage(*object,msg,serializedMessageBody,serializedMessageBodySize);
            }else {
                //some messages are not considered worth forwarding to the proximity system or there's a mishmash of destinations
                if (msg.body().message_size()<len) {
                    len=msg.body().message_size();
                }
                RoutableMessage newMsg (msg);
                newMsg.body().clear_message();
                for (int i=0;i<len;++i) {
                    if (forwardThisName(registration||disconnection,msg.body().message_names(i))) {
                        newMsg.body().add_message(msg.body().message_names(i), msg.body().message_arguments(i));
                    }
                }
                if (sendState==DELIVER_TO_OBJECT)
                    deliverMessage(*object,newMsg,NULL,0);
                if (sendState==DELIVER_TO_PROX)
                    sendMessage(*object,newMsg,NULL,0);
                
            }
            return obj_is_deleted;
        }catch(std::invalid_argument&) {
            SILOG(proximity,warning,"Could not parse message");
            return OBJECT_NOT_DESTROYED;
        }

    }
N_NIMCALL(Tident197010*, getident_197211_791273810)(NCSTRING identifier0, NI length0, NI h0) {
	Tident197010* result0;
	NI idx0;
	Tident197010* last0;
	NI id0;
{	result0 = (Tident197010*)0;
	idx0 = (NI)(h0 & ((NI) 8191));
	result0 = buckets_197024_791273810[(idx0)- 0];
	last0 = NIM_NIL;
	id0 = ((NI) 0);
	{
		while (1) {
			if (!!((result0 == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = (NI)0;
				LOC5 = cmpexact_197165_791273810((*result0).s->data, identifier0, length0);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				{
					if (!!((last0 == NIM_NIL))) goto LA10;
					asgnRefNoCycle((void**) (&(*last0).next), (*result0).next);
					asgnRefNoCycle((void**) (&(*result0).next), buckets_197024_791273810[(idx0)- 0]);
					asgnRefNoCycle((void**) (&buckets_197024_791273810[(idx0)- 0]), result0);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = (NI)0;
				LOC13 = cmpignorestyle_197026_791273810((*result0).s->data, identifier0, length0);
				if (!(LOC13 == ((NI) 0))) goto LA14;
				id0 = (*result0).Sup.id;
			}
			goto LA3;
			LA14: ;
			LA3: ;
			last0 = result0;
			result0 = (*result0).next;
		} LA2: ;
	}
	result0 = (Tident197010*) newObj((&NTI197008), sizeof(Tident197010));
	(*result0).Sup.Sup.m_type = (&NTI197010);
	(*result0).h = h0;
	asgnRefNoCycle((void**) (&(*result0).s), mnewString(((NI) (length0))));
	{
		NI i_197420_791273810;
		NI HEX3Atmp_197434_791273810;
		NI res_197437_791273810;
		i_197420_791273810 = (NI)0;
		HEX3Atmp_197434_791273810 = (NI)0;
		HEX3Atmp_197434_791273810 = (NI)(length0 - ((NI) 1));
		res_197437_791273810 = ((NI) 0);
		{
			while (1) {
				if (!(res_197437_791273810 <= HEX3Atmp_197434_791273810)) goto LA18;
				i_197420_791273810 = res_197437_791273810;
				(*result0).s->data[i_197420_791273810] = identifier0[i_197420_791273810];
				res_197437_791273810 += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result0).next), buckets_197024_791273810[(idx0)- 0]);
	asgnRefNoCycle((void**) (&buckets_197024_791273810[(idx0)- 0]), result0);
	{
		if (!(id0 == ((NI) 0))) goto LA21;
		wordcounter_197210_791273810 += ((NI) 1);
		(*result0).Sup.id = ((NI32)-(wordcounter_197210_791273810));
	}
	goto LA19;
	LA21: ;
	{
		(*result0).Sup.id = id0;
	}
	LA19: ;
	}BeforeRet: ;
	return result0;
}
示例#5
0
N_NIMCALL(tident140017*, getident_140202)(NCSTRING identifier, NI length, NI h) {
	tident140017* result;
	NI idx;
	tident140017* last;
	NI id;
	NI i_140422;
	NI HEX3Atmp_140435;
	NI TMP890;
	NI res_140437;
	nimfr("getIdent", "idents.nim")
	result = 0;
	nimln(69, "idents.nim");
	nimln(69, "idents.nim");
	idx = (NI)(h & 8191);
	nimln(70, "idents.nim");
	result = buckets_140031[(idx)- 0];
	nimln(71, "idents.nim");
	last = NIM_NIL;
	nimln(72, "idents.nim");
	id = 0;
	nimln(73, "idents.nim");
	while (1) {
		nimln(698, "system.nim");
		nimln(698, "system.nim");
		if (!!((result == NIM_NIL))) goto LA1;
		nimln(74, "idents.nim");
		{
			NI LOC4;
			nimln(74, "idents.nim");
			nimln(74, "idents.nim");
			LOC4 = 0;
			LOC4 = cmpexact_140152((*result).S->data, identifier, length);
			if (!(LOC4 == 0)) goto LA5;
			nimln(75, "idents.nim");
			{
				nimln(698, "system.nim");
				nimln(698, "system.nim");
				if (!!((last == NIM_NIL))) goto LA9;
				nimln(77, "idents.nim");
				asgnRefNoCycle((void**) &(*last).Next, (*result).Next);
				nimln(78, "idents.nim");
				asgnRefNoCycle((void**) &(*result).Next, buckets_140031[(idx)- 0]);
				nimln(79, "idents.nim");
				asgnRefNoCycle((void**) &buckets_140031[(idx)- 0], result);
			}			LA9: ;
			nimln(80, "idents.nim");
			goto BeforeRet;
		}		goto LA2;
		LA5: ;
		{
			NI LOC12;
			nimln(81, "idents.nim");
			nimln(81, "idents.nim");
			LOC12 = 0;
			LOC12 = cmpignorestyle_140034((*result).S->data, identifier, length);
			if (!(LOC12 == 0)) goto LA13;
			nimln(82, "idents.nim");
			{
				NIM_BOOL LOC17;
				nimln(82, "idents.nim");
				nimln(82, "idents.nim");
				LOC17 = 0;
				nimln(82, "idents.nim");
				LOC17 = (id == 0);
				if (LOC17) goto LA18;
				nimln(82, "idents.nim");
				LOC17 = (id == (*result).Sup.Id);
				LA18: ;
				if (!!(LOC17)) goto LA19;
				nimln(82, "idents.nim");
				hiddenraiseassert_76017(((NimStringDesc*) &TMP887));			}			LA19: ;
			nimln(83, "idents.nim");
			id = (*result).Sup.Id;
		}		goto LA2;
		LA13: ;
		LA2: ;
		nimln(84, "idents.nim");
		last = result;
		nimln(85, "idents.nim");
		result = (*result).Next;
	} LA1: ;
	nimln(86, "idents.nim");
	result = (tident140017*) newObj((&NTI140015), sizeof(tident140017));
	(*result).Sup.Sup.m_type = (&NTI140017);
	nimln(87, "idents.nim");
	(*result).H = h;
	nimln(88, "idents.nim");
	nimln(88, "idents.nim");
	asgnRefNoCycle((void**) &(*result).S, mnewString(length));
	i_140422 = 0;
	HEX3Atmp_140435 = 0;
	nimln(89, "idents.nim");
	nimln(89, "idents.nim");
	TMP890 = subInt(length, 1);
	HEX3Atmp_140435 = (NI64)(TMP890);
	nimln(1301, "system.nim");
	res_140437 = 0;
	nimln(1302, "system.nim");
	while (1) {
		nimln(1302, "system.nim");
		if (!(res_140437 <= HEX3Atmp_140435)) goto LA21;
		nimln(1301, "system.nim");
		i_140422 = res_140437;
		nimln(89, "idents.nim");
		if ((NU)(i_140422) > (NU)((*result).S->Sup.len)) raiseIndexError();
		(*result).S->data[i_140422] = identifier[i_140422];
		nimln(1304, "system.nim");
		res_140437 = addInt(res_140437, 1);
	} LA21: ;
	nimln(90, "idents.nim");
	asgnRefNoCycle((void**) &(*result).Next, buckets_140031[(idx)- 0]);
	nimln(91, "idents.nim");
	asgnRefNoCycle((void**) &buckets_140031[(idx)- 0], result);
	nimln(92, "idents.nim");
	{
		nimln(92, "idents.nim");
		if (!(id == 0)) goto LA24;
		nimln(93, "idents.nim");
		wordcounter_140200 = addInt(wordcounter_140200, 1);
		nimln(94, "idents.nim");
		nimln(94, "idents.nim");
		if (wordcounter_140200 == (IL64(-9223372036854775807) - IL64(1))) raiseOverflow();
		(*result).Sup.Id = ((NI64)-(wordcounter_140200));
	}	goto LA22;
	LA24: ;
	{
		nimln(96, "idents.nim");
		(*result).Sup.Id = id;
	}	LA22: ;
	BeforeRet: ;	popFrame();
	return result;
}
示例#6
0
N_NIMCALL(void, serve_521257)(TY521259 action) {
	TY521428* HEX3Aenv_521449;
	NimStringDesc* typ;
	HEX3Aenv_521449 = 0;
	HEX3Aenv_521449 = (TY521428*) newObj((&NTI521450), sizeof(TY521428));
	typ = getconfigvar_153340(((NimStringDesc*) &TMP4988));
	if (eqStrings(typ, ((NimStringDesc*) &TMP4989))) goto LA1;
	if (eqStrings(typ, ((NimStringDesc*) &TMP4990))) goto LA2;
	if (eqStrings(typ, ((NimStringDesc*) &TMP1075))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			while (1) {
				NimStringDesc* line;
				NimStringDesc* LOC12;
				line = readline_13478(stdin);
				{
					if (!eqStrings(line, ((NimStringDesc*) &TMP4992))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				LOC12 = 0;
				LOC12 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(line);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				processcmdline_521209(((NU8) 1), line);
				action();
				gerrorcounter_163016 = ((NI) 0);
				printf("%s\012", ((NimStringDesc*) &TMP1075)? (((NimStringDesc*) &TMP1075))->data:"nil");
				fflush(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl513407* server;
		NimStringDesc* p;
		NU16 port;
		NimStringDesc* LOC20;
		NimStringDesc* inp;
		TY163060 LOC21;
		server = newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE);
		p = getconfigvar_153340(((NimStringDesc*) &TMP4993));
		{
			NI LOC18;
			if (!(((NI) 0) < (p ? p->Sup.len : 0))) goto LA16;
			LOC18 = 0;
			LOC18 = nsuParseInt(p);
			port = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port = ((NU16) 6000);
		}
		LA14: ;
		LOC20 = 0;
		LOC20 = getconfigvar_153340(((NimStringDesc*) &TMP4994));
		bindaddr_514620(server, port, LOC20);
		inp = copyString(((NimStringDesc*) &TMP1075));
		listen_514610(server, SOMAXCONN);
		asgnRefNoCycle((void**) (&(*HEX3Aenv_521449).stdoutsocket521408), newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE));
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_521409; LOC21.ClEnv = HEX3Aenv_521449;
		asgnRef((void**) (&writelnhook_163063.ClEnv), LOC21.ClEnv);
		writelnhook_163063.ClPrc = LOC21.ClPrc;
		{
			while (1) {
				NimStringDesc* LOC24;
				accept_515401(server, &(*HEX3Aenv_521449).stdoutsocket521408, 2);
				readline_517608((*HEX3Aenv_521449).stdoutsocket521408, (&inp), ((NI) -1), 2);
				LOC24 = 0;
				LOC24 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(inp);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				processcmdline_521209(((NU8) 1), inp);
				action();
				gerrorcounter_163016 = ((NI) 0);
				send_518208((*HEX3Aenv_521449).stdoutsocket521408, ((NimStringDesc*) &TMP4997), 2);
				close_515417((*HEX3Aenv_521449).stdoutsocket521408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		printf("%s%s\012", ((NimStringDesc*) &TMP5006)? (((NimStringDesc*) &TMP5006))->data:"nil", typ? (typ)->data:"nil");
		msgquit_163112(((NI8) 1));
	}
	LA4: ;
}
示例#7
0
N_NIMCALL(void, serve_530236)(TY530238 action) {
	TY530421* HEX3Aenv_530426;
	NimStringDesc* typ;
	HEX3Aenv_530426 = 0;
	HEX3Aenv_530426 = (TY530421*) newObj((&NTI530420), sizeof(TY530421));
	typ = getconfigvar_160282(((NimStringDesc*) &TMP5273));
	if (eqStrings(typ, ((NimStringDesc*) &TMP5274))) goto LA1;
	if (eqStrings(typ, ((NimStringDesc*) &TMP5275))) goto LA2;
	if (eqStrings(typ, ((NimStringDesc*) &TMP1193))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			while (1) {
				NimStringDesc* line;
				NimStringDesc* LOC12;
				line = readline_15510(stdin);
				{
					if (!eqStrings(line, ((NimStringDesc*) &TMP5276))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				LOC12 = 0;
				LOC12 = curcaascmd_530201; curcaascmd_530201 = copyStringRC1(line);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				processcmdline_530203(((NU8) 1), line);
				action();
				gerrorcounter_183081 = ((NI) 0);
				printf("%s\012", ((NimStringDesc*) &TMP1193)? (((NimStringDesc*) &TMP1193))->data:"nil");
				fflush(stdout);
				fflush(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl522404* server;
		NimStringDesc* p;
		NU16 port;
		NimStringDesc* LOC20;
		NimStringDesc* inp;
		TY183114 LOC21;
		server = newsocket_522821(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE);
		p = getconfigvar_160282(((NimStringDesc*) &TMP5278));
		{
			NI LOC18;
			if (!(((NI) 0) < (p ? p->Sup.len : 0))) goto LA16;
			LOC18 = 0;
			LOC18 = nsuParseInt(p);
			port = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port = ((NU16) 6000);
		}
		LA14: ;
		LOC20 = 0;
		LOC20 = getconfigvar_160282(((NimStringDesc*) &TMP5279));
		bindaddr_523608(server, port, LOC20);
		inp = copyString(((NimStringDesc*) &TMP1193));
		listen_523604(server, SOMAXCONN);
		asgnRefNoCycle((void**) (&(*HEX3Aenv_530426).stdoutsocket530408), newsocket_522821(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE));
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_530409; LOC21.ClEnv = HEX3Aenv_530426;
		asgnRef((void**) (&writelnhook_183117.ClEnv), LOC21.ClEnv);
		writelnhook_183117.ClPrc = LOC21.ClPrc;
		{
			while (1) {
				NimStringDesc* LOC24;
				accept_524401(server, &(*HEX3Aenv_530426).stdoutsocket530408, 2);
				readline_526602((*HEX3Aenv_530426).stdoutsocket530408, (&inp), ((NI) -1), 2);
				LOC24 = 0;
				LOC24 = curcaascmd_530201; curcaascmd_530201 = copyStringRC1(inp);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				processcmdline_530203(((NU8) 1), inp);
				action();
				gerrorcounter_183081 = ((NI) 0);
				send_527202((*HEX3Aenv_530426).stdoutsocket530408, ((NimStringDesc*) &TMP5282), 2);
				close_524411((*HEX3Aenv_530426).stdoutsocket530408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		printf("%s%s\012", ((NimStringDesc*) &TMP5290)? (((NimStringDesc*) &TMP5290))->data:"nil", typ? (typ)->data:"nil");
		fflush(stdout);
		msgquit_183152(((NI8) 1));
	}
	LA4: ;
}
示例#8
0
N_NIMCALL(void, gethostbyaddr_511434)(NimStringDesc* ip, Hostent509612* Result) {
	struct in_addr myaddr;
	struct hostent* s;
	nimfr("getHostByAddr", "rawsockets.nim")
	memset((void*)(&myaddr), 0, sizeof(myaddr));
	nimln(271, "rawsockets.nim");
	myaddr.s_addr = inet_addr(ip->data);
	nimln(278, "rawsockets.nim");
	s = gethostbyaddr(((void*) ((&myaddr))), ((socklen_t) (((NI)sizeof(struct in_addr)))), AF_INET);
	nimln(280, "rawsockets.nim");
	{
		Oserror3433* e_511617;
		NCSTRING LOC5;
		if (!(s == NIM_NIL)) goto LA3;
		e_511617 = 0;
		nimln(2265, "system.nim");
		e_511617 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_511617).Sup.Sup.Sup.m_type = (&NTI3433);
		nimln(2266, "system.nim");
		nimln(281, "rawsockets.nim");
		LOC5 = 0;
		LOC5 = hstrerror(h_errno);
		asgnRefNoCycle((void**) (&(*e_511617).Sup.Sup.message), cstrToNimstr(LOC5));
		raiseException((Exception*)e_511617, "OSError");
	}
	LA3: ;
	nimln(283, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).name), cstrToNimstr((*s).h_name));
	nimln(284, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).aliases), cstringarraytoseq_13843((*s).h_aliases));
	nimln(288, "rawsockets.nim");
	{
		if (!((*s).h_addrtype == AF_INET)) goto LA8;
		nimln(289, "rawsockets.nim");
		(*Result).addrtype = ((NU8) 2);
	}
	goto LA6;
	LA8: ;
	{
		nimln(290, "rawsockets.nim");
		if (!((*s).h_addrtype == AF_INET6)) goto LA11;
		nimln(291, "rawsockets.nim");
		(*Result).addrtype = ((NU8) 23);
	}
	goto LA6;
	LA11: ;
	{
		Oserror3433* e_511803;
		NimStringDesc* LOC14;
		e_511803 = 0;
		nimln(2265, "system.nim");
		e_511803 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_511803).Sup.Sup.Sup.m_type = (&NTI3433);
		nimln(2266, "system.nim");
		LOC14 = 0;
		LOC14 = (*e_511803).Sup.Sup.message; (*e_511803).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP10618));
		if (LOC14) nimGCunrefNoCycle(LOC14);
		nimln(293, "rawsockets.nim");
		raiseException((Exception*)e_511803, "OSError");
	}
	LA6: ;
	nimln(294, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).addrlist), cstringarraytoseq_13843((*s).h_addr_list));
	nimln(295, "rawsockets.nim");
	(*Result).length = ((NI) ((*s).h_length));
	popFrame();
}
示例#9
0
N_NIMCALL(NI, waitfor_527806)(Socketimpl524404* socket, NF* waited, NI timeout, NI size, NimStringDesc* funcname) {
	NI result;
{	result = 0;
	result = ((NI) 1);
	{
		if (!(size <= ((NI) 0))) goto LA3;
	}
	LA3: ;
	{
		if (!(timeout == ((NI) -1))) goto LA7;
		result = size;
		goto BeforeRet;
	}
	LA7: ;
	{
		NIM_BOOL LOC11;
		NIM_BOOL LOC12;
		LOC11 = 0;
		LOC12 = 0;
		LOC12 = (*socket).isbuffered;
		if (!(LOC12)) goto LA13;
		LOC12 = !(((*socket).isbufferedU.S1.buflen == ((NI) 0)));
		LA13: ;
		LOC11 = LOC12;
		if (!(LOC11)) goto LA14;
		LOC11 = !(((*socket).isbufferedU.S1.buflen == (*socket).isbufferedU.S1.currpos));
		LA14: ;
		if (!LOC11) goto LA15;
		result = (NI)((*socket).isbufferedU.S1.buflen - (*socket).isbufferedU.S1.currpos);
		result = ((result <= size) ? result : size);
	}
	goto LA9;
	LA15: ;
	{
		NF starttime;
		NI selret;
		NF LOC33;
		{
			Timeouterror524412* e_528013;
			NimStringDesc* LOC22;
			if (!((NI)(timeout - ((NI) (((NF)((*waited)) * (NF)(1.0000000000000000e+03))))) < ((NI) 1))) goto LA20;
			e_528013 = 0;
			e_528013 = (Timeouterror524412*) newObj((&NTI528014), sizeof(Timeouterror524412));
			(*e_528013).Sup.Sup.m_type = (&NTI524412);
			LOC22 = 0;
			LOC22 = rawNewString(funcname->Sup.len + 21);
appendString(LOC22, ((NimStringDesc*) &TMP5287));
appendString(LOC22, funcname);
appendString(LOC22, ((NimStringDesc*) &TMP5288));
			asgnRefNoCycle((void**) (&(*e_528013).Sup.message), LOC22);
			raiseException((Exception*)e_528013, "TimeoutError");
		}
		LA20: ;
		starttime = ntepochTime();
		selret = select_527201(socket, (NI)(timeout - ((NI) (((NF)((*waited)) * (NF)(1.0000000000000000e+03))))));
		{
			NI32 LOC27;
			if (!(selret < ((NI) 0))) goto LA25;
			LOC27 = 0;
			LOC27 = oslasterror_120040();
			raiseoserror_120024(LOC27, ((NimStringDesc*) &TMP5280));
		}
		LA25: ;
		{
			Timeouterror524412* e_528206;
			NimStringDesc* LOC32;
			if (!!((selret == ((NI) 1)))) goto LA30;
			e_528206 = 0;
			e_528206 = (Timeouterror524412*) newObj((&NTI528014), sizeof(Timeouterror524412));
			(*e_528206).Sup.Sup.m_type = (&NTI524412);
			LOC32 = 0;
			LOC32 = rawNewString(funcname->Sup.len + 21);
appendString(LOC32, ((NimStringDesc*) &TMP5287));
appendString(LOC32, funcname);
appendString(LOC32, ((NimStringDesc*) &TMP5288));
			asgnRefNoCycle((void**) (&(*e_528206).Sup.message), LOC32);
			raiseException((Exception*)e_528206, "TimeoutError");
		}
		LA30: ;
		LOC33 = 0;
		LOC33 = ntepochTime();
		HEX2BHEX3D_109802(waited, ((NF)(LOC33) - (NF)(starttime)));
	}
	LA9: ;
	}BeforeRet: ;
	return result;
}
示例#10
0
	inline void exclusive(Release<T>& ptr) {
		if (ptr->references() != 1) {
			Release<T> newObj(new T(*ptr));
			ptr = newObj;
		};
	}
N_NIMCALL(void, serve_594236_3526807654)(TY594238 action0) {
	TY594421* HEX3Aenv_594426_3526807654;
	NimStringDesc* typ0;
	HEX3Aenv_594426_3526807654 = (TY594421*)0;
	HEX3Aenv_594426_3526807654 = (TY594421*) newObj((&NTI594420), sizeof(TY594421));
	typ0 = getconfigvar_171292_2607990831(((NimStringDesc*) &T3526807654_10));
	if (eqStrings(typ0, ((NimStringDesc*) &T3526807654_11))) goto LA1;
	if (eqStrings(typ0, ((NimStringDesc*) &T3526807654_12))) goto LA2;
	if (eqStrings(typ0, ((NimStringDesc*) &T3526807654_3))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			while (1) {
				NimStringDesc* line0;
				NimStringDesc* LOC12;
				line0 = readline_14912_1689653243(stdin);
				{
					if (!eqStrings(line0, ((NimStringDesc*) &T3526807654_13))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				LOC12 = (NimStringDesc*)0;
				LOC12 = curcaascmd_594201_3526807654; curcaascmd_594201_3526807654 = copyStringRC1(line0);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				processcmdline_594203_3526807654(((Tcmdlinepass282008) 1), line0);
				action0();
				gerrorcounter_194072_155036129 = ((NI) 0);
				printf("%s\012", ((NimStringDesc*) &T3526807654_3)? (((NimStringDesc*) &T3526807654_3))->data:"nil");
				fflush(stdout);
				flushfile_14862_1689653243(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl585406* server0;
		NimStringDesc* p0;
		NU16 port0;
		NimStringDesc* LOC20;
		NimStringDesc* inp0;
		TY194107 LOC21;
		server0 = newsocket_586009_170061329(((Domain579604) 2), ((Socktype579606) 1), ((Protocol579608) 6), NIM_TRUE);
		p0 = getconfigvar_171292_2607990831(((NimStringDesc*) &T3526807654_14));
		{
			NI LOC18;
			if (!(((NI) 0) < (p0 ? p0->Sup.len : 0))) goto LA16;
			LOC18 = (NI)0;
			LOC18 = nsuParseInt(p0);
			port0 = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port0 = ((NU16) 6000);
		}
		LA14: ;
		LOC20 = (NimStringDesc*)0;
		LOC20 = getconfigvar_171292_2607990831(((NimStringDesc*) &T3526807654_15));
		bindaddr_586808_170061329(server0, port0, LOC20);
		inp0 = copyString(((NimStringDesc*) &T3526807654_3));
		listen_586804_170061329(server0, SOMAXCONN);
		asgnRefNoCycle((void**) (&(*HEX3Aenv_594426_3526807654).stdoutsocket594408), newsocket_586009_170061329(((Domain579604) 2), ((Socktype579606) 1), ((Protocol579608) 6), NIM_TRUE));
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_594409_3526807654; LOC21.ClEnv = HEX3Aenv_594426_3526807654;
		asgnRef((void**) (&writelnhook_194110_155036129.ClEnv), LOC21.ClEnv);
		writelnhook_194110_155036129.ClPrc = LOC21.ClPrc;
		{
			while (1) {
				NimStringDesc* LOC24;
				accept_587601_170061329(server0, &(*HEX3Aenv_594426_3526807654).stdoutsocket594408, 2);
				readline_590402_170061329((*HEX3Aenv_594426_3526807654).stdoutsocket594408, (&inp0), ((NI) -1), 2, ((NI) 1000000));
				LOC24 = (NimStringDesc*)0;
				LOC24 = curcaascmd_594201_3526807654; curcaascmd_594201_3526807654 = copyStringRC1(inp0);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				processcmdline_594203_3526807654(((Tcmdlinepass282008) 1), inp0);
				action0();
				gerrorcounter_194072_155036129 = ((NI) 0);
				send_591002_170061329((*HEX3Aenv_594426_3526807654).stdoutsocket594408, ((NimStringDesc*) &T3526807654_16), 2);
				close_587611_170061329((*HEX3Aenv_594426_3526807654).stdoutsocket594408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		printf("%s%s\012", ((NimStringDesc*) &T3526807654_17)? (((NimStringDesc*) &T3526807654_17))->data:"nil", typ0? (typ0)->data:"nil");
		fflush(stdout);
		msgquit_194149_155036129(((NI8) 1));
	}
	LA4: ;
}
示例#12
0
N_NIMCALL(Tident167021*, getident_167248)(NCSTRING identifier, NI length, NI h) {
	Tident167021* result;
	NI idx;
	Tident167021* last;
	NI id;
{	result = 0;
	idx = (NI)(h & ((NI) 8191));
	result = buckets_167039[(idx)- 0];
	last = NIM_NIL;
	id = ((NI) 0);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NI LOC5;
				LOC5 = 0;
				LOC5 = cmpexact_167187((*result).s->data, identifier, length);
				if (!(LOC5 == ((NI) 0))) goto LA6;
				{
					if (!!((last == NIM_NIL))) goto LA10;
					asgnRefNoCycle((void**) (&(*last).next), (*result).next);
					asgnRefNoCycle((void**) (&(*result).next), buckets_167039[(idx)- 0]);
					asgnRefNoCycle((void**) (&buckets_167039[(idx)- 0]), result);
				}
				LA10: ;
				goto BeforeRet;
			}
			goto LA3;
			LA6: ;
			{
				NI LOC13;
				LOC13 = 0;
				LOC13 = cmpignorestyle_167044((*result).s->data, identifier, length);
				if (!(LOC13 == ((NI) 0))) goto LA14;
				id = (*result).Sup.id;
			}
			goto LA3;
			LA14: ;
			LA3: ;
			last = result;
			result = (*result).next;
		} LA2: ;
	}
	result = (Tident167021*) newObj((&NTI167019), sizeof(Tident167021));
	(*result).Sup.Sup.m_type = (&NTI167021);
	(*result).h = h;
	asgnRefNoCycle((void**) (&(*result).s), mnewString(((NI) (length))));
	{
		NI i_167421;
		NI HEX3Atmp_167435;
		NI res_167438;
		i_167421 = 0;
		HEX3Atmp_167435 = 0;
		HEX3Atmp_167435 = (NI)(length - ((NI) 1));
		res_167438 = ((NI) 0);
		{
			while (1) {
				if (!(res_167438 <= HEX3Atmp_167435)) goto LA18;
				i_167421 = res_167438;
				(*result).s->data[i_167421] = identifier[i_167421];
				res_167438 += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result).next), buckets_167039[(idx)- 0]);
	asgnRefNoCycle((void**) (&buckets_167039[(idx)- 0]), result);
	{
		if (!(id == ((NI) 0))) goto LA21;
		wordcounter_167244 += ((NI) 1);
		(*result).Sup.id = ((NI64)-(wordcounter_167244));
	}
	goto LA19;
	LA21: ;
	{
		(*result).Sup.id = id;
	}
	LA19: ;
	}BeforeRet: ;
	return result;
}
示例#13
0
N_NIMCALL(void, readline_588402)(Socketimpl583406* socket, NimStringDesc** line, NI timeout, NU8 flags, NI maxlength) {
	NF waited;
{	waited = 0.0;
	(*line) = setLengthStr((*line), ((NI) 0));
	{
		while (1) {
			NIM_CHAR c;
			NI LOC3;
			NI n;
			c = 0;
			LOC3 = 0;
			LOC3 = waitfor_587606(socket, (&waited), timeout, ((NI) 1), ((NimStringDesc*) &TMP5503));
			n = recv_587216(socket, ((void*) ((&c))), ((NI) 1));
			{
				NI32 lasterror;
				if (!(n < ((NI) 0))) goto LA6;
				lasterror = getsocketerror_584201(socket);
				{
					NIM_BOOL LOC10;
					LOC10 = 0;
					LOC10 = isdisconnectionerror_583470(flags, lasterror);
					if (!LOC10) goto LA11;
					(*line) = setLengthStr((*line), ((NI) 0));
					goto BeforeRet;
				}
				LA11: ;
				socketerror_583464(socket, n, NIM_FALSE, lasterror);
			}
			goto LA4;
			LA6: ;
			{
				if (!(n == ((NI) 0))) goto LA14;
				(*line) = setLengthStr((*line), ((NI) 0));
				goto BeforeRet;
			}
			goto LA4;
			LA14: ;
			LA4: ;
			{
				NI LOC20;
				if (!((NU8)(c) == (NU8)(13))) goto LA18;
				LOC20 = 0;
				LOC20 = waitfor_587606(socket, (&waited), timeout, ((NI) 1), ((NimStringDesc*) &TMP5503));
				n = peekchar_588236(socket, (&c));
				{
					NIM_BOOL LOC23;
					NI LOC27;
					LOC23 = 0;
					LOC23 = (((NI) 0) < n);
					if (!(LOC23)) goto LA24;
					LOC23 = ((NU8)(c) == (NU8)(10));
					LA24: ;
					if (!LOC23) goto LA25;
					LOC27 = 0;
					LOC27 = recv_587216(socket, ((void*) ((&c))), ((NI) 1));
				}
				goto LA21;
				LA25: ;
				{
					NI32 lasterror;
					if (!(n <= ((NI) 0))) goto LA29;
					lasterror = getsocketerror_584201(socket);
					{
						NIM_BOOL LOC33;
						LOC33 = 0;
						LOC33 = isdisconnectionerror_583470(flags, lasterror);
						if (!LOC33) goto LA34;
						(*line) = setLengthStr((*line), ((NI) 0));
						goto BeforeRet;
					}
					LA34: ;
					socketerror_583464(socket, n, NIM_FALSE, lasterror);
				}
				goto LA21;
				LA29: ;
				LA21: ;
				{
					if (!(((*line) ? (*line)->Sup.len : 0) == ((NI) 0))) goto LA38;
					(*line) = resizeString((*line), 2);
appendString((*line), ((NimStringDesc*) &TMP5504));
				}
				LA38: ;
				goto BeforeRet;
			}
			goto LA16;
			LA18: ;
			{
				if (!((NU8)(c) == (NU8)(10))) goto LA41;
				{
					if (!(((*line) ? (*line)->Sup.len : 0) == ((NI) 0))) goto LA45;
					(*line) = resizeString((*line), 2);
appendString((*line), ((NimStringDesc*) &TMP5504));
				}
				LA45: ;
				goto BeforeRet;
			}
			goto LA16;
			LA41: ;
			LA16: ;
			(*line) = addChar((*line), c);
			{
				NimStringDesc* msg;
				Valueerror3646* e_588438;
				NimStringDesc* LOC51;
				if (!(maxlength < ((*line) ? (*line)->Sup.len : 0))) goto LA49;
				msg = copyString(((NimStringDesc*) &TMP5505));
				e_588438 = 0;
				e_588438 = (Valueerror3646*) newObj((&NTI23025), sizeof(Valueerror3646));
				(*e_588438).Sup.Sup.m_type = (&NTI3646);
				LOC51 = 0;
				LOC51 = (*e_588438).Sup.message; (*e_588438).Sup.message = copyStringRC1(msg);
				if (LOC51) nimGCunrefNoCycle(LOC51);
				raiseException((Exception*)e_588438, "ValueError");
			}
			LA49: ;
		}
	}
	}BeforeRet: ;
}
示例#14
0
N_LIB_PRIVATE N_NIMCALL(tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA*, getIdent_F9bx0Ytx9cft0EbGcAUpUsBw)(tyObject_IdentCachecolonObjectType__TzLHS09bRH9a0TYLs39cqcNaw* ic, NCSTRING identifier, NI length, NI h) {
	tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA* result;
	NI idx;
	tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA* last;
	NI id;
{	result = (tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA*)0;
	idx = (NI)(h & ((NI) 8191));
	result = (*ic).buckets[(idx)- 0];
	last = NIM_NIL;
	id = ((NI) 0);
	{
		while (1) {
			if (!!((result == NIM_NIL))) goto LA2;
			{
				NI T5_;
				T5_ = (NI)0;
				T5_ = cmpExact_119akYztO9b7SG3fyF8j9bFgQ(nimToCStringConv((*result).s), identifier, length);
				if (!(T5_ == ((NI) 0))) goto LA6_;
				{
					if (!!((last == NIM_NIL))) goto LA10_;
					asgnRefNoCycle((void**) (&(*last).next), (*result).next);
					asgnRefNoCycle((void**) (&(*result).next), (*ic).buckets[(idx)- 0]);
					asgnRefNoCycle((void**) (&(*ic).buckets[(idx)- 0]), result);
				}
				LA10_: ;
				goto BeforeRet_;
			}
			goto LA3_;
			LA6_: ;
			{
				NI T13_;
				T13_ = (NI)0;
				T13_ = cmpIgnoreStyle_119akYztO9b7SG3fyF8j9bFgQ_2(nimToCStringConv((*result).s), identifier, length);
				if (!(T13_ == ((NI) 0))) goto LA14_;
				id = (*result).Sup.id;
			}
			goto LA3_;
			LA14_: ;
			LA3_: ;
			last = result;
			result = (*result).next;
		} LA2: ;
	}
	result = (tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA*) newObj((&NTI_B0xRsLi0eK4raPu9bd2tkcA_), sizeof(tyObject_TIdent_GufRQq9c0miSybX3zBD4tyA));
	(*result).Sup.Sup.m_type = (&NTI_GufRQq9c0miSybX3zBD4tyA_);
	(*result).h = h;
	asgnRefNoCycle((void**) (&(*result).s), mnewString(((NI) (length))));
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (NI)(length - ((NI) 1));
		res = ((NI) 0);
		{
			while (1) {
				if (!(res <= colontmp_)) goto LA18;
				i = res;
				(*result).s->data[i] = identifier[i];
				res += ((NI) 1);
			} LA18: ;
		}
	}
	asgnRefNoCycle((void**) (&(*result).next), (*ic).buckets[(idx)- 0]);
	asgnRefNoCycle((void**) (&(*ic).buckets[(idx)- 0]), result);
	{
		if (!(id == ((NI) 0))) goto LA21_;
		(*ic).wordCounter += ((NI) 1);
		(*result).Sup.id = ((NI64)-((*ic).wordCounter));
	}
	goto LA19_;
	LA21_: ;
	{
		(*result).Sup.id = id;
	}
	LA19_: ;
	}BeforeRet_: ;
	return result;
}
示例#15
0
N_NIMCALL(void, serve_520254)(TY520256 action) {
	TY520426* HEX3Aenv_520447;
	NimStringDesc* typ;
	nimfr("serve", "service.nim")
	HEX3Aenv_520447 = 0;
	nimln(180, "system.nim");
	HEX3Aenv_520447 = (TY520426*) newObj((&NTI520448), sizeof(TY520426));
	nimln(55, "service.nim");
	typ = getconfigvar_152334(((NimStringDesc*) &TMP10641));
	nimln(56, "service.nim");
	if (eqStrings(typ, ((NimStringDesc*) &TMP10642))) goto LA1;
	if (eqStrings(typ, ((NimStringDesc*) &TMP10643))) goto LA2;
	if (eqStrings(typ, ((NimStringDesc*) &TMP10628))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			nimln(58, "service.nim");
			while (1) {
				NimStringDesc* line;
				NimStringDesc* LOC12;
				nimln(59, "service.nim");
				line = readline_13478(stdin);
				nimln(60, "service.nim");
				{
					if (!eqStrings(line, ((NimStringDesc*) &TMP10644))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				nimln(50, "service.nim");
				LOC12 = 0;
				LOC12 = curcaascmd_520204; curcaascmd_520204 = copyStringRC1(line);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				nimln(51, "service.nim");
				processcmdline_520209(((NU8) 1), line);
				nimln(52, "service.nim");
				action();
				nimln(53, "service.nim");
				gerrorcounter_162012 = ((NI) 0);
				nimln(62, "service.nim");
				printf("%s\012", ((NimStringDesc*) &TMP10628)? (((NimStringDesc*) &TMP10628))->data:"nil");
				nimln(63, "service.nim");
				fflush(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl512407* server;
		NimStringDesc* p;
		NU16 port;
		NimStringDesc* LOC20;
		NimStringDesc* inp;
		TY162054 LOC21;
		nimln(67, "service.nim");
		server = newsocket_512830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE);
		nimln(68, "service.nim");
		p = getconfigvar_152334(((NimStringDesc*) &TMP10647));
		nimln(69, "service.nim");
		{
			NI LOC18;
			if (!(((NI) 0) < (p ? p->Sup.len : 0))) goto LA16;
			LOC18 = 0;
			LOC18 = nsuParseInt(p);
			port = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port = ((NU16) 6000);
		}
		LA14: ;
		nimln(70, "service.nim");
		LOC20 = 0;
		LOC20 = getconfigvar_152334(((NimStringDesc*) &TMP10648));
		bindaddr_513620(server, port, LOC20);
		nimln(71, "service.nim");
		inp = copyString(((NimStringDesc*) &TMP10628));
		nimln(72, "service.nim");
		listen_513610(server, SOMAXCONN);
		nimln(73, "service.nim");
		asgnRefNoCycle((void**) (&(*HEX3Aenv_520447).stdoutsocket520408), newsocket_512830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE));
		nimln(74, "service.nim");
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_520409; LOC21.ClEnv = HEX3Aenv_520447;
		asgnRef((void**) (&writelnhook_162057.ClEnv), LOC21.ClEnv);
		writelnhook_162057.ClPrc = LOC21.ClPrc;
		{
			nimln(77, "service.nim");
			while (1) {
				NimStringDesc* LOC24;
				nimln(78, "service.nim");
				accept_514401(server, &(*HEX3Aenv_520447).stdoutsocket520408, 2);
				nimln(79, "service.nim");
				readline_516608((*HEX3Aenv_520447).stdoutsocket520408, (&inp), ((NI) -1), 2);
				nimln(50, "service.nim");
				LOC24 = 0;
				LOC24 = curcaascmd_520204; curcaascmd_520204 = copyStringRC1(inp);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				nimln(51, "service.nim");
				processcmdline_520209(((NU8) 1), inp);
				nimln(52, "service.nim");
				action();
				nimln(53, "service.nim");
				gerrorcounter_162012 = ((NI) 0);
				nimln(81, "service.nim");
				send_517208((*HEX3Aenv_520447).stdoutsocket520408, ((NimStringDesc*) &TMP10651), 2);
				nimln(82, "service.nim");
				close_514417((*HEX3Aenv_520447).stdoutsocket520408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		nimln(86, "service.nim");
		printf("%s%s\012", ((NimStringDesc*) &TMP10674)? (((NimStringDesc*) &TMP10674))->data:"nil", typ? (typ)->data:"nil");
		nimln(87, "service.nim");
		msgquit_162104(((NI8) 1));
	}
	LA4: ;
	popFrame();
}
std::vector<Object> ObjectDetectionAlgorithmTeamB::calculate(std::vector<Line> lines){

    std::vector<Object> foundObjects;
    std::vector<Object> newUnfinishedObjects;
    std::vector<Object> unfinishedObjects;

    // iterate through database objects
    for(auto model : databaseModels){

        unfinishedObjects.clear();

        // maximum rating for 1 line
        float maxRatingPerLine = 100 / model.getLines().size();

        // create possible object for every line
        for(uint firstLineIndex = 0; firstLineIndex < lines.size(); firstLineIndex++){

            Object obj;
            obj.addLine(lines[firstLineIndex]);
            obj.setRating(maxRatingPerLine - maxRatingPerLine * 0.2);
            unfinishedObjects.push_back(obj);
        }

        // iterate through lines of an object starting at 2nd line (as first lines are already in) to check all other lines
        for(uint objectLineIndex = 1; objectLineIndex < model.getLines().size(); objectLineIndex++){

            newUnfinishedObjects.clear();

            // check other object lines with found lines
            for(uint foundObjectsIndex = 0; foundObjectsIndex < unfinishedObjects.size(); foundObjectsIndex++){

                // get possible next line
                for(uint nextLineIndex = 0; nextLineIndex < lines.size(); nextLineIndex++){

                    double receivedRating = rateObject(unfinishedObjects[foundObjectsIndex], lines[nextLineIndex], model, objectLineIndex, maxRatingPerLine);

                    bool addLine = false;
                    // if rating is high enough add object
                    if(fastMode){
                        if(receivedRating > 0){
                            addLine = true;
                        }
                    }else{
                        if(receivedRating > 0 && unfinishedObjects[foundObjectsIndex].getRating() + receivedRating >= (maxRatingPerLine * (objectLineIndex + 1)) * 0.6){
                            addLine = true;
                        }
                    }

                    if(addLine){

                        // if rating was ok add line to object
                        Object newObj(unfinishedObjects[foundObjectsIndex]);
                        newObj.addLine(lines[nextLineIndex]);
                        newObj.setRating(newObj.getRating() + receivedRating);

                        newUnfinishedObjects.push_back(newObj);
                    }
                }
            }
            unfinishedObjects.clear();
            for(auto newObj : newUnfinishedObjects){
                unfinishedObjects.push_back(newObj);
            }
        }
        getBestRatedObject(unfinishedObjects, &foundObjects, model.getName());
    }
    return foundObjects;
}
示例#17
0
void main (void){
  int teclas=0;
  char tecla;
  struct Timer * timer=newObj(Timer,(ulong)30); 
 /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
 /*** End of Processor Expert internal initialization.                    ***/
  Teclas_Init();
  Display_Init(); // Inicializacion del display
  
    
  for(;;){
    WDog1_Clear();
    tecla=get_key();

    if(tecla=='u'){
      PasarASCII(" uP ",0); //texto fijo
      teclas++;
    }

    if(tecla=='d'){
      PasarASCII("down",0); //texto fijo
      teclas++;
    }

    if(tecla=='r'){
      PasarASCII("enter",0);
      teclas++;
    }

    if(tecla=='k'){
      PasarASCII("eSc ",0); //texto fijo
      teclas++;
    }

    if(tecla=='f'){
      PasarASCII("MAntEnidA",0); //texto fijo
      teclas++;      
    }

    if(tecla=='s'){
      PasarASCII("StoP",0); //texto fijo
      teclas++;      
    }
    
    
    if(Teclas_TimePass() && Timer_isfinish(timer)){
      PasarASCII("tiEMPo",0); //texto fijo     
      teclas=0; 
      Timer_Restart(timer);
    }
    

    
    if(Timer_isfinish(timer)){
      
      Pasar_Numero(teclas,1,0);
      Timer_Restart(timer);
    }

      
  }
}
示例#18
0
文件: idents.c 项目: ddlsmurf/Nimrod
N_NIMCALL(TY54011*, Getident_54023)(NCSTRING Identifier_54025, NI Length_54026, NI H_54027) {
TY54011* Result_54239;
NI Idx_54240;
NI Id_54241;
TY54011* Last_54242;
NI LOC3;
NI LOC9;
NI I_54311;
NI HEX3Atmp_54326;
NI Res_54328;
Result_54239 = 0;
Idx_54240 = 0;
Id_54241 = 0;
Last_54242 = 0;
Idx_54240 = (NI64)(H_54027 & 8191);
Result_54239 = Buckets_54041[(Idx_54240)-0];
Last_54242 = NIM_NIL;
Id_54241 = 0;
while (1) {
if (!!((Result_54239 == NIM_NIL))) goto LA1;
LOC3 = Cmpexact_54164((*Result_54239).S->data, Identifier_54025, Length_54026);
if (!(LOC3 == 0)) goto LA4;
if (!!((Last_54242 == NIM_NIL))) goto LA7;
asgnRefNoCycle((void**) &(*Last_54242).Next, (*Result_54239).Next);
asgnRefNoCycle((void**) &(*Result_54239).Next, Buckets_54041[(Idx_54240)-0]);
asgnRefNoCycle((void**) &Buckets_54041[(Idx_54240)-0], Result_54239);
LA7: ;
goto BeforeRet;
goto LA2;
LA4: ;
LOC9 = Cmpignorestyle_54042((*Result_54239).S->data, Identifier_54025, Length_54026);
if (!(LOC9 == 0)) goto LA10;
Id_54241 = (*Result_54239).Sup.Id;
goto LA2;
LA10: ;
LA2: ;
Last_54242 = Result_54239;
Result_54239 = (*Result_54239).Next;
} LA1: ;
Result_54239 = (TY54011*) newObj(NTI54009, sizeof(TY54011));
(*Result_54239).Sup.Sup.m_type = NTI54011;
(*Result_54239).H = H_54027;
asgnRefNoCycle((void**) &(*Result_54239).S, mnewString(Length_54026));
I_54311 = 0;
HEX3Atmp_54326 = 0;
HEX3Atmp_54326 = (NI64)((NI64)(Length_54026 + 0) - 1);
Res_54328 = 0;
Res_54328 = 0;
while (1) {
if (!(Res_54328 <= HEX3Atmp_54326)) goto LA12;
I_54311 = Res_54328;
(*Result_54239).S->data[I_54311] = Identifier_54025[(NI64)(I_54311 - 0)];
Res_54328 += 1;
} LA12: ;
asgnRefNoCycle((void**) &(*Result_54239).Next, Buckets_54041[(Idx_54240)-0]);
asgnRefNoCycle((void**) &Buckets_54041[(Idx_54240)-0], Result_54239);
if (!(Id_54241 == 0)) goto LA14;
Wordcounter_54233 += 1;
(*Result_54239).Sup.Id = ((NI64)-(Wordcounter_54233));
goto LA13;
LA14: ;
(*Result_54239).Sup.Id = Id_54241;
LA13: ;
BeforeRet: ;
return Result_54239;
}